Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 166810 - [67cat] NullPointerException at org.netbeans.api.java.source.ElementUtilities.isSynthetic
[67cat] NullPointerException at org.netbeans.api.java.source.ElementUtilities...
Status: VERIFIED FIXED
Product: java
Classification: Unclassified
Component: Refactoring
6.x
All All
: P3 (vote)
: 6.x
Assigned To: Jan Pokorsky
issues@java
http://statistics.netbeans.org/except...
EXCEPTIONS_REPORT 67patch1-verified
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-09 20:38 UTC by Michel Graciano
Modified: 2009-07-16 11:20 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
stacktrace (2.41 KB, text/plain)
2009-06-09 20:38 UTC, Michel Graciano
Details
stacktrace (2.41 KB, text/plain)
2009-06-09 20:39 UTC, Michel Graciano
Details
stacktrace (2.41 KB, text/plain)
2009-06-09 20:46 UTC, Michel Graciano
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Graciano 2009-06-09 20:38:33 UTC
Build: NetBeans IDE 6.7 RC2 (Build 200906042131)
VM: Java HotSpot(TM) Client VM, 11.0-b16, Java(TM) SE Runtime Environment, 1.6.0_11-b03
OS: Linux, 2.6.27-14-generic, i386

User Comments:
hmichel: Change method parameters refatoring



Stacktrace: 
java.lang.NullPointerException
        at org.netbeans.api.java.source.ElementUtilities.isSynthetic(ElementUtilities.java:174)
        at org.netbeans.modules.refactoring.java.plugins.ChangeParamsTransformer.visitCompilationUnit(ChangeParamsTransformer.java:83)
        at org.netbeans.modules.refactoring.java.plugins.ChangeParamsTransformer.visitCompilationUnit(ChangeParamsTransformer.java:70)
        at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:482)
        at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
        at org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin$TransformTask.run(JavaRefactoringPlugin.java:363)
Comment 1 Michel Graciano 2009-06-09 20:38:38 UTC
Created attachment 83365 [details]
stacktrace
Comment 2 Michel Graciano 2009-06-09 20:39:37 UTC
Build: NetBeans IDE 6.7 RC2 (Build 200906042131)
VM: Java HotSpot(TM) Client VM, 11.0-b16, Java(TM) SE Runtime Environment, 1.6.0_11-b03
OS: Linux, 2.6.27-14-generic, i386

User Comments: 


Stacktrace: 
java.lang.NullPointerException
        at org.netbeans.api.java.source.ElementUtilities.isSynthetic(ElementUtilities.java:174)
        at org.netbeans.modules.refactoring.java.plugins.ChangeParamsTransformer.visitCompilationUnit(ChangeParamsTransformer.java:83)
        at org.netbeans.modules.refactoring.java.plugins.ChangeParamsTransformer.visitCompilationUnit(ChangeParamsTransformer.java:70)
        at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:482)
        at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
        at org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin$TransformTask.run(JavaRefactoringPlugin.java:363)
Comment 3 Michel Graciano 2009-06-09 20:39:40 UTC
Created attachment 83366 [details]
stacktrace
Comment 4 Michel Graciano 2009-06-09 20:46:35 UTC
Build: NetBeans IDE 6.7 RC2 (Build 200906042131)
VM: Java HotSpot(TM) Client VM, 11.0-b16, Java(TM) SE Runtime Environment, 1.6.0_11-b03
OS: Linux, 2.6.27-14-generic, i386

User Comments: 


Stacktrace: 
java.lang.NullPointerException
        at org.netbeans.api.java.source.ElementUtilities.isSynthetic(ElementUtilities.java:174)
        at org.netbeans.modules.refactoring.java.plugins.ChangeParamsTransformer.visitCompilationUnit(ChangeParamsTransformer.java:83)
        at org.netbeans.modules.refactoring.java.plugins.ChangeParamsTransformer.visitCompilationUnit(ChangeParamsTransformer.java:70)
        at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:482)
        at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
        at org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin$TransformTask.run(JavaRefactoringPlugin.java:363)
Comment 5 Michel Graciano 2009-06-09 20:46:38 UTC
Created attachment 83367 [details]
stacktrace
Comment 6 Michel Graciano 2009-06-09 20:48:27 UTC
This should be fixed for FCS.
Comment 7 Michel Graciano 2009-06-09 21:58:27 UTC
Looks like this happens when code involved (methods to be refactored) are not compilable.
Comment 8 Marian Mirilovic 2009-06-10 08:39:32 UTC
*hmichel*, thanks for report ...

I am sorry I can't reproduce it : tried Refactor | Change Parameters on not compilable method ... also other
refactorings called on non-compilable code.

*jiriprox*, please look at this as well.

Also decreasing the priority ... please follow http://wiki.netbeans.org/BugPriorityGuidelines
Comment 9 Dusan Balek 2009-06-10 09:05:25 UTC
ChangeParamsTransformer should not pass null to ElementUtilities.isSynthetic(...). Reassigning.
Comment 10 Michel Graciano 2009-06-10 12:52:04 UTC
I followed the guidelines, since the feature doesn't work for that scenario, the problem is that I need to send to you 
this scenario... no workaround exists when it happens... I needed to change method without refactoring and fix all calls 
manually. I will try to figure out how to reproduce it and send it to you as soon as I can.

Regards
Comment 11 Jan Pokorsky 2009-06-10 15:23:21 UTC
The refactoring passes what it gets. If you take a look at messages.log there is a broken TreePathHandle->Element
translation again. What is really strange that the same TreePathHandle.resolveElement returns non-null value in a user
action task in ChangeParametersPlugin.preCheck but it returns null in the modification task in
ChangeParametersPlugin.prepare that follows the preCheck.

hmichel: a reproducible scenario would be greatly welcome. I guess it could have something to do with method occurrences
in several source roots (dependent projects?).
Comment 12 Michel Graciano 2009-06-10 15:28:49 UTC
Yes, I will try to reproduce it, but I think it is not so easy. I've used an free form project with several source roots. 
As soon as I can reproduce it I will attach it for you. Thanks
Comment 13 Jiri Prox 2009-06-10 15:30:16 UTC
Steps to reproduce:

1) have project A with class
public class Util {
    public String test() {
        return "";
    }
}

2) have project B depending on A with class 
public class Main {   
    class A extends Util {
        @Override
        public String test() {
            return "";
        }
    }
}

3) put caret over test in Main class
4) perform Change Method Parameter refactoring
Comment 14 Jan Pokorsky 2009-06-10 16:15:05 UTC
Thank you for steps. It is as I guessed. The refactoring source has to be the declaration from the topmost super class
not the usage in order to ensure it is accessible from all classpaths of involved projects.
Comment 15 Jan Pokorsky 2009-06-11 10:55:26 UTC
fixed http://hg.netbeans.org/jet-main/rev/2adda8f21fbd
Comment 16 Quality Engineering 2009-06-12 09:16:06 UTC
Integrated into 'main-golden', will be available in build *200906120201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/2adda8f21fbd
User: Jan Pokorsky <jpokorsky@netbeans.org>
Log: #166810: fixing NPE; Element param of visitXXX methods may be null in case of several dependent source roots
Comment 17 Michel Graciano 2009-06-16 14:12:01 UTC
v. 200906160201
Comment 18 Jiri Prox 2009-06-24 15:47:25 UTC
Justification of patch candidate: the exception occurs in very common scenario
Comment 19 pgebauer 2009-07-01 11:09:26 UTC
The fix has been ported into the release67_fixes repository.
http://hg.netbeans.org/release67_fixes/rev/f5edcfa6a542
Comment 20 pribyl 2009-07-16 11:20:30 UTC
Product Version: NetBeans IDE 6.7.1 RC (Build 200907150227)
Java: 1.6.0_14; Java HotSpot(TM) Client VM 14.0-b16
System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb)

Verified in 6.7.1 RC


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo