1214 }
1215
1216 @DefinedBy(Api.LANGUAGE_MODEL)
1217 public <R, P> R accept(ElementVisitor<R, P> v, P p) {
1218 return v.visitPackage(this, p);
1219 }
1220
1221 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
1222 return v.visitPackageSymbol(this, p);
1223 }
1224
1225 /**Resets the Symbol into the state good for next round of annotation processing.*/
1226 public void reset() {
1227 metadata = null;
1228 }
1229
1230 }
1231
1232 public static class RootPackageSymbol extends PackageSymbol {
1233 public final MissingInfoHandler missingInfoHandler;
1234
1235 public RootPackageSymbol(Name name, Symbol owner, MissingInfoHandler missingInfoHandler) {
1236 super(name, owner);
1237 this.missingInfoHandler = missingInfoHandler;
1238 }
1239
1240 }
1241
1242 /** A class for class symbols
1243 */
1244 public static class ClassSymbol extends TypeSymbol implements TypeElement {
1245
1246 /** a scope for all class members; variables, methods and inner classes
1247 * type parameters are not part of this scope
1248 */
1249 public WriteableScope members_field;
1250
1251 /** the fully qualified name of the class, i.e. pck.outer.inner.
1252 * null for anonymous classes
1253 */
1254 public Name fullname;
1255
1256 /** the fully qualified name of the class after converting to flat
1257 * representation, i.e. pck.outer$inner,
2294 public MethodHandleSymbol(Symbol msym, boolean getter) {
2295 super(msym.flags_field, msym.name, msym.type, msym.owner);
2296 this.refSym = msym;
2297 this.getter = getter;
2298 }
2299
2300 /**
2301 * Returns the kind associated with this method handle.
2302 */
2303 public int referenceKind() {
2304 if (refSym.kind == VAR) {
2305 return getter ?
2306 refSym.isStatic() ? ClassFile.REF_getStatic : ClassFile.REF_getField :
2307 refSym.isStatic() ? ClassFile.REF_putStatic : ClassFile.REF_putField;
2308 } else {
2309 if (refSym.isConstructor()) {
2310 return ClassFile.REF_newInvokeSpecial;
2311 } else {
2312 if (refSym.isStatic()) {
2313 return ClassFile.REF_invokeStatic;
2314 } else if (refSym.enclClass().isInterface()) {
2315 return ClassFile.REF_invokeInterface;
2316 } else {
2317 return ClassFile.REF_invokeVirtual;
2318 }
2319 }
2320 }
2321 }
2322
2323 @Override
2324 public int poolTag() {
2325 return ClassFile.CONSTANT_MethodHandle;
2326 }
2327
2328 @Override
2329 public Object poolKey(Types types) {
2330 return new Pair<>(baseSymbol(), referenceKind());
2331 }
2332
2333 @Override
2334 public MethodHandleSymbol asHandle() {
2335 return this;
2336 }
2337
2338 @Override
2339 public Symbol baseSymbol() {
2340 return refSym;
2341 }
2342
|
1214 }
1215
1216 @DefinedBy(Api.LANGUAGE_MODEL)
1217 public <R, P> R accept(ElementVisitor<R, P> v, P p) {
1218 return v.visitPackage(this, p);
1219 }
1220
1221 public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
1222 return v.visitPackageSymbol(this, p);
1223 }
1224
1225 /**Resets the Symbol into the state good for next round of annotation processing.*/
1226 public void reset() {
1227 metadata = null;
1228 }
1229
1230 }
1231
1232 public static class RootPackageSymbol extends PackageSymbol {
1233 public final MissingInfoHandler missingInfoHandler;
1234 public final boolean allowPrivateInvokeVirtual;
1235
1236 public RootPackageSymbol(Name name, Symbol owner,
1237 MissingInfoHandler missingInfoHandler,
1238 boolean allowPrivateInvokeVirtual) {
1239 super(name, owner);
1240 this.missingInfoHandler = missingInfoHandler;
1241 this.allowPrivateInvokeVirtual = allowPrivateInvokeVirtual;
1242 }
1243
1244 }
1245
1246 /** A class for class symbols
1247 */
1248 public static class ClassSymbol extends TypeSymbol implements TypeElement {
1249
1250 /** a scope for all class members; variables, methods and inner classes
1251 * type parameters are not part of this scope
1252 */
1253 public WriteableScope members_field;
1254
1255 /** the fully qualified name of the class, i.e. pck.outer.inner.
1256 * null for anonymous classes
1257 */
1258 public Name fullname;
1259
1260 /** the fully qualified name of the class after converting to flat
1261 * representation, i.e. pck.outer$inner,
2298 public MethodHandleSymbol(Symbol msym, boolean getter) {
2299 super(msym.flags_field, msym.name, msym.type, msym.owner);
2300 this.refSym = msym;
2301 this.getter = getter;
2302 }
2303
2304 /**
2305 * Returns the kind associated with this method handle.
2306 */
2307 public int referenceKind() {
2308 if (refSym.kind == VAR) {
2309 return getter ?
2310 refSym.isStatic() ? ClassFile.REF_getStatic : ClassFile.REF_getField :
2311 refSym.isStatic() ? ClassFile.REF_putStatic : ClassFile.REF_putField;
2312 } else {
2313 if (refSym.isConstructor()) {
2314 return ClassFile.REF_newInvokeSpecial;
2315 } else {
2316 if (refSym.isStatic()) {
2317 return ClassFile.REF_invokeStatic;
2318 } else if ((refSym.flags() & PRIVATE) != 0 && !allowPrivateInvokeVirtual()) {
2319 return ClassFile.REF_invokeSpecial;
2320 } else if (refSym.enclClass().isInterface()) {
2321 return ClassFile.REF_invokeInterface;
2322 } else {
2323 return ClassFile.REF_invokeVirtual;
2324 }
2325 }
2326 }
2327 }
2328
2329 private boolean allowPrivateInvokeVirtual() {
2330 Symbol rootPack = this;
2331 while (rootPack != null && !(rootPack instanceof RootPackageSymbol)) {
2332 rootPack = rootPack.owner;
2333 }
2334 return rootPack != null && ((RootPackageSymbol) rootPack).allowPrivateInvokeVirtual;
2335 }
2336 @Override
2337 public int poolTag() {
2338 return ClassFile.CONSTANT_MethodHandle;
2339 }
2340
2341 @Override
2342 public Object poolKey(Types types) {
2343 return new Pair<>(baseSymbol(), referenceKind());
2344 }
2345
2346 @Override
2347 public MethodHandleSymbol asHandle() {
2348 return this;
2349 }
2350
2351 @Override
2352 public Symbol baseSymbol() {
2353 return refSym;
2354 }
2355
|