Skip to content

Commit

Permalink
Cleanup Indy bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
jbachorik committed Nov 9, 2024
1 parent 769fc0b commit 88f3ed5
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions btrace-runtime/src/main/java15/org/openjdk/btrace/runtime/Indy.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,23 @@ public static CallSite bootstrap(
MethodHandles.Lookup caller, String name, MethodType type, String probeClassName)
throws Exception {
assert repository != null;
MethodHandle mh;
try {
MethodHandle mh;
try {
byte[] classData =
repository.getProbeHandler(
caller.lookupClass().getName(), probeClassName, name, type.toMethodDescriptorString());
byte[] classData =
repository.getProbeHandler(
caller.lookupClass().getName(), probeClassName, name, type.toMethodDescriptorString());

caller =
caller.defineHiddenClass(classData, false, MethodHandles.Lookup.ClassOption.NESTMATE);
mh = caller.findStatic(caller.lookupClass(), name.substring(name.lastIndexOf("$") + 1), type);
} catch (Throwable t) {
// if unable to properly link just ignore the instrumentation
MethodHandle noopHandle =
MethodHandles.lookup().findStatic(Indy.class, "noop", MethodType.methodType(void.class));
mh = MethodHandles.dropArguments(noopHandle, 0, type.parameterArray());
}

return new ConstantCallSite(mh);
} finally {
// LinkingFlag.reset();
caller =
caller.defineHiddenClass(classData, false, MethodHandles.Lookup.ClassOption.NESTMATE);
mh = caller.findStatic(caller.lookupClass(), name.substring(name.lastIndexOf("$") + 1), type);
} catch (Throwable t) {
// if unable to properly link just ignore the instrumentation
MethodHandle noopHandle =
MethodHandles.lookup().findStatic(Indy.class, "noop", MethodType.methodType(void.class));
mh = MethodHandles.dropArguments(noopHandle, 0, type.parameterArray());
}

return new ConstantCallSite(mh);
}

public static void noop() {}
Expand Down

0 comments on commit 88f3ed5

Please sign in to comment.