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
  • #313804

Closed
Open
Opened May 29, 2009 by gpothier@gpothier

Improve analysis results

Using the BasicVerifier to verify methods, the information about errors is
currently not as useful as it could be, particularly because the instruction
numbers given do not reflect actual bytecode addresses or indexes (because it
is the rank of the faulty instruction in the method node's instruction list,
which includes labels, line number info, and so on).
I propose to include a reference to the faulty instruction in the
AnalyzerException class so that a more useful message can be generated by the
client code. The attached patch does precisely this. Then a code snippet like
this one can be used to retrieve the actual bytecode rank of an instruction,
which is very useful when using a tool that numbers the bytecodes, like eg.
jclasslib):

private int getBytecodeRank(MethodNode aNode, AbstractInsnNode aInstruction)
{
	if (aInstruction == null) return -1;
	int theRank = 1;
	ListIterator<AbstractInsnNode> theIterator = aNode.instructions.iterator();
	while(theIterator.hasNext()) 
	{
		AbstractInsnNode theNode = theIterator.next();
		if (theNode == aInstruction) return theRank;
			
		int theOpcode = theNode.getOpcode();
		if (theOpcode >= 0) theRank++;
	}
	
	return -1;
}
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: asm/asm#313804