if (frameCount != originalFrameCount ||
!Arrays.equals(stackMapFrameList.toArray(), originalFrames))
{
System.out.println("Original preverification ["+clazz.getName()+"]:");
new ClassPrinter().visitProgramMethod(programClass, programMethod);
}
}
else if (frameCount != 0)
{
System.out.println("Original preverification empty ["+clazz.getName()+"."+method.getName(clazz)+"]");
}
}
if (frameCount == 0)
{
// Remove any stack map (table) attribute from the code attribute.
new AttributesEditor(programClass, programMethod, codeAttribute, true).deleteAttribute(stackMapAttributeName);
}
else
{
Attribute stackMapAttribute;
// Create the appropriate attribute.
if (microEdition)
{
// Copy the frames into an array.
FullFrame[] stackMapFrames = new FullFrame[frameCount];
stackMapFrameList.toArray(stackMapFrames);
// Put the frames into a stack map attribute.
stackMapAttribute = new StackMapAttribute(stackMapFrames);
}
else
{
// Copy the frames into an array.
StackMapFrame[] stackMapFrames = new StackMapFrame[frameCount];
stackMapFrameList.toArray(stackMapFrames);
// Put the frames into a stack map table attribute.
stackMapAttribute = new StackMapTableAttribute(stackMapFrames);
}
// Fill out the name of the stack map attribute.
stackMapAttribute.u2attributeNameIndex =
new ConstantPoolEditor(programClass).addUtf8Constant(stackMapAttributeName);
// Add the new stack map (table) attribute to the code attribute.
new AttributesEditor(programClass, programMethod, codeAttribute, true).addAttribute(stackMapAttribute);
if (DEBUG)
{
System.out.println("Preverifier ["+programClass.getName()+"."+programMethod.getName(programClass)+"]:");
stackMapAttribute.accept(programClass, programMethod, codeAttribute, new ClassPrinter());
}
}
// Apply code modifications, deleting unreachable code.
codeAttributeEditor.visitCodeAttribute(clazz, method, codeAttribute);