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 146045

Summary: Generating methods in enum constant body doubles the constant declararion
Product: java Reporter: Jiri Prox <jiriprox>
Component: SourceAssignee: Svata Dedic <sdedic>
Status: VERIFIED FIXED    
Severity: blocker CC: gtzabari, swpalmer
Priority: P4    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description Jiri Prox 2008-09-03 14:12:02 UTC
Product Version: NetBeans IDE Dev (Build 20080831185227)
Java: 1.6.0_10-rc; Java HotSpot(TM) Client VM 11.0-b13
System: Linux version 2.6.22-15-generic running on i386; UTF-8; en_US (nb)

Constants declarations are doubled in enum, when using Insert Code dialog to generate code inside constant body.
Yes I know, it's very rare scenario -> P4

Steps to reproduce:
1) have a code:
public enum Role {

    ADMIN_USER {
        
    },
    REGUALAR_USER,
    SUPER_USER;

    public void m() {
    }
}

2) put caret inside body of ADMIN_USER constant
3) use insert code dialog to override method m()
->

public enum Role {

    ADMIN_USER {
        
    },
    REGUALAR_USER,
    SUPER_USER;
ADMIN_USER {

        @Override
        public void m() {
            super.m();
        }
        
    },
    REGUALAR_USER,
    SUPER_USER;

    public void m() {
    }
}
Comment 1 Jiri Prox 2008-10-29 15:20:13 UTC
*** Issue 151617 has been marked as a duplicate of this issue. ***
Comment 2 Jiri Prox 2009-01-20 10:15:21 UTC
*** Issue 157088 has been marked as a duplicate of this issue. ***
Comment 3 Rastislav Komara 2009-02-03 10:54:35 UTC
Overtake.
Comment 4 Jiri Prox 2009-04-22 16:45:24 UTC
*** Issue 163170 has been marked as a duplicate of this issue. ***
Comment 5 Jan Lahoda 2009-08-20 09:59:12 UTC
Reassigning all moonko's java/source bugs to myself.
Comment 6 _ gtzabari 2011-07-25 14:54:03 UTC
Jan,

The Target Milestone of this issue is out of date. Please review.
Comment 7 Jan Lahoda 2011-07-25 15:12:51 UTC
Seems that the usecase above is no longer reproducible in a current daily build. If there is a particular usecase where this still fails, please specify it here and reopen. Thanks.
Comment 8 _ gtzabari 2011-07-25 15:25:35 UTC
Jan,

I am using:

Product Version: NetBeans IDE Dev (Build 201107220600)
Java: 1.7.0; Java HotSpot(TM) Client VM 21.0-b17
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)

Code-complete no longer corrupts the class, but the functionality still doesn't work.

1. Given this class:

public enum Role {

    ADMIN_USER {

    },
    REGUALAR_USER,
    SUPER_USER;

    public void m() {
    }
}

2. Place the caret inside the body of ADMIN_USER constant
3. Use code-complete (CTRL+SPACEBAR) to override m()
4. Bug #1: Nothing happens (no code is generated).
5. Place the caret inside the body of ADMIN_USER constant
6. Use Generate Code (ALT+INSERT) to override m()
7. Bug #2: ArrayIndexOutOfBoundsException is thrown. See http://statistics.netbeans.org/analytics/detail.do?id=180119

Either way, it doesn't seem to be possible to override m().
Comment 9 Martin Balin 2016-07-07 07:18:21 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 10 _ gtzabari 2016-07-07 19:27:34 UTC
Seems to be fixed in dev build 201607060002.