Fix missing LDC instruction dependency check in optimizer
The optimizer did not track literal class access (e.g.
String.class) via LDC instruction when it analyze dependency.
@@ -62,6 +62,23 @@ public class MethodDependencyVisitor extends MethodVisitor {
super.visitLocalVariable(name, descriptor, signature, start, end, index);
}
+ @Override
+ public void visitLdcInsn(Object value) {
+ if (value instanceof Type) {
+ Type t = (Type) value;
+ String desc = null;
+ if (t.getSort() == Type.OBJECT) {
+ desc = t.getDescriptor();
+ } else if (t.getSort() == Type.ARRAY) {
+ desc = t.getElementType().getDescriptor();
+ }
+ if (desc != null) {
+ dependencyCollector.addDescriptor(desc);
+ }
+ }
+ super.visitLdcInsn(value);
+ }
+
@Override
public void visitLineNumber(int line, Label start) {
if (preserveDebugInfo)
