jdk8/jdk8/langtools: d54300fb3554 (original) (raw)
OpenJDK / jdk8 / jdk8 / langtools
changeset 668:d54300fb3554
6956462: AssertionError exception thrown in the Compiler Tree API in JDK 7. Reviewed-by: jjg
sundar | |
---|---|
date | Fri, 03 Sep 2010 12:36:43 +0530 |
parents | 25dd23fa2511 |
children | 68e765b1e9ed |
files | src/share/classes/com/sun/tools/javac/comp/Attr.java test/tools/javac/T6956462/T6956462.java test/tools/javac/T6956462/TestClass.java |
diffstat | 3 files changed, 168 insertions(+), 0 deletions(-)[+] [-] src/share/classes/com/sun/tools/javac/comp/Attr.java 12 test/tools/javac/T6956462/T6956462.java 126 test/tools/javac/T6956462/TestClass.java 30 |
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Sep 03 11:25:43 2010 +0530 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Sep 03 12:36:43 2010 +0530 @@ -328,6 +328,12 @@ attribExpr(expr, env); } catch (BreakAttr b) { return b.env;
} catch (AssertionError ae) {[](#l1.7)
if (ae.getCause() instanceof BreakAttr) {[](#l1.8)
return ((BreakAttr)(ae.getCause())).env;[](#l1.9)
} else {[](#l1.10)
throw ae;[](#l1.11)
}[](#l1.12) } finally {[](#l1.13) breakTree = null;[](#l1.14) log.useSource(prev);[](#l1.15)
@@ -342,6 +348,12 @@ attribStat(stmt, env); } catch (BreakAttr b) { return b.env;
} catch (AssertionError ae) {[](#l1.20)
if (ae.getCause() instanceof BreakAttr) {[](#l1.21)
return ((BreakAttr)(ae.getCause())).env;[](#l1.22)
} else {[](#l1.23)
throw ae;[](#l1.24)
}[](#l1.25) } finally {[](#l1.26) breakTree = null;[](#l1.27) log.useSource(prev);[](#l1.28)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T6956462/T6956462.java Fri Sep 03 12:36:43 2010 +0530 @@ -0,0 +1,126 @@ +/*
- *
- *
- *
- *
- or visit www.oracle.com if you need additional information or have any
- / + +/
- *
- / + +import java.io.; +import java.net.URISyntaxException; +import java.util.; +import javax.tools.; +import javax.tools.JavaCompiler.CompilationTask; +import com.sun.source.tree.; +import com.sun.source.util.; + +public class T6956462 {
- public static void main(String[] args) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();[](#l2.46)
if (compiler == null) {[](#l2.47)
throw new RuntimeException("can't get javax.tools.JavaCompiler!");[](#l2.48)
}[](#l2.49)
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);[](#l2.50)
List<File> files = new ArrayList<File>();[](#l2.51)
files.add(new File(T6956462.class.getResource("TestClass.java").toURI()));[](#l2.52)
final CompilationTask task = compiler.getTask(null, fm, null,[](#l2.53)
null, null, fm.getJavaFileObjectsFromFiles(files));[](#l2.54)
JavacTask javacTask = (JavacTask) task;[](#l2.55)
for (CompilationUnitTree cu : javacTask.parse()) {[](#l2.56)
cu.accept(new MyVisitor(javacTask), null);[](#l2.57)
}[](#l2.58)
- }
- private static class MyVisitor extends SimpleTreeVisitor<Tree, Void> {
private final Trees trees;[](#l2.62)
private CompilationUnitTree file;[](#l2.63)
private MyVisitor(JavacTask javac) {[](#l2.65)
this.trees = Trees.instance(javac);[](#l2.66)
}[](#l2.67)
@Override[](#l2.69)
public Tree visitCompilationUnit(CompilationUnitTree file, Void v) {[](#l2.70)
this.file = file;[](#l2.71)
for (Tree typeDecl : file.getTypeDecls()) {[](#l2.72)
typeDecl.accept(this, v);[](#l2.73)
}[](#l2.74)
return null;[](#l2.75)
}[](#l2.76)
@Override[](#l2.78)
public Tree visitImport(ImportTree imp, Void v) {[](#l2.79)
return null;[](#l2.80)
}[](#l2.81)
@Override[](#l2.83)
public Tree visitMethodInvocation(MethodInvocationTree invoke, Void v) {[](#l2.84)
invoke.getMethodSelect().accept(this, v);[](#l2.85)
return null;[](#l2.86)
}[](#l2.87)
@Override[](#l2.89)
public Tree visitBlock(BlockTree block, Void v) {[](#l2.90)
for (StatementTree stat : block.getStatements()) {[](#l2.91)
stat.accept(this, v);[](#l2.92)
}[](#l2.93)
return null;[](#l2.94)
}[](#l2.95)
@Override[](#l2.97)
public Tree visitClass(ClassTree clazz, Void v) {[](#l2.98)
for (Tree member : clazz.getMembers()) {[](#l2.99)
member.accept(this, v);[](#l2.100)
}[](#l2.101)
return null;[](#l2.102)
}[](#l2.103)
@Override[](#l2.105)
public Tree visitIdentifier(IdentifierTree ident, Void v) {[](#l2.106)
trees.getScope(trees.getPath(file, ident));[](#l2.107)
return null;[](#l2.108)
}[](#l2.109)
@Override[](#l2.111)
public Tree visitMethod(MethodTree method, Void v) {[](#l2.112)
method.getBody().accept(this, v);[](#l2.113)
return null;[](#l2.114)
}[](#l2.115)
@Override[](#l2.117)
public Tree visitMemberSelect(MemberSelectTree select, Void v) {[](#l2.118)
select.getExpression().accept(this, v);[](#l2.119)
return null;[](#l2.120)
}[](#l2.121)
@Override[](#l2.123)
public Tree visitVariable(VariableTree var, Void v) {[](#l2.124)
var.getInitializer().accept(this, v);[](#l2.125)
return null;[](#l2.126)
}[](#l2.127)
- }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T6956462/TestClass.java Fri Sep 03 12:36:43 2010 +0530 @@ -0,0 +1,30 @@ +/*
- *
- *
- *
- *
- or visit www.oracle.com if you need additional information or have any
- */ + +import java.io.PrintStream; + +abstract class TestClass {
- private void test() {
final PrintStream out = System.out;[](#l3.31)
- }