648 * to ask about the identity of its caller?
649 */
650 static boolean isCallerSensitive(MemberName mem) {
651 if (!mem.isInvocable()) return false; // fields are not caller sensitive
652
653 return mem.isCallerSensitive() || canBeCalledVirtual(mem);
654 }
655
656 static boolean canBeCalledVirtual(MemberName mem) {
657 assert(mem.isInvocable());
658 return mem.getName().equals("getContextClassLoader") && canBeCalledVirtual(mem, java.lang.Thread.class);
659 }
660
661 static boolean canBeCalledVirtual(MemberName symbolicRef, Class<?> definingClass) {
662 Class<?> symbolicRefClass = symbolicRef.getDeclaringClass();
663 if (symbolicRefClass == definingClass) return true;
664 if (symbolicRef.isStatic() || symbolicRef.isPrivate()) return false;
665 return (definingClass.isAssignableFrom(symbolicRefClass) || // Msym overrides Mdef
666 symbolicRefClass.isInterface()); // Mdef implements Msym
667 }
668
669 //--- AOTCache support
670
671 /**
672 * In normal execution, this is set to true, so that LambdaFormEditor and MethodTypeForm will
673 * use soft references to allow class unloading.
674 *
675 * When dumping the AOTCache, this is set to false so that no cached heap objects will
676 * contain soft references (which are not yet supported by AOTCache - see JDK-8341587). AOTCache
677 * only stores LambdaFormEditors and MethodTypeForms for classes in the boot/platform/app loaders.
678 * Such classes will never be unloaded, so it's OK to use hard references.
679 */
680 static final boolean USE_SOFT_CACHE;
681
682 static {
683 USE_SOFT_CACHE = Boolean.parseBoolean(
684 System.getProperty("java.lang.invoke.MethodHandleNatives.USE_SOFT_CACHE", "true"));
685 }
686 }
|
648 * to ask about the identity of its caller?
649 */
650 static boolean isCallerSensitive(MemberName mem) {
651 if (!mem.isInvocable()) return false; // fields are not caller sensitive
652
653 return mem.isCallerSensitive() || canBeCalledVirtual(mem);
654 }
655
656 static boolean canBeCalledVirtual(MemberName mem) {
657 assert(mem.isInvocable());
658 return mem.getName().equals("getContextClassLoader") && canBeCalledVirtual(mem, java.lang.Thread.class);
659 }
660
661 static boolean canBeCalledVirtual(MemberName symbolicRef, Class<?> definingClass) {
662 Class<?> symbolicRefClass = symbolicRef.getDeclaringClass();
663 if (symbolicRefClass == definingClass) return true;
664 if (symbolicRef.isStatic() || symbolicRef.isPrivate()) return false;
665 return (definingClass.isAssignableFrom(symbolicRefClass) || // Msym overrides Mdef
666 symbolicRefClass.isInterface()); // Mdef implements Msym
667 }
668 }
|