[FIX] Ещё баги в asm.

This commit is contained in:
Zaxar163 2019-09-17 18:14:32 +02:00
parent 3441fc21a7
commit 5de7eedc35
No known key found for this signature in database
GPG key ID: 1FE4F2E1F053831B

View file

@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.objectweb.asm.ClassReader;
@ -42,16 +43,21 @@ public static ClassNode forClass(String clazz, int flags, ClassMetadataReader r)
}
public static List<AnnotationNode> annots(String clazz, String method, ClassMetadataReader r) {
List<AnnotationNode> ret = new ArrayList<>();
ClassNode n = forClass(clazz, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG, r);
if (n.visibleAnnotations != null) ret.addAll(n.visibleAnnotations);
if (n.invisibleAnnotations != null) ret.addAll(n.invisibleAnnotations);
for (MethodNode m : n.methods)
if (method.equals(m.name)) {
if (m.visibleAnnotations != null) ret.addAll(m.visibleAnnotations);
if (m.invisibleAnnotations != null) ret.addAll(m.invisibleAnnotations);
}
return ret;
if (clazz.startsWith("L")) clazz = Type.getType(clazz).getInternalName();
try {
List<AnnotationNode> ret = new ArrayList<>();
ClassNode n = forClass(clazz, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG, r);
if (n.visibleAnnotations != null) ret.addAll(n.visibleAnnotations);
if (n.invisibleAnnotations != null) ret.addAll(n.invisibleAnnotations);
for (MethodNode m : n.methods)
if (method.equals(m.name)) {
if (m.visibleAnnotations != null) ret.addAll(m.visibleAnnotations);
if (m.invisibleAnnotations != null) ret.addAll(m.invisibleAnnotations);
}
return ret;
} catch (Throwable e) {
return Collections.emptyList();
}
}
private static int doMethodEmulation(String desc) {