Bug 10667 - NPE in self encapsulate field
Summary: NPE in self encapsulate field
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P1 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-04 05:50 EST by Ilja Preuss CLA
Modified: 2002-03-06 13:32 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ilja Preuss CLA 2002-03-04 05:50:15 EST
java.lang.reflect.InvocationTargetException: java.lang.NullPointerException
	at 
org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveNameForNameReference
(DefaultBindingResolver.java:222)
	at org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveName
(DefaultBindingResolver.java:97)
	at org.eclipse.jdt.core.dom.Name.resolveBinding(Name.java:75)
	at org.eclipse.jdt.internal.corext.refactoring.sef.AccessAnalyzer.visit
(AccessAnalyzer.java:74)
	at org.eclipse.jdt.core.dom.SimpleName.accept0(SimpleName.java:85)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1025)
	at org.eclipse.jdt.core.dom.QualifiedName.accept0(QualifiedName.java:86)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1049)
	at org.eclipse.jdt.core.dom.MethodInvocation.accept0
(MethodInvocation.java:93)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1025)
	at org.eclipse.jdt.core.dom.InfixExpression.accept0
(InfixExpression.java:264)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1025)
	at org.eclipse.jdt.core.dom.ReturnStatement.accept0
(ReturnStatement.java:69)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1049)
	at org.eclipse.jdt.core.dom.Block.accept0(Block.java:76)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:1025)
	at org.eclipse.jdt.core.dom.MethodDeclaration.accept0
(MethodDeclaration.java:183)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1049)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0
(TypeDeclaration.java:163)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:1049)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0
(CompilationUnit.java:143)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:981)
	at 
org.eclipse.jdt.internal.corext.refactoring.sef.SelfEncapsulateFieldRefactoring.
checkInput(SelfEncapsulateFieldRefactoring.java:206)
	at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run
(CheckConditionsOperation.java:58)
	at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run
(CreateChangeOperation.java:93)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run
(ModalContext.java:98)
Comment 1 Erich Gamma CLA 2002-03-04 18:18:59 EST
The actual NPE occurs deep inside the AST moving to JDT CORE
Comment 2 Dirk Baeumer CLA 2002-03-05 04:22:12 EST
Actual moving to JDT Core
Comment 3 Olivier Thomann CLA 2002-03-05 09:49:18 EST
Would you please provide a piece of code? I rewrote completely that part so it is possible that the 
problem is already fixed. Please send me the code of the class and provide some steps to 
reproduce.
Thanks for the report.
Comment 4 Ilja Preuss CLA 2002-03-05 10:37:10 EST
Put the following class in its own project, default package:

------------------------------------
import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class RefactoringTest extends JFrame {

  private static RefactoringTest frame;

  private RefactoringTest() {
    getContentPane().add(new JButton(), BorderLayout.SOUTH);
  }

  public synchronized static RefactoringTest instance() {
    if (frame == null) {
      frame = new RefactoringTest();
    }
    return frame;
  }

}
------------------------------------

Activate "Self Encapsulate Field" on frame. Click "Next>".

After a short moment, "Internal error while creating change object." gets 
displayed.
Comment 5 Olivier Thomann CLA 2002-03-06 13:32:52 EST
I could complete the refactoring without getting any error. So this is fixed with the latest 
changes made on the name resolution.
Closed.