547 VarHandleGuards.class, getVarHandleGuardMethodName(guardType),
548 guardType, REF_invokeStatic);
549
550 linker = MemberName.getFactory().resolveOrNull(REF_invokeStatic, linker,
551 VarHandleGuards.class);
552 if (linker != null) {
553 return linker;
554 }
555 // Fall back to lambda form linkage if guard method is not available
556 // TODO Optionally log fallback ?
557 }
558 return Invokers.varHandleInvokeLinkerMethod(ak, mtype);
559 }
560 static String getVarHandleGuardMethodName(MethodType guardType) {
561 String prefix = "guard_";
562 StringBuilder sb = new StringBuilder(prefix.length() + guardType.parameterCount());
563
564 sb.append(prefix);
565 for (int i = 1; i < guardType.parameterCount() - 1; i++) {
566 Class<?> pt = guardType.parameterType(i);
567 sb.append(getCharType(pt));
568 }
569 sb.append('_').append(getCharType(guardType.returnType()));
570 return sb.toString();
571 }
572 static char getCharType(Class<?> pt) {
573 return Wrapper.forBasicType(pt).basicTypeChar();
574 }
575 static NoSuchMethodError newNoSuchMethodErrorOnVarHandle(String name, MethodType mtype) {
576 return new NoSuchMethodError("VarHandle." + name + mtype);
577 }
578
579 /**
580 * The JVM is resolving a CONSTANT_MethodHandle CP entry. And it wants our help.
581 * It will make an up-call to this method. (Do not change the name or signature.)
582 * The type argument is a Class for field requests and a MethodType for non-fields.
583 * <p>
584 * Recent versions of the JVM may also pass a resolved MemberName for the type.
585 * In that case, the name is ignored and may be null.
586 */
587 static MethodHandle linkMethodHandleConstant(Class<?> callerClass, int refKind,
588 Class<?> defc, String name, Object type) {
589 try {
590 Lookup lookup = IMPL_LOOKUP.in(callerClass);
591 assert(refKindIsValid(refKind));
592 return lookup.linkMethodHandleConstant((byte) refKind, defc, name, type);
|
547 VarHandleGuards.class, getVarHandleGuardMethodName(guardType),
548 guardType, REF_invokeStatic);
549
550 linker = MemberName.getFactory().resolveOrNull(REF_invokeStatic, linker,
551 VarHandleGuards.class);
552 if (linker != null) {
553 return linker;
554 }
555 // Fall back to lambda form linkage if guard method is not available
556 // TODO Optionally log fallback ?
557 }
558 return Invokers.varHandleInvokeLinkerMethod(ak, mtype);
559 }
560 static String getVarHandleGuardMethodName(MethodType guardType) {
561 String prefix = "guard_";
562 StringBuilder sb = new StringBuilder(prefix.length() + guardType.parameterCount());
563
564 sb.append(prefix);
565 for (int i = 1; i < guardType.parameterCount() - 1; i++) {
566 Class<?> pt = guardType.parameterType(i);
567 sb.append(getCharErasedType(pt));
568 }
569 sb.append('_').append(getCharErasedType(guardType.returnType()));
570 return sb.toString();
571 }
572 static char getCharErasedType(Class<?> pt) {
573 return Wrapper.forBasicType(pt).basicTypeChar();
574 }
575 static NoSuchMethodError newNoSuchMethodErrorOnVarHandle(String name, MethodType mtype) {
576 return new NoSuchMethodError("VarHandle." + name + mtype);
577 }
578
579 /**
580 * The JVM is resolving a CONSTANT_MethodHandle CP entry. And it wants our help.
581 * It will make an up-call to this method. (Do not change the name or signature.)
582 * The type argument is a Class for field requests and a MethodType for non-fields.
583 * <p>
584 * Recent versions of the JVM may also pass a resolved MemberName for the type.
585 * In that case, the name is ignored and may be null.
586 */
587 static MethodHandle linkMethodHandleConstant(Class<?> callerClass, int refKind,
588 Class<?> defc, String name, Object type) {
589 try {
590 Lookup lookup = IMPL_LOOKUP.in(callerClass);
591 assert(refKindIsValid(refKind));
592 return lookup.linkMethodHandleConstant((byte) refKind, defc, name, type);
|