This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Classes with parametrized constructor cannot be renamed -- the Refactoring preview produces following exception, and offers only to rename the file (which subsequentially happens, resulting in uncompilable code): QueryException: java.lang.NullPointerException at org.netbeans.jackpot.query.Query.error(Query.java:146) at org.netbeans.modules.java.save.Commit.visitCompilationUnit(Commit.java:192) at org.netbeans.modules.java.save.Commit.visitCompilationUnit(Commit.java:62) at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:478) at org.netbeans.jackpot.tree.NodeScanner.scan(NodeScanner.java:50) at org.netbeans.jackpot.query.Query.scan(Query.java:93) ... (whole stack trace attached) Steps to reproduce: ------------------- 1) Create a new j2se project 2) Add following ctor to Main.java: public Main(File f) { } 3) Invoke Refactor|Rename =>QueryException --- NetBeans IDE Dev (Build 061005) 1.6.0-rc; Java HotSpot(TM) Client VM 1.6.0-rc-b99 SunOS version 5.10 running on sparc en (nb); ISO646-US
Created attachment 34928 [details] Exception stack trace
Pavel, please take a look on this.
Described problem is more general and will be visible in different parts. If you want to test rename, you can workaround it by inserting something between two constructor - e.g. field. There are two problems: i) matching mechanism has to be improved - it should use some weights of elements to compare them and then decide, if it is modify operation or remove/insert operation. Current solution is too simple and in some cases it recognize it as delete and insert operation. Especially, when two following elements in list are modified, it fail totally. That is the reason why this test fails. I will fill separate issue for this, as it is more general. ii) when renaming class, in TreeMaker.setLabel() for class I also renamed constructor. This seems to not be enough as VerryPretty relies on <init> name and this causes the described NPE.
Checking in src/org/netbeans/modules/java/save/ListMatcher.java; /cvs/java/source/src/org/netbeans/modules/java/save/Attic/ListMatcher.java,v <-- ListMatcher.java new revision: 1.1.2.2; previous revision: 1.1.2.1 done Checking in src/org/netbeans/modules/java/save/TreeDiff.java; /cvs/java/source/src/org/netbeans/modules/java/save/Attic/TreeDiff.java,v <-- TreeDiff.java new revision: 1.1.2.6; previous revision: 1.1.2.5 done Checking in test/unit/src/org/netbeans/api/java/source/gen/ConstructorRenameTest.java; /cvs/java/source/test/unit/src/org/netbeans/api/java/source/gen/Attic/ConstructorRenameTest.java,v <-- ConstructorRenameTest.java new revision: 1.1.2.2; previous revision: 1.1.2.1 done
Verified. -- NetBeans IDE Dev (Build 061019) 1.6.0-rc; Java HotSpot(TM) Server VM 1.6.0-rc-b99 Linux version 2.6.12-1.1390_FC4smp running on i386 en_US (nb); UTF-8