Bug 9309 - DOM/AST: NPE when trying to resolve a binding
Summary: DOM/AST: NPE when trying to resolve a binding
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-02-08 09:13 EST by Dirk Baeumer CLA
Modified: 2002-02-11 04:52 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2002-02-08 09:13:51 EST
I have the following source code which contains a compile error since the type 
of the field is unknown. I can build an AST for it but if I try to resolve the 
binding of the field 'field' I get a NPE. Here is the source code

public class A {
	List field;
}


Log: Fri Feb 08 15:08:07 CET 2002
1 org.eclipse.core.resources 4 Unhandled exception caught in event loop.
Log: Fri Feb 08 15:08:07 CET 2002
4 org.eclipse.ui 0 java.lang.NullPointerException
java.lang.NullPointerException

Stack trace:
   java/lang/Throwable.<init>()V
   java/lang/Throwable.<init>(Ljava/lang/String;)V
   java/lang/NullPointerException.<init>(Ljava/lang/String;)V
   org/eclipse/jdt/core/dom/DefaultBindingResolver.getVariableBinding
(Lorg/eclipse/jdt/internal/compiler/lookup/VariableBinding;)
Lorg/eclipse/jdt/core/dom/IVariableBinding;
   org/eclipse/jdt/core/dom/DefaultBindingResolver.resolveVariable
(Lorg/eclipse/jdt/core/dom/VariableDeclaration;)
Lorg/eclipse/jdt/core/dom/IVariableBinding;
   org/eclipse/jdt/core/dom/VariableDeclaration.resolveBinding()
Lorg/eclipse/jdt/core/dom/IVariableBinding;
   
org/eclipse/jdt/internal/corext/refactoring/sef/SelfEncapsulateFieldRefactoring.
checkActivation(Lorg/eclipse/core/runtime/IProgressMonitor;)
Lorg/eclipse/jdt/internal/corext/refactoring/base/RefactoringStatus;
   org/eclipse/jdt/internal/ui/refactoring/actions/RefactoringStarter.activate
(Lorg/eclipse/jdt/internal/corext/refactoring/base/Refactoring;Lorg/eclipse/jdt/
internal/ui/refactoring/RefactoringWizard;Ljava/lang/String;Z)V
   
org/eclipse/jdt/internal/ui/refactoring/actions/SelfEncapsulateFieldAction.run()
V
   org/eclipse/jface/action/Action.runWithEvent(Lorg/eclipse/swt/widgets/Event;)
V
   org/eclipse/jface/action/ActionContributionItem.handleWidgetSelection
(Lorg/eclipse/swt/widgets/Event;)V
   org/eclipse/jface/action/ActionContributionItem.handleWidgetEvent
(Lorg/eclipse/swt/widgets/Event;)V
   org/eclipse/jface/action/ActionContributionItem.access$0
(Lorg/eclipse/jface/action/ActionContributionItem;Lorg/eclipse/swt/widgets/Event
;)V
   org/eclipse/jface/action/ActionContributionItem$ActionListener.handleEvent
(Lorg/eclipse/swt/widgets/Event;)V
   org/eclipse/swt/widgets/EventTable.sendEvent(Lorg/eclipse/swt/widgets/Event;)
V
   org/eclipse/swt/widgets/Widget.notifyListeners
(ILorg/eclipse/swt/widgets/Event;)V
   org/eclipse/swt/widgets/Display.runDeferredEvents()Z
   org/eclipse/swt/widgets/Display.readAndDispatch()Z
   org/eclipse/ui/internal/Workbench.runEventLoop()V
   org/eclipse/ui/internal/Workbench.run(Ljava/lang/Object;)Ljava/lang/Object;
   org/eclipse/core/internal/boot/InternalBootLoader.run
(Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;)
Ljava/lang/Object;
   org/eclipse/core/boot/BootLoader.run
(Ljava/lang/String;Ljava/net/URL;Ljava/lang/String;[Ljava/lang/String;)
Ljava/lang/Object;
   SlimLauncher.main([Ljava/lang/String;)V
Comment 1 Olivier Thomann CLA 2002-02-08 09:57:18 EST
In this case we should return null. The error saying that the type List cannot be resolved should be 
reported on the compilatio unit.
I am working on it.
Comment 2 Olivier Thomann CLA 2002-02-08 10:32:04 EST
Missing a null check.
Fixed and released in HEAD.