Bug 9016

Summary: DOM/AST: Problems with array.length access
Product: [Eclipse Project] JDT Reporter: Dirk Baeumer <dirk_baeumer>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 M3   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Dirk Baeumer CLA 2002-02-04 08:06:53 EST
Asking the VariableBinding of 'array'.length for a key results in a null 
pointer exception. The stack trace is:

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.getTypeBinding
(Lorg/eclipse/jdt/internal/compiler/lookup/TypeBinding;)
Lorg/eclipse/jdt/core/dom/ITypeBinding;
   org/eclipse/jdt/core/dom/VariableBinding.getDeclaringClass()
Lorg/eclipse/jdt/core/dom/ITypeBinding;
   org/eclipse/jdt/core/dom/VariableBinding.getKey()Ljava/lang/String;
   org/eclipse/jdt/internal/corext/dom/BindingIdentifier.matches
(Lorg/eclipse/jdt/core/dom/IBinding;)Z
   
org/eclipse/jdt/internal/corext/refactoring/sef/AccessAnalyzer.getFieldBinding
(Lorg/eclipse/jdt/core/dom/Name;)Lorg/eclipse/jdt/core/dom/IVariableBinding;
   
org/eclipse/jdt/internal/corext/refactoring/sef/AccessAnalyzer.handleSimpleName
(Lorg/eclipse/jdt/core/dom/SimpleName;)V
   org/eclipse/jdt/internal/corext/refactoring/sef/AccessAnalyzer.visit
(Lorg/eclipse/jdt/core/dom/SimpleName;)Z
   org/eclipse/jdt/core/dom/SimpleName.accept0
(Lorg/eclipse/jdt/core/dom/ASTVisitor;)V
   org/eclipse/jdt/core/dom/ASTNode.acceptChild
(Lorg/eclipse/jdt/core/dom/ASTVisitor;Lorg/eclipse/jdt/core/dom/ASTNode;)V
   org/eclipse/jdt/core/dom/QualifiedName.accept0
(Lorg/eclipse/jdt/core/dom/ASTVisitor;)V
   org/eclipse/jdt/core/dom/ASTNode.acceptChildren
(Lorg/eclipse/jdt/core/dom/ASTVisitor;Lorg/eclipse/jdt/core/dom/ASTNode$NodeList
;)V
   org/eclipse/jdt/core/dom/MethodInvocation.accept0
(Lorg/eclipse/jdt/core/dom/ASTVisitor;)V
   org/eclipse/jdt/core/dom/ASTNode.acceptChild
(Lorg/eclipse/jdt/core/dom/ASTVisitor;Lorg/eclipse/jdt/core/dom/ASTNode;)V
   org/eclipse/jdt/core/dom/ExpressionStatement.accept0
(Lorg/eclipse/jdt/core/dom/ASTVisitor;)V
   org/eclipse/jdt/core/dom/ASTNode.acceptChildren
(Lorg/eclipse/jdt/core/dom/ASTVisitor;Lorg/eclipse/jdt/core/dom/ASTNode$NodeList
;)V
   org/eclipse/jdt/core/dom/Block.accept0(Lorg/eclipse/jdt/core/dom/ASTVisitor;)
V
   org/eclipse/jdt/core/dom/ASTNode.acceptChild
(Lorg/eclipse/jdt/core/dom/ASTVisitor;Lorg/eclipse/jdt/core/dom/ASTNode;)V
   org/eclipse/jdt/core/dom/MethodDeclaration.accept0
(Lorg/eclipse/jdt/core/dom/ASTVisitor;)V
   org/eclipse/jdt/core/dom/ASTNode.acceptChildren
(Lorg/eclipse/jdt/core/dom/ASTVisitor;Lorg/eclipse/jdt/core/dom/ASTNode$NodeList
;)V
   org/eclipse/jdt/core/dom/TypeDeclaration.accept0
(Lorg/eclipse/jdt/core/dom/ASTVisitor;)V
   org/eclipse/jdt/core/dom/ASTNode.acceptChildren
(Lorg/eclipse/jdt/core/dom/ASTVisitor;Lorg/eclipse/jdt/core/dom/ASTNode$NodeList
;)V
   org/eclipse/jdt/core/dom/CompilationUnit.accept0
(Lorg/eclipse/jdt/core/dom/ASTVisitor;)V
   org/eclipse/jdt/core/dom/ASTNode.accept
(Lorg/eclipse/jdt/core/dom/ASTVisitor;)V
   
org/eclipse/jdt/internal/corext/refactoring/sef/SelfEncapsulateFieldRefactoring.
checkInput(Lorg/eclipse/core/runtime/IProgressMonitor;)
Lorg/eclipse/jdt/internal/corext/refactoring/base/RefactoringStatus;
   org/eclipse/jdt/internal/ui/refactoring/CheckConditionsOperation.run
(Lorg/eclipse/core/runtime/IProgressMonitor;)V
   org/eclipse/jdt/internal/ui/refactoring/CreateChangeOperation.run
(Lorg/eclipse/core/runtime/IProgressMonitor;)V
   org/eclipse/jface/operation/ModalContext$ModalContextThread.run()V

Reason is that the declaringClass of the compiler's FieldBinding is null.
Comment 1 Olivier Thomann CLA 2002-02-04 08:51:07 EST
This will be fixed today.
Comment 2 Olivier Thomann CLA 2002-02-04 11:08:44 EST
In case the field is .length, there is no declaring class associated with it. Then the getKey() on a 
VariableBinding should check if the declaring class is not null, before trying to include the 
declaring class getKey() inside the variable binding key.
Fixed. Wait for the build input to 
release it.
Comment 3 Olivier Thomann CLA 2002-02-04 12:07:31 EST
Released.