JDK-6569091 : javac 6 incompatibility or javac 5 bug
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: linux
  • CPU: x86
  • Submitted: 2007-06-13
  • Updated: 2011-03-02
  • Resolved: 2011-03-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
6.x

A DESCRIPTION OF THE PROBLEM :
source compile with javac 5.x but doesn't on javac 6.x

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the attached code in 5.x and 6.x

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
expected that code will compile
ACTUAL -
does not compile

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Information:Compilation completed with 2 errors and 0 warnings
Information:2 errors
Information:0 warnings
/home/yohan/workspace/project/sotbicom/src/java/Javac6Und5Difference.java
    Error:Error:line (6)non-static variable this cannot be referenced from a static context
    Error:Error:line (6)non-static variable this cannot be referenced from a static context

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class Javac6Und5Difference {}

enum ENUM {
    ENUM_CONST {
        public AbstractClass method() {
            return new AbstractClass() {
                public boolean method() {
                    return true;
                }
            };
        }
    };

    public abstract AbstractClass method();

    //try remove private modifier and see what happens :)
    private abstract class AbstractClass {
        public abstract boolean method();
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
place "static" modifier :
private static abstract class

Release Regression From : 5.0u11
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION Not reproducible after fix of 6541876.
02-03-2011

EVALUATION The issue described here is the same as the one described in CR 6541876. An erroneous membership check forces javac to resolve AbstractClass through the enclosing instance - in this case no enclosing instance is given since ENUM_CONST is a static class. Removing private from the declaration of AbstractClass helps, since javac realizes that AbstractClass is indeed accessible from within the ENUM_CONST class, so that no enclosing instance access code is to be generated. Unfortunately, as happens for 6541876, fixing this bug would invalidate the fix for 4903103 (but, again, as described in 6541876's eval, that fix is wrong and lead to bad bytecode to be generated). As a result (as happened with 6541876), this bug cannot be fixed until CR 6708938 get addressed.
28-07-2008