|
25 | 25 |
|
26 | 26 | package java.lang.invoke; |
27 | 27 |
|
28 | | -import jdk.internal.org.objectweb.asm.ClassWriter; |
29 | | -import jdk.internal.org.objectweb.asm.Opcodes; |
30 | 28 | import sun.invoke.util.Wrapper; |
31 | 29 |
|
| 30 | +import java.lang.classfile.ClassFile; |
| 31 | +import java.lang.classfile.attribute.SourceFileAttribute; |
| 32 | +import java.lang.constant.ClassDesc; |
32 | 33 | import java.util.ArrayList; |
33 | 34 | import java.util.HashSet; |
34 | 35 | import java.util.Map; |
|
38 | 39 | import java.util.TreeSet; |
39 | 40 | import java.util.stream.Stream; |
40 | 41 |
|
| 42 | +import static java.lang.classfile.ClassFile.*; |
41 | 43 | import static java.lang.invoke.LambdaForm.BasicType.*; |
42 | | -import static java.lang.invoke.MethodHandleStatics.CLASSFILE_VERSION; |
43 | | -import static java.lang.invoke.MethodTypeForm.*; |
44 | 44 | import static java.lang.invoke.LambdaForm.Kind.*; |
| 45 | +import static java.lang.invoke.MethodTypeForm.*; |
45 | 46 |
|
46 | 47 | /** |
47 | 48 | * Helper class to assist the GenerateJLIClassesPlugin to get access to |
@@ -557,19 +558,14 @@ static byte[] generateInvokersHolderClassBytes(String className, |
557 | 558 | * a class with a specified name. |
558 | 559 | */ |
559 | 560 | private static byte[] generateCodeBytesForLFs(String className, String[] names, LambdaForm[] forms) { |
560 | | - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); |
561 | | - cw.visit(CLASSFILE_VERSION, Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, |
562 | | - className, null, InvokerBytecodeGenerator.INVOKER_SUPER_NAME, null); |
563 | | - cw.visitSource(className.substring(className.lastIndexOf('/') + 1), null); |
564 | | - |
565 | | - for (int i = 0; i < forms.length; i++) { |
566 | | - InvokerBytecodeGenerator g |
567 | | - = new InvokerBytecodeGenerator(className, names[i], forms[i], forms[i].methodType()); |
568 | | - g.setClassWriter(cw); |
569 | | - g.addMethod(); |
570 | | - } |
571 | | - |
572 | | - return cw.toByteArray(); |
| 561 | + return ClassFile.of().build(ClassDesc.ofInternalName(className), clb -> { |
| 562 | + clb.withFlags(ACC_PRIVATE | ACC_FINAL | ACC_SUPER) |
| 563 | + .withSuperclass(InvokerBytecodeGenerator.INVOKER_SUPER_DESC) |
| 564 | + .with(SourceFileAttribute.of(className.substring(className.lastIndexOf('/') + 1))); |
| 565 | + for (int i = 0; i < forms.length; i++) { |
| 566 | + new InvokerBytecodeGenerator(className, names[i], forms[i], forms[i].methodType()).addMethod(clb); |
| 567 | + } |
| 568 | + }); |
573 | 569 | } |
574 | 570 |
|
575 | 571 | private static LambdaForm makeReinvokerFor(MethodType type) { |
|
0 commit comments