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