35 import java.lang.classfile.CodeModel;
36 import java.lang.classfile.CodeTransform;
37 import java.lang.classfile.FieldBuilder;
38 import java.lang.classfile.FieldElement;
39 import java.lang.classfile.FieldModel;
40 import java.lang.classfile.FieldTransform;
41 import java.lang.classfile.Interfaces;
42 import java.lang.classfile.MethodBuilder;
43 import java.lang.classfile.MethodElement;
44 import java.lang.classfile.MethodModel;
45 import java.lang.classfile.MethodSignature;
46 import java.lang.classfile.MethodTransform;
47 import java.lang.classfile.Signature;
48 import java.lang.classfile.Superclass;
49 import java.lang.classfile.TypeAnnotation;
50 import java.lang.classfile.attribute.AnnotationDefaultAttribute;
51 import java.lang.classfile.attribute.EnclosingMethodAttribute;
52 import java.lang.classfile.attribute.ExceptionsAttribute;
53 import java.lang.classfile.attribute.InnerClassInfo;
54 import java.lang.classfile.attribute.InnerClassesAttribute;
55 import java.lang.classfile.attribute.ModuleAttribute;
56 import java.lang.classfile.attribute.ModuleProvideInfo;
57 import java.lang.classfile.attribute.NestHostAttribute;
58 import java.lang.classfile.attribute.NestMembersAttribute;
59 import java.lang.classfile.attribute.PermittedSubclassesAttribute;
60 import java.lang.classfile.attribute.RecordAttribute;
61 import java.lang.classfile.attribute.RecordComponentInfo;
62 import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
63 import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
64 import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
65 import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
66 import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
67 import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
68 import java.lang.classfile.attribute.SignatureAttribute;
69 import java.lang.classfile.components.ClassRemapper;
70 import java.lang.classfile.constantpool.Utf8Entry;
71 import java.lang.classfile.instruction.ConstantInstruction.LoadConstantInstruction;
72 import java.lang.classfile.instruction.ExceptionCatch;
73 import java.lang.classfile.instruction.FieldInstruction;
74 import java.lang.classfile.instruction.InvokeDynamicInstruction;
123 .map(this::mapRecordComponent).toList()));
124 case ModuleAttribute ma ->
125 clb.with(ModuleAttribute.of(ma.moduleName(), ma.moduleFlagsMask(),
126 ma.moduleVersion().orElse(null),
127 ma.requires(), ma.exports(), ma.opens(),
128 ma.uses().stream().map(ce ->
129 clb.constantPool().classEntry(map(ce.asSymbol()))).toList(),
130 ma.provides().stream().map(mp ->
131 ModuleProvideInfo.of(map(mp.provides().asSymbol()),
132 mp.providesWith().stream().map(pw ->
133 map(pw.asSymbol())).toList())).toList()));
134 case NestHostAttribute nha ->
135 clb.with(NestHostAttribute.of(map(nha.nestHost().asSymbol())));
136 case NestMembersAttribute nma ->
137 clb.with(NestMembersAttribute.ofSymbols(nma.nestMembers().stream()
138 .map(nm -> map(nm.asSymbol())).toList()));
139 case PermittedSubclassesAttribute psa ->
140 clb.with(PermittedSubclassesAttribute.ofSymbols(
141 psa.permittedSubclasses().stream().map(ps ->
142 map(ps.asSymbol())).toList()));
143 case RuntimeVisibleAnnotationsAttribute aa ->
144 clb.with(RuntimeVisibleAnnotationsAttribute.of(
145 mapAnnotations(aa.annotations())));
146 case RuntimeInvisibleAnnotationsAttribute aa ->
147 clb.with(RuntimeInvisibleAnnotationsAttribute.of(
148 mapAnnotations(aa.annotations())));
149 case RuntimeVisibleTypeAnnotationsAttribute aa ->
150 clb.with(RuntimeVisibleTypeAnnotationsAttribute.of(
151 mapTypeAnnotations(aa.annotations())));
152 case RuntimeInvisibleTypeAnnotationsAttribute aa ->
153 clb.with(RuntimeInvisibleTypeAnnotationsAttribute.of(
154 mapTypeAnnotations(aa.annotations())));
155 default ->
156 clb.with(cle);
157 }
158 }
159
160 @Override
161 public FieldTransform asFieldTransform() {
162 return (FieldBuilder fb, FieldElement fe) -> {
|
35 import java.lang.classfile.CodeModel;
36 import java.lang.classfile.CodeTransform;
37 import java.lang.classfile.FieldBuilder;
38 import java.lang.classfile.FieldElement;
39 import java.lang.classfile.FieldModel;
40 import java.lang.classfile.FieldTransform;
41 import java.lang.classfile.Interfaces;
42 import java.lang.classfile.MethodBuilder;
43 import java.lang.classfile.MethodElement;
44 import java.lang.classfile.MethodModel;
45 import java.lang.classfile.MethodSignature;
46 import java.lang.classfile.MethodTransform;
47 import java.lang.classfile.Signature;
48 import java.lang.classfile.Superclass;
49 import java.lang.classfile.TypeAnnotation;
50 import java.lang.classfile.attribute.AnnotationDefaultAttribute;
51 import java.lang.classfile.attribute.EnclosingMethodAttribute;
52 import java.lang.classfile.attribute.ExceptionsAttribute;
53 import java.lang.classfile.attribute.InnerClassInfo;
54 import java.lang.classfile.attribute.InnerClassesAttribute;
55 import java.lang.classfile.attribute.LoadableDescriptorsAttribute;
56 import java.lang.classfile.attribute.ModuleAttribute;
57 import java.lang.classfile.attribute.ModuleProvideInfo;
58 import java.lang.classfile.attribute.NestHostAttribute;
59 import java.lang.classfile.attribute.NestMembersAttribute;
60 import java.lang.classfile.attribute.PermittedSubclassesAttribute;
61 import java.lang.classfile.attribute.RecordAttribute;
62 import java.lang.classfile.attribute.RecordComponentInfo;
63 import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
64 import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
65 import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
66 import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
67 import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
68 import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
69 import java.lang.classfile.attribute.SignatureAttribute;
70 import java.lang.classfile.components.ClassRemapper;
71 import java.lang.classfile.constantpool.Utf8Entry;
72 import java.lang.classfile.instruction.ConstantInstruction.LoadConstantInstruction;
73 import java.lang.classfile.instruction.ExceptionCatch;
74 import java.lang.classfile.instruction.FieldInstruction;
75 import java.lang.classfile.instruction.InvokeDynamicInstruction;
124 .map(this::mapRecordComponent).toList()));
125 case ModuleAttribute ma ->
126 clb.with(ModuleAttribute.of(ma.moduleName(), ma.moduleFlagsMask(),
127 ma.moduleVersion().orElse(null),
128 ma.requires(), ma.exports(), ma.opens(),
129 ma.uses().stream().map(ce ->
130 clb.constantPool().classEntry(map(ce.asSymbol()))).toList(),
131 ma.provides().stream().map(mp ->
132 ModuleProvideInfo.of(map(mp.provides().asSymbol()),
133 mp.providesWith().stream().map(pw ->
134 map(pw.asSymbol())).toList())).toList()));
135 case NestHostAttribute nha ->
136 clb.with(NestHostAttribute.of(map(nha.nestHost().asSymbol())));
137 case NestMembersAttribute nma ->
138 clb.with(NestMembersAttribute.ofSymbols(nma.nestMembers().stream()
139 .map(nm -> map(nm.asSymbol())).toList()));
140 case PermittedSubclassesAttribute psa ->
141 clb.with(PermittedSubclassesAttribute.ofSymbols(
142 psa.permittedSubclasses().stream().map(ps ->
143 map(ps.asSymbol())).toList()));
144 case LoadableDescriptorsAttribute pa ->
145 clb.with(LoadableDescriptorsAttribute.of(pa.loadableDescriptors()));
146 case RuntimeVisibleAnnotationsAttribute aa ->
147 clb.with(RuntimeVisibleAnnotationsAttribute.of(
148 mapAnnotations(aa.annotations())));
149 case RuntimeInvisibleAnnotationsAttribute aa ->
150 clb.with(RuntimeInvisibleAnnotationsAttribute.of(
151 mapAnnotations(aa.annotations())));
152 case RuntimeVisibleTypeAnnotationsAttribute aa ->
153 clb.with(RuntimeVisibleTypeAnnotationsAttribute.of(
154 mapTypeAnnotations(aa.annotations())));
155 case RuntimeInvisibleTypeAnnotationsAttribute aa ->
156 clb.with(RuntimeInvisibleTypeAnnotationsAttribute.of(
157 mapTypeAnnotations(aa.annotations())));
158 default ->
159 clb.with(cle);
160 }
161 }
162
163 @Override
164 public FieldTransform asFieldTransform() {
165 return (FieldBuilder fb, FieldElement fe) -> {
|