Name: diC59631 Date: 08/19/98
The compiler crashed when trying to compile this
code.
public class PrintUpClass {
public static void print(Class c) {
for (int step=0; c != null ; c = c.getSuperclass(), step++) {
//print the "steps" up the inheritance tree
System.out.println(step);
//print the name of the class
//System.out.println(c.getName());
System.out.println(c);
}
}
public static void main(String[] argv) throws Exception {
if (argv.length == 0) {
print(String.class);
} else if (argv.length == 1) {
print( Class.class.forName(argv[0]) );
} else {
System.err.println("only one argument is allowed");
System.exit(-1);
}
}
}
Here was the stack trace.
java.lang.NullPointerException
at sun.tools.tree.ConditionalExpression.costInline(ConditionalExpression.java:159)
at sun.tools.tree.NaryExpression.costInline(NaryExpression.java:63)
at sun.tools.tree.MethodExpression.costInline(MethodExpression.java:543)
at sun.tools.tree.NaryExpression.costInline(NaryExpression.java:66)
at sun.tools.tree.MethodExpression.costInline(MethodExpression.java:543)
at sun.tools.tree.ExpressionStatement.costInline(ExpressionStatement.java:73)
at sun.tools.tree.IfStatement.costInline(IfStatement.java:117)
at sun.tools.tree.IfStatement.costInline(IfStatement.java:120)
at sun.tools.java.FieldDefinition.cleanup(FieldDefinition.java:509)
at sun.tools.java.ClassDefinition.cleanup(ClassDefinition.java:1180)
at sun.tools.javac.Main.compile(Main.java:369)
at sun.tools.javac.Main.main(Main.java:521)
(Review ID: 37255)
======================================================================
- duplicates
-
JDK-4069861 class literal in if statement with empty body causes NullPointerException.
-
- Closed
-