Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312606 - [pull up] Null pointer exception in org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor
Summary: [pull up] Null pointer exception in org.eclipse.jdt.internal.corext.refactori...
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5.1   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-12 09:03 EDT by lehmia CLA
Modified: 2020-03-18 16:28 EDT (History)
2 users (show)

See Also:


Attachments
In this file..code of all files that are needed are given also error trace is written (16.13 KB, application/octet-stream)
2010-05-12 09:58 EDT, lehmia CLA
no flags Details
zip file containing java files and error trace (4.03 KB, application/zip)
2010-05-12 10:20 EDT, lehmia CLA
no flags Details
log file of error (31.02 KB, application/octet-stream)
2010-05-12 10:36 EDT, lehmia CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description lehmia CLA 2010-05-12 09:03:27 EDT
Build Identifier: 20090920-1017

When i call CheckFinalConditions of class pullUpRefactoring processor,the method rewriteTypeOccurrences is called internally.In rewriteTypeOccurrences a variable "declaring" is created, this variable declaring loses its value when it is called in anonymousClass method public final void acceptAST(final ICompilationUnit unit, final CompilationUnit node) and it throws NullPointerException.

Reproducible: Always

Steps to Reproduce:
1.Make a plugin development project 
2.Add the class PullUpMethod.java
3.Add the CallPullUpMethod.java
Now as input callUpMethod takes java files as input so 
4.create a package named pull
5.Add subClass.java
6.Add superClass.java
Comment 1 Olivier Thomann CLA 2010-05-12 09:45:54 EDT
Move to JDT/UI
Comment 2 lehmia CLA 2010-05-12 09:58:52 EDT
Created attachment 168141 [details]
In this file..code of all files that are needed are given also error trace is written
Comment 3 Olivier Thomann CLA 2010-05-12 10:05:58 EDT
Could you please provide them in a zip file as plain text files?
Not everyone as Microsoft Word to open the file you attached.
Thanks.
Comment 4 lehmia CLA 2010-05-12 10:20:38 EDT
Created attachment 168147 [details]
zip file containing java files and error trace
Comment 5 Dani Megert CLA 2010-05-12 10:27:29 EDT
Please also attach the .log file.
Comment 6 Dani Megert CLA 2010-05-12 10:28:30 EDT
Our comments just crossed. Saw the log. Thx.
Comment 7 lehmia CLA 2010-05-12 10:36:41 EDT
Created attachment 168152 [details]
log file of error
Comment 8 Dani Megert CLA 2010-05-12 12:46:23 EDT
The attached example is not self-containing but looking at the code I see you're using internal classes and methods which is not supported.

Moving to Markus to check whether it is OK here not to check 'subType' for 'null':
final IType subType= (IType) JavaModelUtil.findInCompilationUnit(unit, declaring);
in org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor.rewriteTypeOccurrences(...).new ASTRequestor() {...}.acceptAST(ICompilationUnit, CompilationUnit)
Comment 9 lehmia CLA 2010-05-12 13:28:44 EDT
(In reply to comment #8)
> The attached example is not self-containing but looking at the code I see
> you're using internal classes and methods which is not supported.
> 
> Moving to Markus to check whether it is OK here not to check 'subType' for
> 'null':
> final IType subType= (IType) JavaModelUtil.findInCompilationUnit(unit,
> declaring);
> in
> org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor.rewriteTypeOccurrences(...).new
> ASTRequestor() {...}.acceptAST(ICompilationUnit, CompilationUnit)

yes, actually i have to use these internal files by hook or by crook, because 
PullUpDescriptor does not allow to configure the destination type and moved members. It does not provide any setters. The only way I found to accomplish that was to import some of JDT's internal packages and to instantiate the internal PullUpRefactoringProcessor class :( can u suggest me any better way to do pull up method refactoring without using internal classes.

And i have debug the code many times, and the problem is that value in declaring variable is null.As u can see in java file of pullUpMethodprocessor and in method rewriteTypeOccurrences, firstly the value of declaring is being set properly, but when:
"public final void acceptAST(final ICompilationUnit unit, final CompilationUnit node)" is being processed decalring lost its value and start giving null. I am unable to track down why is this happening?? I think there is some problem in plugin code, and the i can suggest is to use getDeclaringType() instead of declaring in 
final IType subType= (IType) JavaModelUtil.findInCompilationUnit(unit,declaring);

 And one more thing should i attach my whole project to show how this error occurs..actually i donot to upload my whole project, and the only thing that is missing here is to first make a eclipse plugin project and then add java source files.Kindly let me know,if it works or not.If neccessary then i will upload my whole project.
Comment 10 Eclipse Genie CLA 2020-03-18 16:28:29 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.