Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
asm
asm
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 5
    • Issues 5
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 3
    • Merge Requests 3
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • asm
  • asmasm
  • Issues
  • #317821

Closed
Open
Opened Apr 17, 2018 by Evgeny Mandrikov@godinContributor

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);
		}
	}
}
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: asm/asm#317821