Skip to content

Commit

Permalink
ClassFile context made static
Browse files Browse the repository at this point in the history
  • Loading branch information
asotona committed Jun 3, 2024
1 parent 29e269f commit fb3cdcd
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
*/
final class ProxyGenerator {

private static final ClassFile CF_CONTEXT =
ClassFile.of(ClassFile.StackMapsOption.DROP_STACK_MAPS);

private static final ClassDesc
CD_Class_array = ReferenceClassDescImpl.ofValidated("[Ljava/lang/Class;"),
CD_IllegalAccessException = ReferenceClassDescImpl.ofValidated("Ljava/lang/IllegalAccessException;"),
Expand Down Expand Up @@ -118,10 +121,6 @@ final class ProxyGenerator {
}
}

/**
* Classfile context
*/
private final ClassFile classfileContext;
private final ConstantPoolBuilder cp;
private final List<StackMapFrameInfo.VerificationTypeInfo> throwableStack;
private final NameAndTypeEntry exInit;
Expand Down Expand Up @@ -163,10 +162,6 @@ final class ProxyGenerator {
*/
private ProxyGenerator(ClassLoader loader, String className, List<Class<?>> interfaces,
int accessFlags) {
this.classfileContext = ClassFile.of(
ClassFile.StackMapsOption.DROP_STACK_MAPS,
ClassFile.ClassHierarchyResolverOption.of(
ClassHierarchyResolver.ofClassLoading(loader).cached()));
this.cp = ConstantPoolBuilder.of();
this.classEntry = cp.classEntry(ReferenceClassDescImpl.ofValidatedBinaryName(className));
this.interfaces = interfaces;
Expand Down Expand Up @@ -469,7 +464,7 @@ private byte[] generateClassFile() {
checkReturnTypes(sigmethods);
}

return classfileContext.build(classEntry, cp, clb -> {
return CF_CONTEXT.build(classEntry, cp, clb -> {
clb.withSuperclass(proxy);
clb.withFlags(accessFlags);
clb.withInterfaces(toClassEntries(cp, interfaces));
Expand Down

0 comments on commit fb3cdcd

Please sign in to comment.