< prev index next >

test/hotspot/jtreg/compiler/intrinsics/klass/TestGetModifiers.java

Print this page

 67 
 68     protected static class T4 {
 69     }
 70 
 71     class T5 {
 72     }
 73 
 74     interface T6 {
 75     }
 76 
 77     static void test(Class cl, int expectedMods) {
 78         for (int i = 0; i < 100_000; i++) {
 79             int actualMods = cl.getModifiers();
 80             if (actualMods != expectedMods) {
 81                 throw new IllegalStateException("Error with: " + cl);
 82             }
 83         }
 84     }
 85 
 86     public static void main(String... args) {
 87         test(T1.class,                                      PUBLIC | STATIC);
 88         test(T2.class,                                      PUBLIC | FINAL | STATIC);
 89         test(T3.class,                                      PRIVATE | STATIC);
 90         test(T4.class,                                      PROTECTED | STATIC);
 91         test(new TestGetModifiers().new T5().getClass(),    0);
 92         test(T6.class,                                      ABSTRACT | STATIC | INTERFACE);
 93 
 94         test(int.class,                                     PUBLIC | ABSTRACT | FINAL);
 95         test(long.class,                                    PUBLIC | ABSTRACT | FINAL);
 96         test(double.class,                                  PUBLIC | ABSTRACT | FINAL);
 97         test(float.class,                                   PUBLIC | ABSTRACT | FINAL);
 98         test(char.class,                                    PUBLIC | ABSTRACT | FINAL);
 99         test(byte.class,                                    PUBLIC | ABSTRACT | FINAL);
100         test(short.class,                                   PUBLIC | ABSTRACT | FINAL);
101         test(void.class,                                    PUBLIC | ABSTRACT | FINAL);
102         test(int[].class,                                   PUBLIC | ABSTRACT | FINAL);
103         test(long[].class,                                  PUBLIC | ABSTRACT | FINAL);
104         test(double[].class,                                PUBLIC | ABSTRACT | FINAL);
105         test(float[].class,                                 PUBLIC | ABSTRACT | FINAL);
106         test(char[].class,                                  PUBLIC | ABSTRACT | FINAL);
107         test(byte[].class,                                  PUBLIC | ABSTRACT | FINAL);
108         test(short[].class,                                 PUBLIC | ABSTRACT | FINAL);
109         test(Object[].class,                                PUBLIC | ABSTRACT | FINAL);
110         test(TestGetModifiers[].class,                      PUBLIC | ABSTRACT | FINAL);
111 
112         test(new TestGetModifiers().getClass(),             PUBLIC);
113         test(new T1().getClass(),                           PUBLIC | STATIC);
114         test(new T2().getClass(),                           PUBLIC | FINAL | STATIC);
115         test(new T3().getClass(),                           PRIVATE | STATIC);
116         test(new T4().getClass(),                           PROTECTED | STATIC);
117     }
118 }

 67 
 68     protected static class T4 {
 69     }
 70 
 71     class T5 {
 72     }
 73 
 74     interface T6 {
 75     }
 76 
 77     static void test(Class cl, int expectedMods) {
 78         for (int i = 0; i < 100_000; i++) {
 79             int actualMods = cl.getModifiers();
 80             if (actualMods != expectedMods) {
 81                 throw new IllegalStateException("Error with: " + cl);
 82             }
 83         }
 84     }
 85 
 86     public static void main(String... args) {
 87         test(T1.class,                                      PUBLIC | STATIC | IDENTITY);
 88         test(T2.class,                                      PUBLIC | FINAL | STATIC | IDENTITY);
 89         test(T3.class,                                      PRIVATE | STATIC | IDENTITY);
 90         test(T4.class,                                      PROTECTED | STATIC | IDENTITY);
 91         test(new TestGetModifiers().new T5().getClass(),    IDENTITY);
 92         test(T6.class,                                      ABSTRACT | STATIC | INTERFACE);
 93 
 94         test(int.class,                                     PUBLIC | ABSTRACT | FINAL);
 95         test(long.class,                                    PUBLIC | ABSTRACT | FINAL);
 96         test(double.class,                                  PUBLIC | ABSTRACT | FINAL);
 97         test(float.class,                                   PUBLIC | ABSTRACT | FINAL);
 98         test(char.class,                                    PUBLIC | ABSTRACT | FINAL);
 99         test(byte.class,                                    PUBLIC | ABSTRACT | FINAL);
100         test(short.class,                                   PUBLIC | ABSTRACT | FINAL);
101         test(void.class,                                    PUBLIC | ABSTRACT | FINAL);
102         test(int[].class,                                   PUBLIC | ABSTRACT | FINAL);
103         test(long[].class,                                  PUBLIC | ABSTRACT | FINAL);
104         test(double[].class,                                PUBLIC | ABSTRACT | FINAL);
105         test(float[].class,                                 PUBLIC | ABSTRACT | FINAL);
106         test(char[].class,                                  PUBLIC | ABSTRACT | FINAL);
107         test(byte[].class,                                  PUBLIC | ABSTRACT | FINAL);
108         test(short[].class,                                 PUBLIC | ABSTRACT | FINAL);
109         test(Object[].class,                                PUBLIC | ABSTRACT | FINAL);
110         test(TestGetModifiers[].class,                      PUBLIC | ABSTRACT | FINAL);
111 
112         test(new TestGetModifiers().getClass(),             PUBLIC | IDENTITY);
113         test(new T1().getClass(),                           PUBLIC | STATIC | IDENTITY);
114         test(new T2().getClass(),                           PUBLIC | FINAL | STATIC | IDENTITY);
115         test(new T3().getClass(),                           PRIVATE | STATIC | IDENTITY);
116         test(new T4().getClass(),                           PROTECTED | STATIC | IDENTITY);
117     }
118 }
< prev index next >