Community
Participate
Working Groups
Using latest, we optimize out the static receiver for a static field invocation. We should not as this prevents the declaring class of the static field from being initialized and this can have a side-effect on the method invocation. public class X { static int Value = 2; public static void main(String args[]) { foo(); } public static int foo() { return Y.CONST.getValue(); } public static int getValue() { return Value; } } class Y { static { X.Value = 0; System.out.println("Class Y is initialized"); } static X CONST = null; } When executing X, it should display: Class Y is initialized
Created attachment 16099 [details] Apply on HEAD Possible patch. The static field is generated and discarded immediately.
Fixed. Adjusted various regression tests. Added Compliance_1*#test097.
Verified in I20050214