8338543: ClassBuilder withMethod builders should cache the method type symbol
Reviewed-by: asotona
This commit is contained in:
parent
55851a312b
commit
68d1f5c33b
@ -276,10 +276,7 @@ public sealed interface ClassBuilder
|
||||
MethodTypeDesc descriptor,
|
||||
int methodFlags,
|
||||
Consumer<? super CodeBuilder> handler) {
|
||||
return withMethodBody(constantPool().utf8Entry(name),
|
||||
constantPool().utf8Entry(descriptor),
|
||||
methodFlags,
|
||||
handler);
|
||||
return withMethod(name, descriptor, methodFlags, mb -> mb.withCode(handler));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package jdk.internal.classfile.impl;
|
||||
|
||||
import java.lang.constant.MethodTypeDesc;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import java.lang.classfile.*;
|
||||
@ -78,6 +79,15 @@ public final class ChainedClassBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassBuilder withMethod(String name, MethodTypeDesc descriptor, int flags, Consumer<? super MethodBuilder> handler) {
|
||||
var mb = new BufferedMethodBuilder(terminal.constantPool, terminal.context,
|
||||
constantPool().utf8Entry(name), constantPool().utf8Entry(descriptor), flags, null);
|
||||
mb.mDesc = descriptor;
|
||||
consumer.accept(mb.run(handler).toModel());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassBuilder transformMethod(MethodModel method, MethodTransform transform) {
|
||||
BufferedMethodBuilder builder = new BufferedMethodBuilder(terminal.constantPool, terminal.context,
|
||||
|
@ -26,6 +26,7 @@
|
||||
package jdk.internal.classfile.impl;
|
||||
|
||||
import java.lang.constant.ConstantDescs;
|
||||
import java.lang.constant.MethodTypeDesc;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -106,6 +107,13 @@ public final class DirectClassBuilder
|
||||
.run(handler));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassBuilder withMethod(String name, MethodTypeDesc descriptor, int flags, Consumer<? super MethodBuilder> handler) {
|
||||
var method = new DirectMethodBuilder(constantPool, context, constantPool.utf8Entry(name), constantPool.utf8Entry(descriptor), flags, null);
|
||||
method.mDesc = descriptor;
|
||||
return withMethod(method.run(handler));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassBuilder transformMethod(MethodModel method, MethodTransform transform) {
|
||||
DirectMethodBuilder builder = new DirectMethodBuilder(constantPool, context, method.methodName(),
|
||||
|
Loading…
Reference in New Issue
Block a user