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.

Bug 86585 - Classes with parametrized contructor cannot be renamed
Summary: Classes with parametrized contructor cannot be renamed
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: Sun All
: P2 blocker (vote)
Assignee: Pavel Flaska
URL:
Keywords:
Depends on:
Blocks: 87136
  Show dependency tree
 
Reported: 2006-10-05 14:45 UTC by Max Sauer
Modified: 2007-01-17 10:09 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Exception stack trace (2.34 KB, text/plain)
2006-10-05 14:46 UTC, Max Sauer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Max Sauer 2006-10-05 14:45:25 UTC
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
Comment 1 Max Sauer 2006-10-05 14:46:56 UTC
Created attachment 34928 [details]
Exception stack trace
Comment 2 Jan Lahoda 2006-10-05 15:02:09 UTC
Pavel, please take a look on this.
Comment 3 Pavel Flaska 2006-10-06 10:43:26 UTC
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.

Comment 4 Pavel Flaska 2006-10-10 13:31:08 UTC
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
Comment 5 Max Sauer 2006-10-19 15:30:23 UTC
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