Bug 15030 - NPE trying to open or edit source files that reference jbuilder.jar
Summary: NPE trying to open or edit source files that reference jbuilder.jar
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 blocker (vote)
Target Milestone: 2.0 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-01 15:03 EDT by mark_dixon CLA
Modified: 2002-05-02 11:55 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mark_dixon CLA 2002-05-01 15:03:58 EDT
I'm trying to write a jbuilder OpenTool (like an eclipse plugin) using my 
favorite Java IDE, but eclipse is having a hard time with jbuilder classes.  A 
specific case follows, but almost any use of JBuilder classes seems to cause 
eclipse to fail with the same exception during e.g. code completion.  The 
regular error dialogs and lack of code completion are bearable, but not being 
able to reopen my source code is a bit of a showstopper :-)

Thanks
Mark

1. Add jbuilder.jar to the classpath
2. Create a new class and paste in the following method (from the JBuilder help 
docs)
public static void initOpenTool(byte major,
       byte minor) {

    // Check OpenTools version number
    if (major != PrimeTime.CURRENT_MAJOR_VERSION)
        return;

    // Add a new menu item to the Help menu
    JBuilderMenu.GROUP_Help.add(new BrowserAction(
        "Say Hello") {
         public void actionPerformed(Browser browser) {
             JOptionPane.showConfirmDialog(null,
                  "Hello, World!");
         }
     });
}
3. Organize imports, save and close
4. Try to reopen the file. Fails with
java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.classfmt.ClassFileStruct.u2At
(ClassFileStruct.java:147)
	at 
org.eclipse.jdt.internal.compiler.classfmt.FieldInfo.readConstantAttribute
(FieldInfo.java:172)
	at org.eclipse.jdt.internal.compiler.classfmt.FieldInfo.getConstant
(FieldInfo.java:56)
	at 
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createFields
(BinaryTypeBinding.java:151)
	at 
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom
(BinaryTypeBinding.java:133)
	at 
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom
(LookupEnvironment.java:292)
	at 
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom
(LookupEnvironment.java:275)
	at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:188)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType
(LookupEnvironment.java:65)
	at 
org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve
(UnresolvedReferenceBinding.java:23)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.superclass
(BinaryTypeBinding.java:403)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMemberType
(Scope.java:319)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage
(Scope.java:996)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getType
(Scope.java:911)
	at 
org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding
(SingleTypeReference.java:34)
	at 
org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypesFor
(SourceTypeBinding.java:799)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.methods
(SourceTypeBinding.java:663)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.buildMethods
(ClassScope.java:218)
	at 
org.eclipse.jdt.internal.compiler.lookup.ClassScope.buildFieldsAndMethods
(ClassScope.java:114)
	at 
org.eclipse.jdt.internal.compiler.lookup.ClassScope.buildAnonymousTypeBinding
(ClassScope.java:32)
	at org.eclipse.jdt.internal.compiler.lookup.BlockScope.addAnonymousType
(BlockScope.java:58)
	at 
org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.resolveType
(QualifiedAllocationExpression.java:301)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType
(MessageSend.java:195)
	at org.eclipse.jdt.internal.compiler.ast.Expression.resolve
(Expression.java:419)
	at 
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatement
s(AbstractMethodDeclaration.java:322)
	at 
org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements
(MethodDeclaration.java:64)
	at 
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve
(AbstractMethodDeclaration.java:311)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve
(TypeDeclaration.java:898)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve
(TypeDeclaration.java:930)
	at 
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve
(CompilationUnitDeclaration.java:213)
	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:561)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.resolve
(CompilationUnitProblemFinder.java:151)
	at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure
(CompilationUnit.java:81)
	at org.eclipse.jdt.internal.core.Openable.openWhenClosed
(Openable.java:394)
	at org.eclipse.jdt.internal.core.WorkingCopy.openWhenClosed
(WorkingCopy.java:332)
	at org.eclipse.jdt.internal.core.Openable.open(Openable.java:330)
	at org.eclipse.jdt.internal.core.WorkingCopy.open(WorkingCopy.java:294)
	at org.eclipse.jdt.internal.core.CompilationUnit.getWorkingCopy
(CompilationUnit.java:619)
	at org.eclipse.jdt.internal.core.CompilationUnit.getSharedWorkingCopy
(CompilationUnit.java:590)
	at 
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.createEle
mentInfo(CompilationUnitDocumentProvider.java:421)
	at org.eclipse.ui.texteditor.AbstractDocumentProvider.connect
(AbstractDocumentProvider.java:247)
	at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput
(AbstractTextEditor.java:1503)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.doSetInput
(JavaEditor.java:486)
	at 
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.doSetInput
(CompilationUnitEditor.java:933)
	at org.eclipse.ui.texteditor.AbstractTextEditor.init
(AbstractTextEditor.java:1146)
	at org.eclipse.ui.internal.EditorManager.createSite
(EditorManager.java:485)
	at org.eclipse.ui.internal.EditorManager.access$1
(EditorManager.java:483)
	at org.eclipse.ui.internal.EditorManager$2.run(EditorManager.java:467)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:56)
	at org.eclipse.ui.internal.EditorManager.openInternalEditor
(EditorManager.java:460)
	at org.eclipse.ui.internal.EditorManager.openInternalEditor
(EditorManager.java:529)
	at org.eclipse.ui.internal.EditorManager.openEditor
(EditorManager.java:361)
	at org.eclipse.ui.internal.EditorManager.openEditor
(EditorManager.java:264)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor
(WorkbenchPage.java:1637)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor
(WorkbenchPage.java:1601)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor
(EditorUtility.java:130)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor
(EditorUtility.java:102)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor
(EditorUtility.java:89)
	at org.eclipse.jdt.internal.ui.actions.OpenActionUtil.open
(OpenActionUtil.java:45)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:141)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:132)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun
(SelectionDispatchAction.java:132)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run
(SelectionDispatchAction.java:94)
	at 
org.eclipse.jdt.internal.ui.packageview.PackageExplorerActionGroup.handleDoubleC
lick(PackageExplorerActionGroup.java:214)
	at 
org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.handleDoubleClick
(PackageExplorerPart.java:500)
	at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.access$1
(PackageExplorerPart.java:499)
	at 
org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4.doubleClick
(PackageExplorerPart.java:311)
	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick
(StructuredViewer.java:286)
	at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect
(StructuredViewer.java:444)
	at org.eclipse.jface.viewers.AbstractTreeViewer$1.widgetDefaultSelected
(AbstractTreeViewer.java:627)
	at org.eclipse.swt.widgets.TypedListener.handleEvent
(TypedListener.java:92)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:75)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:637)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1412)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1208)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:833)
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:816)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:643)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:349)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:160)
	at org.eclipse.core.launcher.Main.run(Main.java:548)
	at org.eclipse.core.launcher.Main.main(Main.java:403)
Comment 1 Olivier Thomann CLA 2002-05-01 17:51:56 EDT
Where do I get the jbuilder.jar file? I think this is the first step to reproduce this problem. Is 
there a licence agreement to get it?
Comment 2 mark_dixon CLA 2002-05-01 18:09:58 EDT
There is a license agreement so I can't really send it to you.  However it is 
downloadable at no charge from 

http://www.borland.com/jbuilder/download/jb6personal_steps.html
Comment 3 Olivier Thomann CLA 2002-05-01 18:12:54 EDT
I think this has something to do with the fully initialized instances of the ClassFileReader. I 
need the jbuilder.jar to reproduce the case and then it should be fairly simple to find out what the 
problem is.
Comment 4 Olivier Thomann CLA 2002-05-01 18:46:47 EDT
I requested jbuilder.jar through the official software request form. Wait to get the jar file 
before further investigations.
Comment 5 Olivier Thomann CLA 2002-05-01 19:49:07 EDT
Which build are you using?
Comment 6 mark_dixon CLA 2002-05-01 20:56:17 EDT
Problem is definitely present in M5.  I downloaded an integration build earlier 
today which was almost certainly 20020425 (I'm not at the office so I can't be 
100% sure) and that still had the problem.
Comment 7 Olivier Thomann CLA 2002-05-02 09:57:56 EDT
Looking only at the stack trace should allow me to narrow down the problem. I will investigate it 
before I got the jbuilder.jar file.
Comment 8 Olivier Thomann CLA 2002-05-02 11:32:44 EDT
I got the jar file. I am investigating.
Comment 9 Olivier Thomann CLA 2002-05-02 11:54:28 EDT
I found the bug. It is fixed now. The problem came from the reading of the field constant value. This 
was boggus for a field that contains another attribute before the constant value attribute.
I 
will add some regression tests.
Fixed and released in HEAD.