mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8295537: Enhance TRACE_METHOD_LINKAGE to show the target MethodHandle
Reviewed-by: jvernee, redestad, mchung
This commit is contained in:
parent
182c215888
commit
fd668dc44f
5 changed files with 75 additions and 14 deletions
|
@ -281,6 +281,12 @@ class MethodHandleNatives {
|
|||
type,
|
||||
staticArguments,
|
||||
caller);
|
||||
if (TRACE_METHOD_LINKAGE) {
|
||||
MethodHandle target = callSite.getTarget();
|
||||
System.out.println("linkCallSite target class => " + target.getClass().getName());
|
||||
System.out.println("linkCallSite target => " + target.debugString(0));
|
||||
}
|
||||
|
||||
if (callSite instanceof ConstantCallSite) {
|
||||
appendixResult[0] = callSite.dynamicInvoker();
|
||||
return Invokers.linkToTargetMethod(type);
|
||||
|
@ -298,13 +304,13 @@ class MethodHandleNatives {
|
|||
Object bsmReference = bootstrapMethod.internalMemberName();
|
||||
if (bsmReference == null) bsmReference = bootstrapMethod;
|
||||
String staticArglist = staticArglistForTrace(staticArguments);
|
||||
System.out.println("linkCallSite "+caller.getName()+" "+
|
||||
System.out.println("linkCallSite "+getCallerInfo(caller)+" "+
|
||||
bsmReference+" "+
|
||||
name+type+"/"+staticArglist);
|
||||
try {
|
||||
MemberName res = linkCallSiteImpl(caller, bootstrapMethod, name, type,
|
||||
staticArguments, appendixResult);
|
||||
System.out.println("linkCallSite => "+res+" + "+appendixResult[0]);
|
||||
System.out.println("linkCallSite linkage => "+res+" + "+appendixResult[0]);
|
||||
return res;
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace(); // print now in case exception is swallowed
|
||||
|
@ -313,6 +319,20 @@ class MethodHandleNatives {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a human-readable description of the caller. Something like
|
||||
* "java.base/java.security.Security.<clinit>(Security.java:82)"
|
||||
*/
|
||||
private static String getCallerInfo(Class<?> caller) {
|
||||
for (StackTraceElement e : Thread.currentThread().getStackTrace()) {
|
||||
if (e.getClassName().equals(caller.getName())) {
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
// fallback if the caller is somehow missing from the stack.
|
||||
return caller.getName();
|
||||
}
|
||||
|
||||
// this implements the upcall from the JVM, MethodHandleNatives.linkDynamicConstant:
|
||||
static Object linkDynamicConstant(Object callerObj,
|
||||
Object bootstrapMethodObj,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue