Mercurial > hg > graal-jvmci-8
comparison jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ModifiersProvider.java @ 22672:1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 08 Oct 2015 17:28:41 -0700 |
parents | jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/ModifiersProvider.java@ec96f33a101d |
children | d6bd0b9cd0b6 |
comparison
equal
deleted
inserted
replaced
22671:97f30e4d0e95 | 22672:1bbd4a7c274b |
---|---|
1 /* | |
2 * Copyright (c) 2014, 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 */ | |
23 package jdk.vm.ci.meta; | |
24 | |
25 import static java.lang.reflect.Modifier.ABSTRACT; | |
26 import static java.lang.reflect.Modifier.FINAL; | |
27 import static java.lang.reflect.Modifier.INTERFACE; | |
28 import static java.lang.reflect.Modifier.NATIVE; | |
29 import static java.lang.reflect.Modifier.PRIVATE; | |
30 import static java.lang.reflect.Modifier.PROTECTED; | |
31 import static java.lang.reflect.Modifier.PUBLIC; | |
32 import static java.lang.reflect.Modifier.STATIC; | |
33 import static java.lang.reflect.Modifier.STRICT; | |
34 import static java.lang.reflect.Modifier.SYNCHRONIZED; | |
35 import static java.lang.reflect.Modifier.TRANSIENT; | |
36 import static java.lang.reflect.Modifier.VOLATILE; | |
37 | |
38 import java.lang.reflect.Modifier; | |
39 | |
40 /** | |
41 * A Java element (i.e., a class, interface, field or method) that is described by a set of Java | |
42 * language {@linkplain #getModifiers() modifiers}. | |
43 */ | |
44 public interface ModifiersProvider { | |
45 int BRIDGE = MetaUtil.getNonPublicModifierStaticField("BRIDGE"); | |
46 int VARARGS = MetaUtil.getNonPublicModifierStaticField("VARARGS"); | |
47 int SYNTHETIC = MetaUtil.getNonPublicModifierStaticField("SYNTHETIC"); | |
48 int ANNOTATION = MetaUtil.getNonPublicModifierStaticField("ANNOTATION"); | |
49 int ENUM = MetaUtil.getNonPublicModifierStaticField("ENUM"); | |
50 int MANDATED = MetaUtil.getNonPublicModifierStaticField("MANDATED"); | |
51 | |
52 /** | |
53 * Returns the Java Virtual Machine modifiers for this element. Note that this can differ from | |
54 * standard Java Reflection modifiers. For example at the JVM level, classes ( | |
55 * {@link ResolvedJavaType}) can not be private or protected. | |
56 */ | |
57 int getModifiers(); | |
58 | |
59 /** | |
60 * @see Modifier#isInterface(int) | |
61 */ | |
62 default boolean isInterface() { | |
63 return Modifier.isInterface(getModifiers()); | |
64 } | |
65 | |
66 /** | |
67 * @see Modifier#isSynchronized(int) | |
68 */ | |
69 default boolean isSynchronized() { | |
70 return Modifier.isSynchronized(getModifiers()); | |
71 } | |
72 | |
73 /** | |
74 * @see Modifier#isStatic(int) | |
75 */ | |
76 default boolean isStatic() { | |
77 return Modifier.isStatic(getModifiers()); | |
78 } | |
79 | |
80 /** | |
81 * The setting of the final modifier bit for types is somewhat confusing, so don't export | |
82 * isFinal by default. Subclasses like {@link ResolvedJavaField} and {@link ResolvedJavaMethod} | |
83 * can export it as isFinal, but {@link ResolvedJavaType} can provide a more sensible equivalent | |
84 * like {@link ResolvedJavaType#isLeaf}. | |
85 * | |
86 * @see Modifier#isFinal(int) | |
87 */ | |
88 default boolean isFinalFlagSet() { | |
89 return Modifier.isFinal(getModifiers()); | |
90 } | |
91 | |
92 /** | |
93 * @see Modifier#isPublic(int) | |
94 */ | |
95 default boolean isPublic() { | |
96 return Modifier.isPublic(getModifiers()); | |
97 } | |
98 | |
99 /** | |
100 * Determines if this element is neither {@linkplain #isPublic() public}, | |
101 * {@linkplain #isProtected() protected} nor {@linkplain #isPrivate() private}. | |
102 */ | |
103 default boolean isPackagePrivate() { | |
104 return ((PUBLIC | PROTECTED | PRIVATE) & getModifiers()) == 0; | |
105 } | |
106 | |
107 /** | |
108 * @see Modifier#isPrivate(int) | |
109 */ | |
110 default boolean isPrivate() { | |
111 return Modifier.isPrivate(getModifiers()); | |
112 } | |
113 | |
114 /** | |
115 * @see Modifier#isProtected(int) | |
116 */ | |
117 default boolean isProtected() { | |
118 return Modifier.isProtected(getModifiers()); | |
119 } | |
120 | |
121 /** | |
122 * @see Modifier#isTransient(int) | |
123 */ | |
124 default boolean isTransient() { | |
125 return Modifier.isTransient(getModifiers()); | |
126 } | |
127 | |
128 /** | |
129 * @see Modifier#isStrict(int) | |
130 */ | |
131 default boolean isStrict() { | |
132 return Modifier.isStrict(getModifiers()); | |
133 } | |
134 | |
135 /** | |
136 * @see Modifier#isVolatile(int) | |
137 */ | |
138 default boolean isVolatile() { | |
139 return Modifier.isVolatile(getModifiers()); | |
140 } | |
141 | |
142 /** | |
143 * @see Modifier#isNative(int) | |
144 */ | |
145 default boolean isNative() { | |
146 return Modifier.isNative(getModifiers()); | |
147 } | |
148 | |
149 /** | |
150 * @see Modifier#isAbstract(int) | |
151 */ | |
152 default boolean isAbstract() { | |
153 return Modifier.isAbstract(getModifiers()); | |
154 } | |
155 | |
156 /** | |
157 * Checks that the method is concrete and not abstract. | |
158 * | |
159 * @return whether the method is a concrete method | |
160 */ | |
161 default boolean isConcrete() { | |
162 return !isAbstract(); | |
163 } | |
164 | |
165 static int jvmClassModifiers() { | |
166 // no SUPER | |
167 return PUBLIC | FINAL | INTERFACE | ABSTRACT | ANNOTATION | ENUM | SYNTHETIC; | |
168 } | |
169 | |
170 static int jvmMethodModifiers() { | |
171 return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | SYNCHRONIZED | BRIDGE | VARARGS | NATIVE | ABSTRACT | STRICT | SYNTHETIC; | |
172 } | |
173 | |
174 static int jvmFieldModifiers() { | |
175 return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | VOLATILE | TRANSIENT | ENUM | SYNTHETIC; | |
176 } | |
177 } |