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.
NB 4.2 (200507272036) JDK 1.6.0 Exception is sometimes thrown when extracting interface. At first the exception doesn't occur but after several refactorings it appears regulary in the console. If the exception is thrown the undo refactoring stays disabled although the chnages are performed. I firstly noticed this exception when I was extracting interface from a class which was already implementing some interface. java.util.NoSuchElementException at java.util.LinkedList.getFirst(LinkedList.java:109) at org.netbeans.modules.javacore.internalapi.UndoManager.addItem(UndoManager.java:267) at org.netbeans.modules.javacore.internalapi.UndoManager.addItem(UndoManager.java:248)
Created attachment 23344 [details] Exception
I forgot to specify the module: Experimental refactoring, ver: 0.20.0.2.3
Martin will look at it.
*** Issue 62030 has been marked as a duplicate of this issue. ***
*** Issue 62049 has been marked as a duplicate of this issue. ***
Is anyone able to reproduce this in the current build? I am not.
I can reproduce it on current dev build 050823. Here are steps to reproduce: 1) create this class: public class Main implements Runnable { /** Creates a new instance of Main */ public Main() { } class Inner { } public void method() { } public void run() { } } 2) call Extract interface 3) leave the new name as it is and select only 'implements ...' to be extracted 4) confirm refactoring -> the mentioned exception is thrown It is tested with clear userdir. It is probably not RANDOM because I got the exception everytime I try this scenarion. I also reproduced it somehow while Extracting Super Class, but i don't have reproducible test case yet.
Please confirm that you can still reproduce this and provide exact steps (do you have any files open in the editor when this happens? do you click on any of the elements in the refactoring preview before you do the refactoring? do you use refactoring undo before this happens? - etc. any information that could help me to reproduce this - I am not able to reproduce it currently)
I know I am annoying but I can still reproduce it. I'll provide exact steps to reproduce, even some of them are probably not necessary. I used test case form one of the duplicate. 1) Create file XXX with two top level elements public class XXX and another class YYY, both of them contains some methods 2) make YYY implement some interface 3) add new method to XXX (maybe this step is esential, it look like adding method cause some changes, which are not done when the file is opened form the file) 4) wait several second till the changes are refelected in navigator 5) put cursor in the body of YYY 6) call extract interface 7) from the table select the line with 'implementing ...', and fill in some name 8) confirm -> preview is opened 9) do refactoring All this was done with fresh user dir, after starting IDE only exisitng project was opened, and the file, which it is beeing tested with, was opened in the editor. On others file opened, not used Undo before.
Great, thanks. You are not annoying. I am glad you were able to provide a reproducible scenario. I will try it out. In case I will not be able to reproduce it on my machine, I will add some debug messages and let you know the commandline switch to turn them on.
*** Issue 63493 has been marked as a duplicate of this issue. ***
OK. I was not able to reproduce it with your scenario either, but finally found a reliable reproduction scenario: 1. perform extract interface refactoring on the Main class you described - everything goes fine 2. now delete the newly extracted interface and replace implements clause in the Main class with what it was previously - i.e. Runnable 3. perform the extract interface refactoring on the Main class again - voila! - the exception is printed to the console I've fixed it. Checking in src/org/netbeans/modules/javacore/internalapi/UndoManager.java; /cvs/java/javacore/src/org/netbeans/modules/javacore/internalapi/UndoManager.java,v <-- UndoManager.java new revision: 1.14; previous revision: 1.13 done
verified