Regression in 6.1: "new Frame" instead of "newFrame" in Analyzer
Analyzer in ASM 6.0 uses only methods newFrame
for creation of instances of class Frame
. In ASM 6.1.1 there is usage of new Frame
- https://gitlab.ow2.org/asm/asm/blob/ASM_6_1_1/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Analyzer.java#L276
Test below is a simplified variant of https://github.com/jacoco/jacoco/blob/v0.8.1/org.jacoco.core.test/src/org/jacoco/core/test/validation/StructuredLockingTest.java
Both tests pass with ASM 6.0, but fail with 6.1.1:
import org.junit.Test;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.analysis.Analyzer;
import org.objectweb.asm.tree.analysis.AnalyzerException;
import org.objectweb.asm.tree.analysis.BasicInterpreter;
import org.objectweb.asm.tree.analysis.BasicValue;
import org.objectweb.asm.tree.analysis.Frame;
import java.io.IOException;
import static org.junit.Assert.assertTrue;
public class ExampleTest {
@Test
public void test() throws AnalyzerException, IOException {
Analyzer<BasicValue> analyzer = new Analyzer<BasicValue>(
new BasicInterpreter()) {
@Override
protected Frame<BasicValue> newFrame(int nLocals, int nStack) {
return new CustomFrame(nLocals, nStack);
}
@Override
protected Frame<BasicValue> newFrame(
Frame<? extends BasicValue> src) {
return new CustomFrame(src);
}
};
ClassNode classNode = new ClassNode();
new ClassReader(Target.class.getName()).accept(classNode, 0);
for (MethodNode m : classNode.methods) {
analyzer.analyze(classNode.name, m);
}
}
static class Target {
static final Object lock1 = new Object();
public static void main(String[] args) {
synchronized (lock1) {
nop();
}
}
static void nop() {
}
}
static class CustomFrame extends Frame<BasicValue> {
CustomFrame(int nLocals, int nStack) {
super(nLocals, nStack);
}
CustomFrame(Frame<? extends BasicValue> src) {
super(src);
}
@Override
public Frame<BasicValue> init(Frame<? extends BasicValue> frame) {
assertTrue(frame instanceof CustomFrame);
return super.init(frame);
}
}
}