|
23 | 23 | */ |
24 | 24 | public final class ClassFile { |
25 | 25 |
|
| 26 | + static final String JAVA_LANG_OBJECT = "java/lang/Object"; |
| 27 | + static final String STATIC_INITIALIZER = "<clinit>"; |
| 28 | + static final String CONSTRUCTOR = "<init>"; |
| 29 | + static final String SIMPLE_CALL = "()V"; |
| 30 | + |
26 | 31 | private static final String[] NO_INTERFACES = {}; |
27 | 32 | private static final FieldOutline[] NO_FIELDS = {}; |
28 | 33 | private static final MethodOutline[] NO_METHODS = {}; |
29 | 34 | private static final String[] NO_ANNOTATIONS = {}; |
| 35 | + |
| 36 | + private static final int ACC_INTERFACE = 0x0200; |
30 | 37 | private static final int ACC_MODULE = 0x8000; |
31 | 38 |
|
32 | 39 | // attribute header for annotations that are visible at runtime |
@@ -171,7 +178,17 @@ private static ClassHeader parse(byte[] bytecode, boolean onlyHeader) { |
171 | 178 | String className = utf(bytecode, cp[cp[u2(bytecode, cursor)]]); |
172 | 179 | cursor += 2; |
173 | 180 |
|
174 | | - String superName = access != ACC_MODULE ? utf(bytecode, cp[cp[u2(bytecode, cursor)]]) : null; |
| 181 | + String superName; |
| 182 | + if ((access & ACC_INTERFACE) != 0) { |
| 183 | + superName = JAVA_LANG_OBJECT; |
| 184 | + } else if (access != ACC_MODULE) { |
| 185 | + superName = utf(bytecode, cp[cp[u2(bytecode, cursor)]]); |
| 186 | + if (JAVA_LANG_OBJECT.equals(superName)) { |
| 187 | + superName = JAVA_LANG_OBJECT; |
| 188 | + } |
| 189 | + } else { |
| 190 | + superName = null; |
| 191 | + } |
175 | 192 | cursor += 2; |
176 | 193 |
|
177 | 194 | // optional list of implemented/extended interfaces |
@@ -231,8 +248,14 @@ private static ClassHeader parse(byte[] bytecode, boolean onlyHeader) { |
231 | 248 | int methodAccess = u2(bytecode, cursor); |
232 | 249 | cursor += 2; |
233 | 250 | String methodName = utf(bytecode, cp[u2(bytecode, cursor)]); |
| 251 | + if (CONSTRUCTOR.equals(methodName)) { |
| 252 | + methodName = CONSTRUCTOR; |
| 253 | + } |
234 | 254 | cursor += 2; |
235 | 255 | String descriptor = utf(bytecode, cp[u2(bytecode, cursor)]); |
| 256 | + if (SIMPLE_CALL.equals(descriptor)) { |
| 257 | + descriptor = SIMPLE_CALL; |
| 258 | + } |
236 | 259 | cursor += 2; |
237 | 260 | String[] annotations = NO_ANNOTATIONS; |
238 | 261 | Map<UtfKey, String> ofInterest = annotationsOfInterest; |
|
0 commit comments