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 61510 - NoSuchElementException when extracting interface
Summary: NoSuchElementException when extracting interface
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 5.x
Hardware: PC All
: P2 blocker (vote)
Assignee: Martin Matula
URL:
Keywords:
: 62030 62049 63493 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-28 13:27 UTC by Jiri Prox
Modified: 2007-04-03 18:02 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Exception (1.00 KB, text/plain)
2005-07-28 13:28 UTC, Jiri Prox
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Prox 2005-07-28 13:27:32 UTC
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)
Comment 1 Jiri Prox 2005-07-28 13:28:36 UTC
Created attachment 23344 [details]
Exception
Comment 2 Jiri Prox 2005-07-28 14:09:38 UTC
I forgot to specify the module: Experimental refactoring, ver: 0.20.0.2.3
Comment 3 Tomas Hurka 2005-08-17 10:05:41 UTC
Martin will look at it.
Comment 4 Tomas Hurka 2005-08-19 15:19:46 UTC
*** Issue 62030 has been marked as a duplicate of this issue. ***
Comment 5 Tomas Hurka 2005-08-19 15:39:44 UTC
*** Issue 62049 has been marked as a duplicate of this issue. ***
Comment 6 Martin Matula 2005-08-22 12:09:04 UTC
Is anyone able to reproduce this in the current build? I am not.
Comment 7 Jiri Prox 2005-08-23 10:58:53 UTC
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.
Comment 8 Martin Matula 2005-08-25 08:16:52 UTC
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)
Comment 9 Jiri Prox 2005-08-25 11:08:53 UTC
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.
Comment 10 Martin Matula 2005-08-25 13:54:01 UTC
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.
Comment 11 Martin Matula 2005-09-01 14:28:41 UTC
*** Issue 63493 has been marked as a duplicate of this issue. ***
Comment 12 Martin Matula 2005-09-06 18:29:08 UTC
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
Comment 13 Jiri Prox 2005-10-26 17:18:41 UTC
verified