Community
Participate
Working Groups
One of my sourcecode files in a Java 5.0 project causes the eclipse compiler to stop compiling with an "internal compiler error" - but only if that file is changed and compiled alone. If I recompile the whole project afterwards (or change the file again which causes eclipse to do a full build in this case) it compiles without problems. Unfortunately I cannot extract a single sourcecode example to reproduce the problem because it seems that it is caused by the overall project and/or class structure. Below you'll find the stack trace from the error log. java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.enclosingType(ParameterizedTypeBinding.java:256) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createRawType(LookupEnvironment.java:497) at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.swapUnresolved(ParameterizedTypeBinding.java:873) at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.setResolvedType(UnresolvedReferenceBinding.java:75) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:405) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:393) at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:190) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:99) at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:43) at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveUnresolvedType(BinaryTypeBinding.java:92) at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.memberTypes(BinaryTypeBinding.java:722) at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.memberTypes(ParameterizedTypeBinding.java:671) at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.getMemberType(ParameterizedTypeBinding.java:457) at org.eclipse.jdt.internal.compiler.lookup.Scope.findMemberType(Scope.java:998) at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2393) at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:2237) at org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding(SingleTypeReference.java:39) at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:124) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypeFor(SourceTypeBinding.java:1176) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields(SourceTypeBinding.java:630) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTypesForFieldsAndMethods(SourceTypeBinding.java:616) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:393) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:497) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:329) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:240) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:190) at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:114) at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:227) at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:155) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:593) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:168) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:202) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:231) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:234) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:253) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:282) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:139) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:200) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:67)
ps: Tested with 3.1RC1
Please provide steps to reproduce, then reopen.
A parameterized member type cannot have a type not associated with an enclosing type. Suspecting the type of param type to not be a generic type, but rather another parameterized type. Would need a testcase to find offending scenario.
Created attachment 21934 [details] ZIP containing Eclipse 3.1RC1 project to reproduce the problem
Ok, I took the code apart and isolated the problem. The attachment contains a stripped down Eclipse project that should allow you to reproduce the problem. Changing and then recompiling the "RecordStringTransform.java" sourcecode (or that of a base class) causes the mentioned compiler error on my system on each second compilation. While digging into this I also found a way to prevent the compiler error. You'll find the necessary change in the "StringTransform.java" sourcecode, preceded with a comment containing "FIX:". It is a declaration that misses a generic type declaration (the project had been converted to JDK 5.0). But as far as I can see the code is not wrong without the declaration but just using the raw type.
Thank you much.
Created attachment 22182 [details] Batch compiler test case that reproduces the problem _test34 shows that the suggested workaround works _test35 reproduces the problem on a small code base _test36 shows that simplistic attempts to simplify _test35 fail to reproduce the problem
Problem came from lazy enclosing type resolution. When needing the enclosing type (during UnresolvedReferenceBinding.setResolvedType(...)), the binary type didn't yet know it had any. Moved enclosingType init in BinaryTypeBinding constructor, and ensured all creator of ParameterizedTypeBinding specify an enclosing type if any (it is no longer ok to pass null, and rely on resolution later on, since the enclosingType is a criteria for reusing the binding in the cache). Added GenericTypeTest#test711-712 (adapted from proposed batch test 34&35).
forgot to reassign
fixed
*** Bug 98232 has been marked as a duplicate of this bug. ***
Verified for 3.1 RC2 using build N20050607-0010 + JDT/Core HEAD
Verified with I20050610-0010