test/tools/javac/InnerNamedConstant_2.java

Tue, 03 Jun 2008 13:26:47 -0700

author
jjg
date
Tue, 03 Jun 2008 13:26:47 -0700
changeset 46
7708bd6d800d
parent 1
9a66ca7c79fa
child 69
82c7aa6fe50a
permissions
-rw-r--r--

4075303: Use javap to enquire aboput a specific inner class
4348375: Javap is not internationalized
4459541: "javap -l" shows line numbers as signed short; they should be unsigned
4501660: change diagnostic of -help as 'print this help message and exit'
4776241: unused source file in javap...
4870651: javap should recognize generics, varargs, enum
4876942: javap invoked without args does not print help screen
4880663: javap could output whitespace between class name and opening brace
4975569: javap doesn't print new flag bits
6271787: javap dumps LocalVariableTypeTable attribute in hex, needs to print a table
6305779: javap: support annotations
6439940: Clean up javap implementation
6469569: wrong check of searchpath in JavapEnvironment
6474890: javap does not open .zip files in -classpath
6587786: Javap throws error : "ERROR:Could not find <classname>" for JRE classes
6622215: javap ignores certain relevant access flags
6622216: javap names some attributes incorrectly
6622232: javap gets whitespace confused
6622260: javap prints negative bytes incorrectly in hex
Reviewed-by: ksrini

     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  *
     7  * @run shell InnerNamedConstant_2.sh
     8  */
    10 public class InnerNamedConstant_2 {
    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     }
    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     }
    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.
    33     class Inner3 {
    34         static final int y = Inner1.x * 5; // ERROR - initializer not constant
    35     }
    37 }

mercurial