Community
Participate
Working Groups
Build ID: I20080617-2000 Steps To Reproduce: 1. Create the following file: package test2; import test.Map; public class Test { } 2. Add test.jar attached to the build path. 3. Get the following error in the Problems view: Description Location Resource Path Type Internal compiler error java.lang.NullPointerException line 0 Test.java java-scala-test/src/test2 Java Problem Description Location Resource Path Type Internal compiler error java.lang.NullPointerException line 0 Test.java java-scala-test/src/test Java Problem More information: The reason why I am attaching the test.jar with .class files instead of the java source is that it's generated from Scala source. At first I thought it was a bug in the Scala compiler, but javac compiles the code fine and a NPE doesn't sound like the right feedback even if the .class file is invalid (I don't know if it is or if it isn't though). Looking through the logs, there was also: Java Model Exception: java.lang.NullPointerException at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:222) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:243) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:190) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:709) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:770) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1224) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1185) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:131) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:149) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:102) at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77) at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206) Caused by: java.lang.NullPointerException Caused by: java.lang.NullPointerException
Created attachment 110502 [details] Jar containing the class file for test.Map
(In reply to comment #0) > Description Location Resource Path Type > Internal compiler error > java.lang.NullPointerException > line 0 Test.java java-scala-test/src/test2 Java Problem > > Description Location Resource Path Type > Internal compiler error > java.lang.NullPointerException > line 0 Test.java java-scala-test/src/test Java Problem Sorry, ignore the second error. I pasted it twice by mistake. Just the first one is relevant.
I am getting a slightly different stack trace. java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.util.SimpleLookupTable.get(SimpleLookupTable.java:68) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createParameterizedType(LookupEnvironment.java:859) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:1283) at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethod(BinaryTypeBinding.java:480) at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethods(BinaryTypeBinding.java:561) at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:326) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:719) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:699) at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:294) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:128) at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:182) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findImport(CompilationUnitScope.java:456) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findSingleImport(CompilationUnitScope.java:510) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInImports(CompilationUnitScope.java:359) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:435) at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:852) at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:904) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:182) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:243) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:190) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:709) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:769) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1224) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:124) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:149) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:102) at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77) at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
The signature of a method has an unexpected shape which leads to the NPE when trying to resolve the method. The signature is: (TA;)Ltest/Map<TA;TB;>.Map$MapTo; and the expected one should be: (TA;)Ltest/Map<TA;TB;>.MapTo; The method org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.getMemberType(char[]) expects the member name not to contain its enclosing type name. We should be more resilient, but this is also failing with javac once the source file is slightly modified. Try to compile: import test.Map; public class X implements Map { public Map.MapTo $plus(Object o) { } } You get: d:\tests_sources>javac X.java -classpath d:\Downloads\test.jar X.java:3: cannot access test.Map$Map$MapTo class file for test.Map$Map$MapTo not found public class X implements Map { ^ X.java:4: $plus(java.lang.Object) in X cannot implement $plus(A) in test.Map; attempting to use incompatible return type found : test.Map.MapTo required: test.Map$Map$MapTo public Map.MapTo $plus(Object o) { ^ 2 errors which means that the decoding of the member type also fails since it is looking for a type Map$Map$MapTo.
Thanks for looking into this. Is it right to say that there's a bug in the bytecode generated by the Scala compiler then?
I would say yes. The signature is boggus, but we could be more resilient than failing with a NPE. So both sides need to be fixed: scala compiler and our compiler to "properly" reject such boggus signatures.
Makes sense, I filed a bug in the Scala bug tracker too (in case someone else hits this): http://lampsvn.epfl.ch/trac/scala/ticket/1263
Created attachment 112240 [details] Proposed patch With this patch, the supplied testcase fails the build with an error: The class file Map<A,B> contains a signature '(TA;)Ltest/Map<TA;TB;>.Map$MapTo;' ill-formed at position 23 The error message is our existing CorruptedSignature message. If we believe this problem is more common then we can make a specific one for corrupted member type signatures. Ok?
I am not sure if the question was directed at me, but I'm happy with the proposed error.
It was directed at anyone who is listening ;)
Fix released into 3.5M3 To verify: 1. Add test.jar attached to the build path. 2. Create the following file: import test.Map; public class Test {} 3. Verify that the error "The class file Map<A,B> contains a signature '(TA;)Ltest/Map<TA;TB;>.Map$MapTo;' ill-formed at position 23" appears and no stack trace is dumped
*** Bug 241978 has been marked as a duplicate of this bug. ***
Verified for 3.5M3 using I20081026-2000 build.
Created attachment 124046 [details] Patch for 3.4 maintenance branch
+1 for 3.4.2
Reopen to close for 3.4.2.
Released for 3.4.2.
Unfortunately, we missed to backport this fix into 3.4.2 stream. So, change the target to 3.5M3 and set as verified in this stream...
This is backported to 3.4.2. The map file is updated with the corresponding version.
(In reply to comment #19) > This is backported to 3.4.2. > The map file is updated with the corresponding version. > That's right. Sorry for the confusion => I put back the 3.4.2 target and I'll verify it when tomorrow's maintenance build will be available
Reopening to close as RESOLVED/FIXED and not VERIFIED/FIXED.
Fixed.
(In reply to comment #21) > Reopening to close as RESOLVED/FIXED and not VERIFIED/FIXED. > FYI, it was not necessary to reopen the bug as I set the Status Whiteboard to 'To be verified for 3.4.2.' (see JDT/Core bug life cycle step 2.1 in the FAQ)...
Verified for 3.4.2 using M20090204-1400.
*** Bug 265995 has been marked as a duplicate of this bug. ***