Community
Participate
Working Groups
When using the JDT/Core batch compiler to compile the GNU Classpath library, a NullPointerException is thrown. Unfortunately, I wasn't able to isolate a simple autonomous test case. Steps to reproduce: 1. Grab a snapshot of the Classpath source tree and unpack: $ wget ftp://ftp.gnu.org/pub/gnu/classpath/classpath-0.14.tar.gz $ tar zxf classpath-0.14.tar.gz; cd classpath-0.14 2. Apply the attached patch (conf.patch) to configure the source tree. Note that this step is only needed to make sure Configure.java is compilable. Normally, the ./configure script is run. $ patch -p0 < conf.patch $ mv gnu/classpath/Configuration.java.in \ gnu/classpath/Configuration.java 3. Run the batch compiler. GdkGraphics2D.java is causing the NPE, so we're compiling it directly: $ java -classpath jdtcore.jar \ org.eclipse.jdt.internal.compiler.batch.Main \ gnu/java/awt/peer/gtk/GdkGraphics2D.java Actual Results: 1. ERROR in gnu/java/awt/peer/gtk/GdkGraphics2D.java (at line 0) /* GdkGraphics2D.java -- ^ Internal compiler error java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.generateCode(AllocationExpression.java:91) at org.eclipse.jdt.internal.compiler.ast.FieldDeclaration.generateCode(FieldDeclaration.java:120) at org.eclipse.jdt.internal.compiler.ast.Clinit.generateCode(Clinit.java:216) at org.eclipse.jdt.internal.compiler.ast.Clinit.generateCode(Clinit.java:91) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:561) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:615) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:181) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:516) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335) at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:2366) at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1106) at org.eclipse.jdt.internal.compiler.batch.Main.main(Main.java:1011) Build Date & Platform: eclipse-SDK-3.1M5a-linux-gtk JRE: java-sun-1.5.0 (also reproduced using java-sun-1.4.2 and gij) Additional Information: This seems to be triggered by the first code block in the static initializer (GdkGraphics2D.java, lines 102-104) -- commenting it out resolves the issue.
Created attachment 19017 [details] Patch to configure the Classpath source tree
Reproduced once applying the patch and renaming Configuration.java.in into Configuration.java, and using following .classpath: <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry excluding="examples/|external/sax/|external/w3c_dom/|vm/reference/" kind="src" path="classpath-0.14"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="src" path="classpath-0.14/examples"/> <classpathentry kind="src" path="classpath-0.14/external/sax"/> <classpathentry kind="src" path="classpath-0.14/external/w3c_dom"/> <classpathentry kind="src" path="classpath-0.14/vm/reference"/> <classpathentry kind="output" path="bin"/> </classpath>
Simpler testcase: public class X { static { if (true) throw new NullPointerException(); } static Object o = new Object(); }
Needed to tag as unreachable field (static/non static) when flow info was not reachable, so that they are not generated in the end. Added InitializationTest#test185-186. Fixed
Verified in I20050330-0500