jaroslav@1646: /* jaroslav@1646: * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. jaroslav@1646: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@1646: * jaroslav@1646: * This code is free software; you can redistribute it and/or modify it jaroslav@1646: * under the terms of the GNU General Public License version 2 only, as jaroslav@1646: * published by the Free Software Foundation. Oracle designates this jaroslav@1646: * particular file as subject to the "Classpath" exception as provided jaroslav@1646: * by Oracle in the LICENSE file that accompanied this code. jaroslav@1646: * jaroslav@1646: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@1646: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@1646: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@1646: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@1646: * accompanied this code). jaroslav@1646: * jaroslav@1646: * You should have received a copy of the GNU General Public License version jaroslav@1646: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@1646: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@1646: * jaroslav@1646: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@1646: * or visit www.oracle.com if you need additional information or have any jaroslav@1646: * questions. jaroslav@1646: */ jaroslav@1646: jaroslav@1646: package java.lang.invoke; jaroslav@1646: jaroslav@1646: import static java.lang.invoke.MethodHandleNatives.Constants.*; jaroslav@1646: import static java.lang.invoke.MethodHandleStatics.*; jaroslav@1669: import java.lang.invoke.MethodHandles.Lookup; jaroslav@1646: import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; jaroslav@1669: import java.lang.reflect.Constructor; jaroslav@1669: import java.lang.reflect.Field; jaroslav@1669: import java.lang.reflect.Method; jaroslav@1646: jaroslav@1646: /** jaroslav@1646: * The JVM interface for the method handles package is all here. jaroslav@1646: * This is an interface internal and private to an implementation of JSR 292. jaroslav@1646: * This class is not part of the JSR 292 standard. jaroslav@1646: * @author jrose jaroslav@1646: */ jaroslav@1646: class MethodHandleNatives { jaroslav@1646: jaroslav@1646: private MethodHandleNatives() { } // static only jaroslav@1646: jaroslav@1646: /// MemberName support jaroslav@1646: jaroslav@1669: static void init(MemberName self, Object ref) { jaroslav@1669: } jaroslav@1669: jaroslav@1669: static void expand(MemberName self) { jaroslav@1669: } jaroslav@1669: jaroslav@1661: static MemberName resolve(MemberName self, Class caller) throws LinkageError { jaroslav@1661: return self; jaroslav@1661: } jaroslav@1669: static int getMembers(Class defc, String matchName, String matchSig, jaroslav@1669: int matchFlags, Class caller, int skip, MemberName[] results) { jaroslav@1669: int orig = skip; jaroslav@1669: for (Method m : defc.getMethods()) { jaroslav@1669: if (skip == results.length) { jaroslav@1669: break; jaroslav@1669: } jaroslav@1669: MemberName mn = new MemberName(m); jaroslav@1669: results[skip++] = mn; jaroslav@1669: } jaroslav@1669: for (Constructor m : defc.getConstructors()) { jaroslav@1669: if (skip == results.length) { jaroslav@1669: break; jaroslav@1669: } jaroslav@1669: MemberName mn = new MemberName(m); jaroslav@1669: results[skip++] = mn; jaroslav@1669: } jaroslav@1669: for (Field m : defc.getFields()) { jaroslav@1669: if (skip == results.length) { jaroslav@1669: break; jaroslav@1669: } jaroslav@1669: MemberName mn = new MemberName(m); jaroslav@1669: results[skip++] = mn; jaroslav@1669: } jaroslav@1669: return skip - orig; jaroslav@1669: } jaroslav@1646: jaroslav@1646: /// Field layout queries parallel to sun.misc.Unsafe: jaroslav@1646: static native long objectFieldOffset(MemberName self); // e.g., returns vmindex jaroslav@1646: static native long staticFieldOffset(MemberName self); // e.g., returns vmindex jaroslav@1646: static native Object staticFieldBase(MemberName self); // e.g., returns clazz jaroslav@1646: static native Object getMemberVMInfo(MemberName self); // returns {vmindex,vmtarget} jaroslav@1646: jaroslav@1646: /// MethodHandle support jaroslav@1646: jaroslav@1646: /// CallSite support jaroslav@1646: jaroslav@1646: /** Tell the JVM that we need to change the target of a CallSite. */ jaroslav@1646: static native void setCallSiteTargetNormal(CallSite site, MethodHandle target); jaroslav@1646: static native void setCallSiteTargetVolatile(CallSite site, MethodHandle target); jaroslav@1646: jaroslav@1646: static { jaroslav@1646: // The JVM calls MethodHandleNatives.. Cascade the calls as needed: jaroslav@1646: MethodHandleImpl.initStatics(); jaroslav@1646: } jaroslav@1646: jaroslav@1646: // All compile-time constants go here. jaroslav@1646: // There is an opportunity to check them against the JVM's idea of them. jaroslav@1646: static class Constants { jaroslav@1646: Constants() { } // static only jaroslav@1646: // MethodHandleImpl jaroslav@1646: static final int // for getConstant jaroslav@1646: GC_COUNT_GWT = 4, jaroslav@1646: GC_LAMBDA_SUPPORT = 5; jaroslav@1646: jaroslav@1646: // MemberName jaroslav@1646: // The JVM uses values of -2 and above for vtable indexes. jaroslav@1646: // Field values are simple positive offsets. jaroslav@1646: // Ref: src/share/vm/oops/methodOop.hpp jaroslav@1646: // This value is negative enough to avoid such numbers, jaroslav@1646: // but not too negative. jaroslav@1646: static final int jaroslav@1646: MN_IS_METHOD = 0x00010000, // method (not constructor) jaroslav@1646: MN_IS_CONSTRUCTOR = 0x00020000, // constructor jaroslav@1646: MN_IS_FIELD = 0x00040000, // field jaroslav@1646: MN_IS_TYPE = 0x00080000, // nested type jaroslav@1646: MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected jaroslav@1646: MN_REFERENCE_KIND_SHIFT = 24, // refKind jaroslav@1646: MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT, jaroslav@1646: // The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers: jaroslav@1646: MN_SEARCH_SUPERCLASSES = 0x00100000, jaroslav@1646: MN_SEARCH_INTERFACES = 0x00200000; jaroslav@1646: jaroslav@1646: /** jaroslav@1646: * Basic types as encoded in the JVM. These code values are not jaroslav@1646: * intended for use outside this class. They are used as part of jaroslav@1646: * a private interface between the JVM and this class. jaroslav@1646: */ jaroslav@1646: static final int jaroslav@1646: T_BOOLEAN = 4, jaroslav@1646: T_CHAR = 5, jaroslav@1646: T_FLOAT = 6, jaroslav@1646: T_DOUBLE = 7, jaroslav@1646: T_BYTE = 8, jaroslav@1646: T_SHORT = 9, jaroslav@1646: T_INT = 10, jaroslav@1646: T_LONG = 11, jaroslav@1646: T_OBJECT = 12, jaroslav@1646: //T_ARRAY = 13 jaroslav@1646: T_VOID = 14, jaroslav@1646: //T_ADDRESS = 15 jaroslav@1646: T_ILLEGAL = 99; jaroslav@1646: jaroslav@1646: /** jaroslav@1646: * Constant pool entry types. jaroslav@1646: */ jaroslav@1646: static final byte jaroslav@1646: CONSTANT_Utf8 = 1, jaroslav@1646: CONSTANT_Integer = 3, jaroslav@1646: CONSTANT_Float = 4, jaroslav@1646: CONSTANT_Long = 5, jaroslav@1646: CONSTANT_Double = 6, jaroslav@1646: CONSTANT_Class = 7, jaroslav@1646: CONSTANT_String = 8, jaroslav@1646: CONSTANT_Fieldref = 9, jaroslav@1646: CONSTANT_Methodref = 10, jaroslav@1646: CONSTANT_InterfaceMethodref = 11, jaroslav@1646: CONSTANT_NameAndType = 12, jaroslav@1646: CONSTANT_MethodHandle = 15, // JSR 292 jaroslav@1646: CONSTANT_MethodType = 16, // JSR 292 jaroslav@1646: CONSTANT_InvokeDynamic = 18, jaroslav@1646: CONSTANT_LIMIT = 19; // Limit to tags found in classfiles jaroslav@1646: jaroslav@1646: /** jaroslav@1646: * Access modifier flags. jaroslav@1646: */ jaroslav@1646: static final char jaroslav@1646: ACC_PUBLIC = 0x0001, jaroslav@1646: ACC_PRIVATE = 0x0002, jaroslav@1646: ACC_PROTECTED = 0x0004, jaroslav@1646: ACC_STATIC = 0x0008, jaroslav@1646: ACC_FINAL = 0x0010, jaroslav@1646: ACC_SYNCHRONIZED = 0x0020, jaroslav@1646: ACC_VOLATILE = 0x0040, jaroslav@1646: ACC_TRANSIENT = 0x0080, jaroslav@1646: ACC_NATIVE = 0x0100, jaroslav@1646: ACC_INTERFACE = 0x0200, jaroslav@1646: ACC_ABSTRACT = 0x0400, jaroslav@1646: ACC_STRICT = 0x0800, jaroslav@1646: ACC_SYNTHETIC = 0x1000, jaroslav@1646: ACC_ANNOTATION = 0x2000, jaroslav@1646: ACC_ENUM = 0x4000, jaroslav@1646: // aliases: jaroslav@1646: ACC_SUPER = ACC_SYNCHRONIZED, jaroslav@1646: ACC_BRIDGE = ACC_VOLATILE, jaroslav@1646: ACC_VARARGS = ACC_TRANSIENT; jaroslav@1646: jaroslav@1646: /** jaroslav@1646: * Constant pool reference-kind codes, as used by CONSTANT_MethodHandle CP entries. jaroslav@1646: */ jaroslav@1646: static final byte jaroslav@1646: REF_NONE = 0, // null value jaroslav@1646: REF_getField = 1, jaroslav@1646: REF_getStatic = 2, jaroslav@1646: REF_putField = 3, jaroslav@1646: REF_putStatic = 4, jaroslav@1646: REF_invokeVirtual = 5, jaroslav@1646: REF_invokeStatic = 6, jaroslav@1646: REF_invokeSpecial = 7, jaroslav@1646: REF_newInvokeSpecial = 8, jaroslav@1646: REF_invokeInterface = 9, jaroslav@1646: REF_LIMIT = 10; jaroslav@1646: } jaroslav@1646: jaroslav@1646: static boolean refKindIsValid(int refKind) { jaroslav@1646: return (refKind > REF_NONE && refKind < REF_LIMIT); jaroslav@1646: } jaroslav@1646: static boolean refKindIsField(byte refKind) { jaroslav@1646: assert(refKindIsValid(refKind)); jaroslav@1646: return (refKind <= REF_putStatic); jaroslav@1646: } jaroslav@1646: static boolean refKindIsGetter(byte refKind) { jaroslav@1646: assert(refKindIsValid(refKind)); jaroslav@1646: return (refKind <= REF_getStatic); jaroslav@1646: } jaroslav@1646: static boolean refKindIsSetter(byte refKind) { jaroslav@1646: return refKindIsField(refKind) && !refKindIsGetter(refKind); jaroslav@1646: } jaroslav@1646: static boolean refKindIsMethod(byte refKind) { jaroslav@1646: return !refKindIsField(refKind) && (refKind != REF_newInvokeSpecial); jaroslav@1646: } jaroslav@1646: static boolean refKindIsConstructor(byte refKind) { jaroslav@1646: return (refKind == REF_newInvokeSpecial); jaroslav@1646: } jaroslav@1646: static boolean refKindHasReceiver(byte refKind) { jaroslav@1646: assert(refKindIsValid(refKind)); jaroslav@1646: return (refKind & 1) != 0; jaroslav@1646: } jaroslav@1646: static boolean refKindIsStatic(byte refKind) { jaroslav@1646: return !refKindHasReceiver(refKind) && (refKind != REF_newInvokeSpecial); jaroslav@1646: } jaroslav@1646: static boolean refKindDoesDispatch(byte refKind) { jaroslav@1646: assert(refKindIsValid(refKind)); jaroslav@1646: return (refKind == REF_invokeVirtual || jaroslav@1646: refKind == REF_invokeInterface); jaroslav@1646: } jaroslav@1646: static { jaroslav@1646: final int HR_MASK = ((1 << REF_getField) | jaroslav@1646: (1 << REF_putField) | jaroslav@1646: (1 << REF_invokeVirtual) | jaroslav@1646: (1 << REF_invokeSpecial) | jaroslav@1646: (1 << REF_invokeInterface) jaroslav@1646: ); jaroslav@1646: for (byte refKind = REF_NONE+1; refKind < REF_LIMIT; refKind++) { jaroslav@1646: assert(refKindHasReceiver(refKind) == (((1< caller = (Class)callerObj; jaroslav@1646: String name = nameObj.toString().intern(); jaroslav@1646: MethodType type = (MethodType)typeObj; jaroslav@1646: CallSite callSite = CallSite.makeSite(bootstrapMethod, jaroslav@1646: name, jaroslav@1646: type, jaroslav@1646: staticArguments, jaroslav@1646: caller); jaroslav@1646: if (callSite instanceof ConstantCallSite) { jaroslav@1646: appendixResult[0] = callSite.dynamicInvoker(); jaroslav@1646: return Invokers.linkToTargetMethod(type); jaroslav@1646: } else { jaroslav@1646: appendixResult[0] = callSite; jaroslav@1646: return Invokers.linkToCallSiteMethod(type); jaroslav@1646: } jaroslav@1646: } jaroslav@1646: jaroslav@1646: /** jaroslav@1646: * The JVM wants a pointer to a MethodType. Oblige it by finding or creating one. jaroslav@1646: */ jaroslav@1646: static MethodType findMethodHandleType(Class rtype, Class[] ptypes) { jaroslav@1646: return MethodType.makeImpl(rtype, ptypes, true); jaroslav@1646: } jaroslav@1646: jaroslav@1646: /** jaroslav@1646: * The JVM wants to link a call site that requires a dynamic type check. jaroslav@1646: * Name is a type-checking invoker, invokeExact or invoke. jaroslav@1646: * Return a JVM method (MemberName) to handle the invoking. jaroslav@1646: * The method assumes the following arguments on the stack: jaroslav@1646: * 0: the method handle being invoked jaroslav@1646: * 1-N: the arguments to the method handle invocation jaroslav@1646: * N+1: an optional, implicitly added argument (typically the given MethodType) jaroslav@1646: *

jaroslav@1646: * The nominal method at such a call site is an instance of jaroslav@1646: * a signature-polymorphic method (see @PolymorphicSignature). jaroslav@1646: * Such method instances are user-visible entities which are jaroslav@1646: * "split" from the generic placeholder method in {@code MethodHandle}. jaroslav@1646: * (Note that the placeholder method is not identical with any of jaroslav@1646: * its instances. If invoked reflectively, is guaranteed to throw an jaroslav@1646: * {@code UnsupportedOperationException}.) jaroslav@1646: * If the signature-polymorphic method instance is ever reified, jaroslav@1646: * it appears as a "copy" of the original placeholder jaroslav@1646: * (a native final member of {@code MethodHandle}) except jaroslav@1646: * that its type descriptor has shape required by the instance, jaroslav@1646: * and the method instance is not varargs. jaroslav@1646: * The method instance is also marked synthetic, since the jaroslav@1646: * method (by definition) does not appear in Java source code. jaroslav@1646: *

jaroslav@1646: * The JVM is allowed to reify this method as instance metadata. jaroslav@1646: * For example, {@code invokeBasic} is always reified. jaroslav@1646: * But the JVM may instead call {@code linkMethod}. jaroslav@1646: * If the result is an * ordered pair of a {@code (method, appendix)}, jaroslav@1646: * the method gets all the arguments (0..N inclusive) jaroslav@1646: * plus the appendix (N+1), and uses the appendix to complete the call. jaroslav@1646: * In this way, one reusable method (called a "linker method") jaroslav@1646: * can perform the function of any number of polymorphic instance jaroslav@1646: * methods. jaroslav@1646: *

jaroslav@1646: * Linker methods are allowed to be weakly typed, with any or jaroslav@1646: * all references rewritten to {@code Object} and any primitives jaroslav@1646: * (except {@code long}/{@code float}/{@code double}) jaroslav@1646: * rewritten to {@code int}. jaroslav@1646: * A linker method is trusted to return a strongly typed result, jaroslav@1646: * according to the specific method type descriptor of the jaroslav@1646: * signature-polymorphic instance it is emulating. jaroslav@1646: * This can involve (as necessary) a dynamic check using jaroslav@1646: * data extracted from the appendix argument. jaroslav@1646: *

jaroslav@1646: * The JVM does not inspect the appendix, other than to pass jaroslav@1646: * it verbatim to the linker method at every call. jaroslav@1646: * This means that the JDK runtime has wide latitude jaroslav@1646: * for choosing the shape of each linker method and its jaroslav@1646: * corresponding appendix. jaroslav@1646: * Linker methods should be generated from {@code LambdaForm}s jaroslav@1646: * so that they do not become visible on stack traces. jaroslav@1646: *

jaroslav@1646: * The {@code linkMethod} call is free to omit the appendix jaroslav@1646: * (returning null) and instead emulate the required function jaroslav@1646: * completely in the linker method. jaroslav@1646: * As a corner case, if N==255, no appendix is possible. jaroslav@1646: * In this case, the method returned must be custom-generated to jaroslav@1646: * to perform any needed type checking. jaroslav@1646: *

jaroslav@1646: * If the JVM does not reify a method at a call site, but instead jaroslav@1646: * calls {@code linkMethod}, the corresponding call represented jaroslav@1646: * in the bytecodes may mention a valid method which is not jaroslav@1646: * representable with a {@code MemberName}. jaroslav@1646: * Therefore, use cases for {@code linkMethod} tend to correspond to jaroslav@1646: * special cases in reflective code such as {@code findVirtual} jaroslav@1646: * or {@code revealDirect}. jaroslav@1646: */ jaroslav@1646: static MemberName linkMethod(Class callerClass, int refKind, jaroslav@1646: Class defc, String name, Object type, jaroslav@1646: Object[] appendixResult) { jaroslav@1646: if (!TRACE_METHOD_LINKAGE) jaroslav@1646: return linkMethodImpl(callerClass, refKind, defc, name, type, appendixResult); jaroslav@1646: return linkMethodTracing(callerClass, refKind, defc, name, type, appendixResult); jaroslav@1646: } jaroslav@1646: static MemberName linkMethodImpl(Class callerClass, int refKind, jaroslav@1646: Class defc, String name, Object type, jaroslav@1646: Object[] appendixResult) { jaroslav@1646: try { jaroslav@1646: if (defc == MethodHandle.class && refKind == REF_invokeVirtual) { jaroslav@1646: return Invokers.methodHandleInvokeLinkerMethod(name, fixMethodType(callerClass, type), appendixResult); jaroslav@1646: } jaroslav@1646: } catch (Throwable ex) { jaroslav@1646: if (ex instanceof LinkageError) jaroslav@1646: throw (LinkageError) ex; jaroslav@1646: else jaroslav@1646: throw new LinkageError(ex.getMessage(), ex); jaroslav@1646: } jaroslav@1646: throw new LinkageError("no such method "+defc.getName()+"."+name+type); jaroslav@1646: } jaroslav@1646: private static MethodType fixMethodType(Class callerClass, Object type) { jaroslav@1646: if (type instanceof MethodType) jaroslav@1646: return (MethodType) type; jaroslav@1646: else jaroslav@1646: return MethodType.fromMethodDescriptorString((String)type, callerClass.getClassLoader()); jaroslav@1646: } jaroslav@1646: // Tracing logic: jaroslav@1646: static MemberName linkMethodTracing(Class callerClass, int refKind, jaroslav@1646: Class defc, String name, Object type, jaroslav@1646: Object[] appendixResult) { jaroslav@1646: System.out.println("linkMethod "+defc.getName()+"."+ jaroslav@1646: name+type+"/"+Integer.toHexString(refKind)); jaroslav@1646: try { jaroslav@1646: MemberName res = linkMethodImpl(callerClass, refKind, defc, name, type, appendixResult); jaroslav@1646: System.out.println("linkMethod => "+res+" + "+appendixResult[0]); jaroslav@1646: return res; jaroslav@1646: } catch (Throwable ex) { jaroslav@1646: System.out.println("linkMethod => throw "+ex); jaroslav@1646: throw ex; jaroslav@1646: } jaroslav@1646: } jaroslav@1646: jaroslav@1646: jaroslav@1646: /** jaroslav@1646: * The JVM is resolving a CONSTANT_MethodHandle CP entry. And it wants our help. jaroslav@1646: * It will make an up-call to this method. (Do not change the name or signature.) jaroslav@1646: * The type argument is a Class for field requests and a MethodType for non-fields. jaroslav@1646: *

jaroslav@1646: * Recent versions of the JVM may also pass a resolved MemberName for the type. jaroslav@1646: * In that case, the name is ignored and may be null. jaroslav@1646: */ jaroslav@1646: static MethodHandle linkMethodHandleConstant(Class callerClass, int refKind, jaroslav@1646: Class defc, String name, Object type) { jaroslav@1646: try { jaroslav@1646: Lookup lookup = IMPL_LOOKUP.in(callerClass); jaroslav@1646: assert(refKindIsValid(refKind)); jaroslav@1646: return lookup.linkMethodHandleConstant((byte) refKind, defc, name, type); jaroslav@1646: } catch (IllegalAccessException ex) { jaroslav@1646: Throwable cause = ex.getCause(); jaroslav@1646: if (cause instanceof AbstractMethodError) { jaroslav@1646: throw (AbstractMethodError) cause; jaroslav@1646: } else { jaroslav@1646: Error err = new IllegalAccessError(ex.getMessage()); jaroslav@1646: throw initCauseFrom(err, ex); jaroslav@1646: } jaroslav@1646: } catch (NoSuchMethodException ex) { jaroslav@1646: Error err = new NoSuchMethodError(ex.getMessage()); jaroslav@1646: throw initCauseFrom(err, ex); jaroslav@1646: } catch (NoSuchFieldException ex) { jaroslav@1646: Error err = new NoSuchFieldError(ex.getMessage()); jaroslav@1646: throw initCauseFrom(err, ex); jaroslav@1646: } catch (ReflectiveOperationException ex) { jaroslav@1646: Error err = new IncompatibleClassChangeError(); jaroslav@1646: throw initCauseFrom(err, ex); jaroslav@1646: } jaroslav@1646: } jaroslav@1646: jaroslav@1646: /** jaroslav@1646: * Use best possible cause for err.initCause(), substituting the jaroslav@1646: * cause for err itself if the cause has the same (or better) type. jaroslav@1646: */ jaroslav@1646: static private Error initCauseFrom(Error err, Exception ex) { jaroslav@1646: Throwable th = ex.getCause(); jaroslav@1646: if (err.getClass().isInstance(th)) jaroslav@1646: return (Error) th; jaroslav@1646: err.initCause(th == null ? ex : th); jaroslav@1646: return err; jaroslav@1646: } jaroslav@1646: jaroslav@1646: /** jaroslav@1646: * Is this method a caller-sensitive method? jaroslav@1646: * I.e., does it call Reflection.getCallerClass or a similer method jaroslav@1646: * to ask about the identity of its caller? jaroslav@1646: */ jaroslav@1646: static boolean isCallerSensitive(MemberName mem) { jaroslav@1646: if (!mem.isInvocable()) return false; // fields are not caller sensitive jaroslav@1646: jaroslav@1646: return mem.isCallerSensitive() || canBeCalledVirtual(mem); jaroslav@1646: } jaroslav@1646: jaroslav@1646: static boolean canBeCalledVirtual(MemberName mem) { jaroslav@1646: assert(mem.isInvocable()); jaroslav@1646: Class defc = mem.getDeclaringClass(); jaroslav@1646: switch (mem.getName()) { jaroslav@1646: case "checkMemberAccess": jaroslav@1651: return true; //canBeCalledVirtual(mem, java.lang.SecurityManager.class); jaroslav@1646: case "getContextClassLoader": jaroslav@1646: return canBeCalledVirtual(mem, java.lang.Thread.class); jaroslav@1646: } jaroslav@1646: return false; jaroslav@1646: } jaroslav@1646: jaroslav@1646: static boolean canBeCalledVirtual(MemberName symbolicRef, Class definingClass) { jaroslav@1646: Class symbolicRefClass = symbolicRef.getDeclaringClass(); jaroslav@1646: if (symbolicRefClass == definingClass) return true; jaroslav@1646: if (symbolicRef.isStatic() || symbolicRef.isPrivate()) return false; jaroslav@1646: return (definingClass.isAssignableFrom(symbolicRefClass) || // Msym overrides Mdef jaroslav@1646: symbolicRefClass.isInterface()); // Mdef implements Msym jaroslav@1646: } jaroslav@1646: }