Compiling the following class crashes javac with a CompilerError:
public class BAD {
public Object foo() {
// return new Cloneable() {} ; // OK
return new Cloneable(null) {} ; // BAD
}
}
The backtrace is:
sun.tools.java.CompilerError: stackSize null
at sun.tools.java.Type.stackSize(Type.java)
at sun.tools.tree.Context.declare(Context.java)
at sun.tools.javac.SourceField.check(SourceField.java)
at sun.tools.javac.SourceClass.checkFields(SourceClass.java)
at sun.tools.javac.SourceClass.checkInternal(SourceClass.java)
at sun.tools.javac.SourceClass.checkLocalClass(SourceClass.java)
at sun.tools.tree.NewInstanceExpression.checkValue(NewInstanceExpression.java)
at sun.tools.tree.ReturnStatement.check(ReturnStatement.java)
at sun.tools.tree.Statement.checkBlockStatement(Statement.java)
at sun.tools.tree.CompoundStatement.check(CompoundStatement.java)
at sun.tools.tree.Statement.checkMethod(Statement.java)
at sun.tools.javac.SourceField.check(SourceField.java)
at sun.tools.javac.SourceClass.checkFields(SourceClass.java)
at sun.tools.javac.SourceClass.checkInternal(SourceClass.java)
at sun.tools.javac.SourceClass.check(SourceClass.java)
at sun.tools.javac.Main.compile(Main.java)
at sun.tools.javac.Main.main(Main.java)
william.maddox@Eng 1997-07-30
public class BAD {
public Object foo() {
// return new Cloneable() {} ; // OK
return new Cloneable(null) {} ; // BAD
}
}
The backtrace is:
sun.tools.java.CompilerError: stackSize null
at sun.tools.java.Type.stackSize(Type.java)
at sun.tools.tree.Context.declare(Context.java)
at sun.tools.javac.SourceField.check(SourceField.java)
at sun.tools.javac.SourceClass.checkFields(SourceClass.java)
at sun.tools.javac.SourceClass.checkInternal(SourceClass.java)
at sun.tools.javac.SourceClass.checkLocalClass(SourceClass.java)
at sun.tools.tree.NewInstanceExpression.checkValue(NewInstanceExpression.java)
at sun.tools.tree.ReturnStatement.check(ReturnStatement.java)
at sun.tools.tree.Statement.checkBlockStatement(Statement.java)
at sun.tools.tree.CompoundStatement.check(CompoundStatement.java)
at sun.tools.tree.Statement.checkMethod(Statement.java)
at sun.tools.javac.SourceField.check(SourceField.java)
at sun.tools.javac.SourceClass.checkFields(SourceClass.java)
at sun.tools.javac.SourceClass.checkInternal(SourceClass.java)
at sun.tools.javac.SourceClass.check(SourceClass.java)
at sun.tools.javac.Main.compile(Main.java)
at sun.tools.javac.Main.main(Main.java)
william.maddox@Eng 1997-07-30
- duplicates
-
JDK-4054689 Anonymous inner class with null constructor parameter throws compiler error
- Closed