Class StackMapAdder

java.lang.Object
org.aspectj.weaver.bcel.asm.StackMapAdder

public class StackMapAdder extends Object
Uses asm to add the stack map attribute to methods in a class. The class is passed in as pure byte data and then a reader/writer process it. The writer is wired into the world so that types can be resolved and getCommonSuperClass() can be implemented without class loading using the context class loader. It is important that the constant pool is preserved here and asm does not try to remove unused entries. That is because some entries are refered to from classfile attributes. Asm cannot see into these attributes so does not realise the constant pool entries are in use. In order to ensure the copying of cp occurs, we use the variant super constructor call in AspectJConnectClassWriter that passes in the classreader. However, ordinarily that change causes a further optimization: that if a classreader sees a methodvisitor that has been created by a ClassWriter then it just copies the data across without changing it (and so it fails to attach the stackmapattribute). In order to avoid this further optimization we use our own minimal MethodVisitor.
Author:
Andy Clement
  • Constructor Details

    • StackMapAdder

      public StackMapAdder()
  • Method Details

    • addStackMaps

      public static byte[] addStackMaps(World world, byte[] data)