Community
Participate
Working Groups
Build Identifier: M20090917-0800 Manually (not using refactor assist) move a field F in class A to class B and this field is used by a method in class A. The method will show an error because it doesn't know . Then try to use refactor move method from class A to class B. You'll receive the error "an unhandled exception occurred while performing the refactoring." Reproducible: Always Steps to Reproduce: Manually (not using refactor assist) move a field F in class A to class B and this field is used by a method in class A. The method will show an error because it doesn't know . Then try to use refactor move method from class A to class B. You'll receive the error "an unhandled exception occurred while performing the refactoring."
Would it be possible to get the .log file inside the .metadata folder?
Created attachment 181635 [details] Gzipped log file as requested
Ok, this seems to be the problem that you are getting:java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.Bindings.equals(Bindings.java:78) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor$MethodBodyRewriter.visit(MoveInstanceMethodProcessor.java:632) at org.eclipse.jdt.core.dom.SimpleName.accept0(SimpleName.java:148) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2528) at org.eclipse.jdt.core.dom.ReturnStatement.accept0(ReturnStatement.java:136) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2551) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:136) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createMethodBody(MoveInstanceMethodProcessor.java:2055) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createMethodCopy(MoveInstanceMethodProcessor.java:2224) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createChangeManager(MoveInstanceMethodProcessor.java:1776) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.checkFinalConditions(MoveInstanceMethodProcessor.java:1270) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:224) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:85) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:211) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) Would it be possible for you to provide a self-containing test that reproduces this issue ? You are getting a null binding and we need to understand why. Thanks.
Did you attempt to follow my instructions to reproduce? I noticed that I couldn't reproduce it on Helios, so please make sure to use last year's version. Thanks, Jeff
(In reply to comment #0) > Steps to Reproduce: > Manually (not using refactor assist) move a field F in class A to class B and > this field is used by a method in class A. The method will show an error > because it doesn't know . > > Then try to use refactor move method from class A to class B. You'll receive > the error "an unhandled exception occurred while performing the refactoring." Do you mean that you are using refactoring on the code that contains the error reported in the first step ?
(In reply to comment #5) > (In reply to comment #0) > > Steps to Reproduce: > > Manually (not using refactor assist) move a field F in class A to class B and > > this field is used by a method in class A. The method will show an error > > because it doesn't know . > > > > Then try to use refactor move method from class A to class B. You'll receive > > the error "an unhandled exception occurred while performing the refactoring." > Do you mean that you are using refactoring on the code that contains the error > reported in the first step ? Yes.
(In reply to comment #4) > Did you attempt to follow my instructions to reproduce? I noticed that I > couldn't reproduce it on Helios, so please make sure to use last year's > version. There is no more updates of the 3.5.x stream. Could you please try your test case with 3.6.1? Thanks.
I got this error: java.lang.NullPointerException at org.eclipse.jdt.internal.core.search.matching.FieldLocator.reportDeclaration(FieldLocator.java:281) at org.eclipse.jdt.internal.core.search.matching.FieldLocator.matchReportReference(FieldLocator.java:153) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2219) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2694) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2421) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1673) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1083) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1124) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1256) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchDeclarations(BasicSearchEngine.java:1513) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchDeclarationsOfAccessedFields(BasicSearchEngine.java:1561) at org.eclipse.jdt.core.search.SearchEngine.searchDeclarationsOfAccessedFields(SearchEngine.java:1120) at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2.searchReferencedFields(RefactoringSearchEngine2.java:513) at org.eclipse.jdt.internal.corext.refactoring.structure.MemberVisibilityAdjustor.adjustVisibility(MemberVisibilityAdjustor.java:739) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createChangeManager(MoveInstanceMethodProcessor.java:1778) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.checkFinalConditions(MoveInstanceMethodProcessor.java:1274) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:224) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:85) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:209) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) This is also reproducable in 3.6.1 and HEAD. I could not reproduce your initial issue. So you either better describe your steps or you try with 3.6.1 to tell me if you also get it with this build.
Created attachment 181792 [details] Proposed fix Patch for the second exception since I cannot reproduce the first one.
Oliver: Thanks so much for looking into this. It's not clear to me what you're doing or asking for. You've begun to talk about two different exceptions and mentioned that you've been able to reproduce one of them. I was only reporting one particular bug. I believe I described how to reproduce it. I had asked if you were able to reproduce it using the steps I described with the version of Eclipse I reported. Have you been able to do this? Thanks, Jeff (In reply to comment #9) > Created an attachment (id=181792) [details] > Proposed fix > > Patch for the second exception since I cannot reproduce the first one.
(In reply to comment #10) > I believe I described how to reproduce it. I had asked if you were able to > reproduce it using the steps I described with the version of Eclipse I > reported. Have you been able to do this? No, this is too general. Trying to reproduce it I caused another exception which is fixed now. This is your steps: << Manually (not using refactor assist) move a field F in class A to class B and this field is used by a method in class A. The method will show an error because it doesn't know . Then try to use refactor move method from class A to class B. You'll receive the error "an unhandled exception occurred while performing the refactoring." >> It would be easier if you actually describe what you have in A, B,.. So something like this: 1) Create a new Java project 2) Create a class A in this project with the following contents: .... 3) Create a class B in this project with the following contents: .... 4) Go to A and delete the field F. 5) You should see an error ..... at this moment reported again the method .... in A. 6) Select .... and use the Move refactoring to the class B. 7) You should get the exception in the log. Something like this would let me reproduce this issue more clearly. Hope you can provide such steps for further investigations. Targetting M4 if I get steps to reproduce this issue.
(In reply to comment #11) > Targetting M4 if I get steps to reproduce this issue. or 3.6.2 is the problem can be reproduced in 3.6.x since you are getting it inside 3.5.x which doesn't have any further updates.
Reproduced. Investigating.
Steps to reproduce: 1) Create a class A with the following contents: package p; public class A { void foo(B b) { int j = i; System.out.println(j); } } 2) Create a class B with the following contents: package p; public class B { } 3) Invoke move refactoring on the method foo 4) The exception will be thrown. There is a missing null check as the binding for 'i' is null. If you replace foo with: void foo(B b) { int j = this.i; System.out.println(j); } then you would get the exception I got in bug 328786.
Created attachment 182058 [details] Proposed fix Regression test needs to be added.
Moving to JDT/UI
Created attachment 184064 [details] fix and test Fixes a few more similar cases where missing bindings caused trouble.
Fixed in HEAD.