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 204373

Summary: Introduce constant inside anonymous class corrupts source
Product: java Reporter: _ rkubacki <rkubacki>
Component: HintsAssignee: Jan Lahoda <jlahoda>
Status: RESOLVED FIXED    
Severity: normal CC: jglick
Priority: P3    
Version: 7.1   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 204435    
Bug Blocks:    

Description _ rkubacki 2011-10-28 20:29:30 UTC
NB7.1, JDK 1.6

Select an expression inside method body in anonymous class and run 'introduce constant' refactoring. 'public static final Foo FOO = ...' is created in this inner class and this is not allowed by Java specification.
Comment 1 Jesse Glick 2011-10-31 13:49:57 UTC
More generally I remember problems with introduce constant/field trying to add a static member to a nonstatic nested class (anonymous, local, or member); perhaps some of those have been fixed separately.
Comment 2 Jan Lahoda 2012-04-02 08:59:37 UTC
http://hg.netbeans.org/jet-main/rev/73c14c29e972
Comment 3 Quality Engineering 2012-04-03 11:13:08 UTC
Integrated into 'main-golden', will be available in build *201204030400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/73c14c29e972
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #204373: prevent adding static fields into non-static contexts.