362 System.out.println("linkMethod => throw "+ex); 363 throw ex; 364 } 365 } 366 367 368 /** 369 * The JVM is resolving a CONSTANT_MethodHandle CP entry. And it wants our help. 370 * It will make an up-call to this method. (Do not change the name or signature.) 371 * The type argument is a Class for field requests and a MethodType for non-fields. 372 * <p> 373 * Recent versions of the JVM may also pass a resolved MemberName for the type. 374 * In that case, the name is ignored and may be null. 375 */ 376 static MethodHandle linkMethodHandleConstant(Class<?> callerClass, int refKind, 377 Class<?> defc, String name, Object type) { 378 try { 379 Lookup lookup = IMPL_LOOKUP.in(callerClass); 380 assert(refKindIsValid(refKind)); 381 return lookup.linkMethodHandleConstant((byte) refKind, defc, name, type); 382 } catch (ReflectiveOperationException ex) { 383 Error err = new IncompatibleClassChangeError(); 384 err.initCause(ex); 385 throw err; 386 } 387 } 388 389 /** 390 * Is this method a caller-sensitive method? 391 * I.e., does it call Reflection.getCallerClass or a similer method 392 * to ask about the identity of its caller? 393 */ 394 static boolean isCallerSensitive(MemberName mem) { 395 if (!mem.isInvocable()) return false; // fields are not caller sensitive 396 397 return mem.isCallerSensitive() || canBeCalledVirtual(mem); 398 } 399 400 static boolean canBeCalledVirtual(MemberName mem) { 401 assert(mem.isInvocable()); | 362 System.out.println("linkMethod => throw "+ex); 363 throw ex; 364 } 365 } 366 367 368 /** 369 * The JVM is resolving a CONSTANT_MethodHandle CP entry. And it wants our help. 370 * It will make an up-call to this method. (Do not change the name or signature.) 371 * The type argument is a Class for field requests and a MethodType for non-fields. 372 * <p> 373 * Recent versions of the JVM may also pass a resolved MemberName for the type. 374 * In that case, the name is ignored and may be null. 375 */ 376 static MethodHandle linkMethodHandleConstant(Class<?> callerClass, int refKind, 377 Class<?> defc, String name, Object type) { 378 try { 379 Lookup lookup = IMPL_LOOKUP.in(callerClass); 380 assert(refKindIsValid(refKind)); 381 return lookup.linkMethodHandleConstant((byte) refKind, defc, name, type); 382 } catch (IllegalAccessException ex) { 383 Error err = new IllegalAccessError(ex.getMessage()); 384 // err.initCause(ex); 385 throw err; 386 } catch (ReflectiveOperationException ex) { 387 Error err = new IncompatibleClassChangeError(); 388 err.initCause(ex); 389 throw err; 390 } 391 } 392 393 /** 394 * Is this method a caller-sensitive method? 395 * I.e., does it call Reflection.getCallerClass or a similer method 396 * to ask about the identity of its caller? 397 */ 398 static boolean isCallerSensitive(MemberName mem) { 399 if (!mem.isInvocable()) return false; // fields are not caller sensitive 400 401 return mem.isCallerSensitive() || canBeCalledVirtual(mem); 402 } 403 404 static boolean canBeCalledVirtual(MemberName mem) { 405 assert(mem.isInvocable()); |