test/tools/javac/ClassFileModifiers/ClassModifiers.java

Tue, 28 Dec 2010 15:54:52 -0800

author
ohair
date
Tue, 28 Dec 2010 15:54:52 -0800
changeset 798
4868a36f6fd8
parent 611
4172cfff05f0
child 2525
2eb010b6cb22
permissions
-rw-r--r--

6962318: Update copyright year
Reviewed-by: xdono

     1 /*
     2  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test
    26  * @bug 4109894 4239646 4785453
    27  * @summary Verify that class modifiers bits written into class
    28  * file are correct, including those within InnerClasses attributes.
    29  * @author John Rose (jrose). Entered as a regression test by Bill Maddox (maddox).
    30  *
    31  * @compile/ref=ClassModifiers.out  -XDdumpmodifiers=ci ClassModifiers.java
    32  *
    33  */
    35 class T {
    36  //all "protected" type members are transformed to "public"
    37  //all "private" type members are transformed to package-scope
    38  //all "static" type members are transformed to non-static
    40  //a class is one of {,public,private,protected}x{,static}x{,abstract,final}
    41  //all of these 24 combinations are legal
    42  //all of these 24 combinations generate distinct InnerClasses modifiers
    43  //transformed class modifiers can be {,public}x{,abstract,final}
    44  //thus, each of the next 6 groups of 4 have identical transformed modifiers
    46  class iC{}
    47  static class iSC{}
    48  private class iVC{}
    49  static private class iSVC{}
    51  final class iFC{}
    52  static final class iSFC{}
    53  final private class iFVC{}
    54  static final private class iSFVC{}
    56  abstract class iAC{}
    57  static abstract class iSAC{}
    58  abstract private class iAVC{}
    59  static abstract private class iSAVC{}
    61  protected class iRC{}
    62  static protected class iSRC{}
    63  public class iUC{}
    64  static public class iSUC{}
    66  final protected class iFRC{}
    67  static final protected class iSFRC{}
    68  final public class iFUC{}
    69  static final public class iSFUC{}
    71  abstract protected class iARC{}
    72  static abstract protected class iSARC{}
    73  abstract public class iAUC{}
    74  static abstract public class iSAUC{}
    76  //all interface members are automatically "static" whether marked so or not
    77  //all interfaces are automatically "abstract" whether marked so or not
    78  //thus, interface modifiers are only distinguished by access permissions
    79  //thus, each of the next 4 groups of 4 classes have identical modifiers
    80  interface iI{}
    81  static interface iSI{}
    82  abstract interface iAI{}
    83  static abstract interface iSAI{}
    85  protected interface iRI{}
    86  static protected interface iSRI{}
    87  abstract protected interface iARI{}
    88  static abstract protected interface iSARI{}
    90  private interface iVI{}
    91  static private interface iSVI{}
    92  abstract private interface iAVI{}
    93  static abstract private interface iSAVI{}
    95  public interface iUI{}
    96  static public interface iSUI{}
    97  abstract public interface iAUI{}
    98  static abstract public interface iSAUI{}
    99 }
   101 interface U {
   102  //no members can be "protected" or "private"
   104  //all type members are automatically "public" whether marked so or not
   105  //all type members are automatically "static" whether marked so or not
   106  //thus, each of the next 3 groups of 4 classes have identical modifiers
   107  class jC{}
   108  static class jSC{}
   109  public class jUC{}
   110  static public class jSUC{}
   112  final class jFC{}
   113  static final class jSFC{}
   114  final public class jFUC{}
   115  static final public class jSFUC{}
   117  abstract class jAC{}
   118  static abstract class jSAC{}
   119  abstract public class jAUC{}
   120  static abstract public class jSAUC{}
   122  //all interface members are automatically "static" whether marked so or not
   123  //all interfaces are automatically "abstract" whether marked so or not
   124  //thus, all 8 of the following classes have identical modifiers:
   125  interface jI{}
   126  static interface jSI{}
   127  abstract interface jAI{}
   128  static abstract interface jSAI{}
   129  public interface jUI{}
   130  static public interface jSUI{}
   131  abstract public interface jAUI{}
   132  static abstract public interface jSAUI{}
   133 }

mercurial