Bug 147875 - [1.5][compiler] NPE when initializing annotations of a binary field
Summary: [1.5][compiler] NPE when initializing annotations of a binary field
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.2.1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 147880 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-20 10:53 EDT by Jesse Eichar CLA
Modified: 2006-09-12 04:05 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (2.06 KB, patch)
2006-06-28 10:08 EDT, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Eichar CLA 2006-06-20 10:53:59 EDT
An error occurs while generating the AST resulting in a NULL AST.  I will attach a project where the class has the problem.  Here is the error:

eclipse.buildId=I20060602-1317
java.version=1.5.0_06
java.vendor=Apple Computer, Inc.
BootLoader constants: OS=macosx, ARCH=x86, WS=carbon, NL=en_US
Framework arguments:  -keyring /Users/Jesse/.eclipse_keyring -showlocation
Command-line arguments:  -os macosx -ws carbon -keyring /Users/Jesse/.eclipse_keyring -consoleLog -showlocation
This is a continuation of log file /Users/Jesse/Development/workspace/udig/udig3.1/.metadata/.bak_2.log
Created Time: 2006-06-19 23:12:38.956

Error
Tue Jun 20 07:49:31 PDT 2006
Error in JDT Core during AST creation

java.lang.NullPointerException
at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding$2.compare(ReferenceBinding.java:49)
at java.util.Arrays.mergeSort(Arrays.java:1284)
at java.util.Arrays.sort(Arrays.java:1265)
at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.sortFields(ReferenceBinding.java:153)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.getField(BinaryTypeBinding.java:708)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.convertMemberValue(BinaryTypeBinding.java:62)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createAnnotation(BinaryTypeBinding.java:82)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createAnnotations(BinaryTypeBinding.java:92)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createFields(BinaryTypeBinding.java:344)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:312)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:579)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:558)
at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:272)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:102)
at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:43)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:97)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.convertMemberValue(BinaryTypeBinding.java:61)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createAnnotation(BinaryTypeBinding.java:82)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createAnnotations(BinaryTypeBinding.java:92)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethod(BinaryTypeBinding.java:483)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethods(BinaryTypeBinding.java:530)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:313)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:579)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:558)
at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:272)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:102)
at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:43)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveUnresolvedType(BinaryTypeBinding.java:138)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.superInterfaces(BinaryTypeBinding.java:920)
at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.implementsInterface(ReferenceBinding.java:791)
at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith0(ReferenceBinding.java:937)
at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith(ReferenceBinding.java:890)
at org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel(Scope.java:3495)
at org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel(Scope.java:3483)
at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:443)
at org.eclipse.jdt.internal.compiler.lookup.Scope.getConstructor(Scope.java:1605)
at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType(AllocationExpression.java:301)
at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:344)
at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:880)
at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:432)
at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:179)
at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:403)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1047)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1094)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:353)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:882)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:508)
at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:832)
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:630)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:605)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:600)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:514)
at org.eclipse.jdt.internal.ui.text.java.hover.NLSStringHover.getHoverInfo(NLSStringHover.java:86)
at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102)
at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69)
at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:160)
Comment 1 Olivier Thomann CLA 2006-06-20 10:59:10 EDT
Could be a dup of bug 143259.
Could you please try with latest integration build?
Comment 2 Olivier Thomann CLA 2006-06-20 13:47:12 EDT
*** Bug 147880 has been marked as a duplicate of this bug. ***
Comment 3 Jesse Eichar CLA 2006-06-20 21:31:20 EDT
Tried integration build I20060620-1010 and bug still exists.  I have put a small project that illustrates the bug online at:

udig.refractions.net/NullASTBug.zip

Both classes demonstrate the bug.  

In Test.java you can make the AST generate correctly by changing DefaultGeographicCRS.WGS84 to null.  (And make it fail by switching it back)

Let me know if you still have questions.
Comment 4 Olivier Thomann CLA 2006-06-20 22:40:23 EDT
Reproduced.
Thanks for the test case.
Philippe,
The given test case reproduces the problem. The annotation initialization seems to be responsible of the NPE.
Comment 5 Philipe Mulet CLA 2006-06-28 10:08:42 EDT
Created attachment 45465 [details]
Proposed patch

This is a bug due to reentrance, where an annotation on a binary field is denoting a field of the same binary type, which hasn't yet been constructed.

Fix is to defer the annotation reification after the initial fields construction.
Comment 6 Philipe Mulet CLA 2006-06-28 10:12:04 EDT
Olivier - could you construct a DOM AST regression test ?
Problem is located on binary ref to org.opengis.annotation.Obligation which fields carry some self-referring annotations.
Comment 7 Philipe Mulet CLA 2006-06-28 12:46:28 EDT
Olivier - pls release the changes to both HEAD and 3.2.1, once you have the regression test.
Comment 8 Olivier Thomann CLA 2006-06-28 13:12:41 EDT
Released for 3.3 M1.
Regression test added in org.eclipse.jdt.core.tests.dom.ASTConverter15Test.test0221.
Comment 9 Olivier Thomann CLA 2006-06-28 13:24:47 EDT
Released for 3.2.1.
Same regression test.
Comment 10 Frederic Fusier CLA 2006-08-08 09:37:13 EDT
Verified for 3.3 M1 using build I20060807-2000.
Comment 11 David Audel CLA 2006-09-12 04:05:32 EDT
Verified for 3.2.1 using build M20060908-1655