|
23 | 23 | import com.google.common.base.Splitter;
|
24 | 24 | import com.google.common.collect.ImmutableList;
|
25 | 25 | import com.google.common.collect.Streams;
|
26 |
| -import org.objectweb.asm.Opcodes; |
| 26 | +import com.google.turbine.bytecode.ClassFile; |
| 27 | +import com.google.turbine.bytecode.ClassReader; |
27 | 28 | import java.io.File;
|
28 | 29 | import java.io.IOException;
|
29 | 30 | import java.io.UncheckedIOException;
|
|
41 | 42 | import org.junit.Test;
|
42 | 43 | import org.junit.runner.RunWith;
|
43 | 44 | import org.junit.runners.JUnit4;
|
44 |
| -import org.objectweb.asm.ClassReader; |
45 |
| -import org.objectweb.asm.ClassVisitor; |
46 |
| -import org.objectweb.asm.FieldVisitor; |
47 |
| -import org.objectweb.asm.MethodVisitor; |
48 | 45 |
|
49 | 46 | /**
|
50 | 47 | * Reads all field, class, and method signatures in the bootclasspath, and round-trips them through
|
@@ -92,51 +89,31 @@ public void roundTrip() throws Exception {
|
92 | 89 | forEachBootclass(
|
93 | 90 | path -> {
|
94 | 91 | try {
|
95 |
| - new ClassReader(Files.newInputStream(path)) |
96 |
| - .accept( |
97 |
| - new ClassVisitor(Opcodes.ASM9) { |
98 |
| - @Override |
99 |
| - public void visit( |
100 |
| - int version, |
101 |
| - int access, |
102 |
| - String name, |
103 |
| - String signature, |
104 |
| - String superName, |
105 |
| - String[] interfaces) { |
106 |
| - if (signature != null) { |
107 |
| - assertThat(SigWriter.classSig(new SigParser(signature).parseClassSig())) |
108 |
| - .isEqualTo(signature); |
109 |
| - totalSignatures[0]++; |
110 |
| - } |
111 |
| - } |
112 |
| - |
113 |
| - @Override |
114 |
| - public FieldVisitor visitField( |
115 |
| - int access, String name, String desc, String signature, Object value) { |
116 |
| - if (signature != null) { |
117 |
| - assertThat(SigWriter.type(new SigParser(signature).parseFieldSig())) |
118 |
| - .isEqualTo(signature); |
119 |
| - totalSignatures[0]++; |
120 |
| - } |
121 |
| - return super.visitField(access, name, desc, signature, value); |
122 |
| - } |
123 |
| - |
124 |
| - @Override |
125 |
| - public MethodVisitor visitMethod( |
126 |
| - int access, |
127 |
| - String name, |
128 |
| - String desc, |
129 |
| - String signature, |
130 |
| - String[] exceptions) { |
131 |
| - if (signature != null) { |
132 |
| - assertThat(SigWriter.method(new SigParser(signature).parseMethodSig())) |
133 |
| - .isEqualTo(signature); |
134 |
| - totalSignatures[0]++; |
135 |
| - } |
136 |
| - return super.visitMethod(access, name, desc, signature, exceptions); |
137 |
| - } |
138 |
| - }, |
139 |
| - ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG); |
| 92 | + ClassFile classFile = ClassReader.read(path.toString(), Files.readAllBytes(path)); |
| 93 | + { |
| 94 | + String signature = classFile.signature(); |
| 95 | + if (signature != null) { |
| 96 | + assertThat(SigWriter.classSig(new SigParser(signature).parseClassSig())) |
| 97 | + .isEqualTo(signature); |
| 98 | + totalSignatures[0]++; |
| 99 | + } |
| 100 | + } |
| 101 | + for (ClassFile.FieldInfo field : classFile.fields()) { |
| 102 | + String signature = field.signature(); |
| 103 | + if (signature != null) { |
| 104 | + assertThat(SigWriter.type(new SigParser(signature).parseFieldSig())) |
| 105 | + .isEqualTo(signature); |
| 106 | + totalSignatures[0]++; |
| 107 | + } |
| 108 | + } |
| 109 | + for (ClassFile.MethodInfo method : classFile.methods()) { |
| 110 | + String signature = method.signature(); |
| 111 | + if (signature != null) { |
| 112 | + assertThat(SigWriter.method(new SigParser(signature).parseMethodSig())) |
| 113 | + .isEqualTo(signature); |
| 114 | + totalSignatures[0]++; |
| 115 | + } |
| 116 | + } |
140 | 117 | } catch (IOException e) {
|
141 | 118 | throw new UncheckedIOException(e);
|
142 | 119 | }
|
|
0 commit comments