duke@1: /* duke@1: * @test /nodynamiccopyright/ duke@1: * @bug 4095568 4277286 4785453 duke@1: * @summary Verify rejection of illegal static variables in inner classes. duke@1: * @author William Maddox (maddox) duke@1: * jjg@611: * @compile/fail/ref=InnerNamedConstant_2.out -XDrawDiagnostics InnerNamedConstant_2.java duke@1: */ duke@1: duke@1: public class InnerNamedConstant_2 { duke@1: duke@1: static class Inner1 { duke@1: static int x = 1; // OK - class is top-level duke@1: static final int y = x * 5; // OK - class is top-level duke@1: static final String z; // OK - class is top-level duke@1: static { duke@1: z = "foobar"; duke@1: } duke@1: } duke@1: duke@1: class Inner2 { duke@1: static int x = 1; // ERROR - static not final duke@1: static final String z; // ERROR - static blank final duke@1: { duke@1: z = "foobar"; // Error may be reported here. See 4278961. duke@1: } duke@1: } duke@1: duke@1: // This case must go in a separate class, as otherwise the detection duke@1: // of the error is suppressed as a result of recovery from the other duke@1: // errors. duke@1: duke@1: class Inner3 { duke@1: static final int y = Inner1.x * 5; // ERROR - initializer not constant duke@1: } duke@1: duke@1: }