author | peterz |
Fri, 28 May 2010 13:32:40 +0400 | |
changeset 5594 | 3db39773da2e |
parent 863 | 3113c955a388 |
child 6150 | d055fa8ced62 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
2 |
* @test /nodynamiccopyright/ |
|
3 |
* @bug 4095568 4277286 4785453 |
|
4 |
* @summary Verify rejection of illegal static variables in inner classes. |
|
5 |
* @author William Maddox (maddox) |
|
6 |
* |
|
863
3113c955a388
6724327: eliminate use of shell tests for simple golden file tests
jjg
parents:
10
diff
changeset
|
7 |
* @compile/fail/ref=InnerNamedConstant_2.out -XDrawDiagnostics -XDstdout InnerNamedConstant_2.java |
10 | 8 |
*/ |
9 |
||
10 |
public class InnerNamedConstant_2 { |
|
11 |
||
12 |
static class Inner1 { |
|
13 |
static int x = 1; // OK - class is top-level |
|
14 |
static final int y = x * 5; // OK - class is top-level |
|
15 |
static final String z; // OK - class is top-level |
|
16 |
static { |
|
17 |
z = "foobar"; |
|
18 |
} |
|
19 |
} |
|
20 |
||
21 |
class Inner2 { |
|
22 |
static int x = 1; // ERROR - static not final |
|
23 |
static final String z; // ERROR - static blank final |
|
24 |
{ |
|
25 |
z = "foobar"; // Error may be reported here. See 4278961. |
|
26 |
} |
|
27 |
} |
|
28 |
||
29 |
// This case must go in a separate class, as otherwise the detection |
|
30 |
// of the error is suppressed as a result of recovery from the other |
|
31 |
// errors. |
|
32 |
||
33 |
class Inner3 { |
|
34 |
static final int y = Inner1.x * 5; // ERROR - initializer not constant |
|
35 |
} |
|
36 |
||
37 |
} |