A gjc vs. javac inconsistency:
class Foo {
public static final Bar CONSTANT = new Foo.Bar() {
};
public interface Bar {
}
public Foo() {
}
}
Sun's javac will compile this input, while gjc gives an error:
$ kaffe gjc.Main Foo.java
Foo.java:2: non-static variable this cannot be referenced from a static context
public static final Bar CONSTANT = new Foo.Bar() {
Even though javac compiles it, javap crashes on the result:
Exception in thread "main" java.lang.NullPointerException
at sun.tools.java.BinaryClass.initInnerClasses(Compiled Code)
at sun.tools.java.BinaryClass.loadNested(Compiled Code)
at sun.tools.javap.JavaPEnvironment.loadDefinition(Compiled Code)
at sun.tools.java.ClassDeclaration.getClassDefinition(Compiled Code)
at sun.tools.java.Environment.getClassDefinition(Compiled Code)
at sun.tools.javap.JavaP.displayResults(Compiled Code)
at sun.tools.javap.JavaP.perform(Compiled Code)
at sun.tools.javap.JavaP.entry(Compiled Code)
at sun.tools.javap.JavaP.main(Compiled Code)
class Foo {
public static final Bar CONSTANT = new Foo.Bar() {
};
public interface Bar {
}
public Foo() {
}
}
Sun's javac will compile this input, while gjc gives an error:
$ kaffe gjc.Main Foo.java
Foo.java:2: non-static variable this cannot be referenced from a static context
public static final Bar CONSTANT = new Foo.Bar() {
Even though javac compiles it, javap crashes on the result:
Exception in thread "main" java.lang.NullPointerException
at sun.tools.java.BinaryClass.initInnerClasses(Compiled Code)
at sun.tools.java.BinaryClass.loadNested(Compiled Code)
at sun.tools.javap.JavaPEnvironment.loadDefinition(Compiled Code)
at sun.tools.java.ClassDeclaration.getClassDefinition(Compiled Code)
at sun.tools.java.Environment.getClassDefinition(Compiled Code)
at sun.tools.javap.JavaP.displayResults(Compiled Code)
at sun.tools.javap.JavaP.perform(Compiled Code)
at sun.tools.javap.JavaP.entry(Compiled Code)
at sun.tools.javap.JavaP.main(Compiled Code)
- duplicates
-
JDK-4278961 # error reporting and recovery issues in the new compiler
-
- Closed
-