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