8329955: Class-File API ClassPrinter does not print bootstrap methods arguments

Reviewed-by: briangoetz
This commit is contained in:
Adam Sotona 2024-04-09 14:44:00 +00:00
parent f9bc2db9a9
commit e75e1cb02c
2 changed files with 335 additions and 264 deletions

View file

@ -817,13 +817,15 @@ public final class ClassPrinterImpl {
"owner", inv.owner().name().stringValue(),
"method name", inv.name().stringValue(),
"method type", inv.type().stringValue()));
case InvokeDynamicInstruction invd -> in.with(leafs(
case InvokeDynamicInstruction invd -> {
in.with(leafs(
"name", invd.name().stringValue(),
"descriptor", invd.type().stringValue(),
"kind", invd.bootstrapMethod().kind().name(),
"owner", invd.bootstrapMethod().owner().descriptorString(),
"method name", invd.bootstrapMethod().methodName(),
"invocation type", invd.bootstrapMethod().invocationType().descriptorString()));
"bootstrap method", invd.bootstrapMethod().kind().name()
+ " " + Util.toInternalName(invd.bootstrapMethod().owner())
+ "::" + invd.bootstrapMethod().methodName()));
in.with(list("arguments", "arg", invd.bootstrapArgs().stream()));
}
case NewObjectInstruction newo -> in.with(leaf(
"type", newo.className().name().stringValue()));
case NewPrimitiveArrayInstruction newa -> in.with(leafs(
@ -884,12 +886,15 @@ public final class ClassPrinterImpl {
bm -> {
var mh = bm.bootstrapMethod();
var mref = mh.reference();
return map("bm",
var bmNode = new MapNodeImpl(FLOW, "bm");
bmNode.with(leafs(
"index", bm.bsmIndex(),
"kind", DirectMethodHandleDesc.Kind.valueOf(mh.kind(),
mref instanceof InterfaceMethodRefEntry).name(),
"owner", mref.owner().name().stringValue(),
"name", mref.nameAndType().name().stringValue(),
"type", mref.nameAndType().type().stringValue());
"owner", mref.owner().asInternalName(),
"name", mref.nameAndType().name().stringValue()));
bmNode.with(list("args", "arg", bm.arguments().stream().map(LoadableConstantEntry::constantValue)));
return bmNode;
})));
case ConstantValueAttribute cva ->
nodes.add(leaf("constant value", cva.constant().constantValue()));