Top Description Inners Constructors Methods
org.aspectj.weaver.bcel.asm

public Class StackMapAdder

extends Object
Class Inheritance
Imports
org.aspectj.weaver.ResolvedType, .UnresolvedType, .World, aj.org.objectweb.asm.ClassReader, .ClassVisitor, .ClassWriter, .MethodVisitor, .Opcodes

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static byte[]
addStackMaps(World world, String classname, byte[] data)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StackMapAdderback to summary
public StackMapAdder()

Method Detail

addStackMapsback to summary
public static byte[] addStackMaps(World world, String classname, byte[] data)
org.aspectj.weaver.bcel.asm back to summary

private Class StackMapAdder.AspectJClassVisitor

extends ClassVisitor
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Inherited from aj.org.objectweb.asm.ClassVisitor:
apicv

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public MethodVisitor
visitMethod(int
the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.
access
,
String
the method's name.
name
,
String
the method's descriptor (see Type).
desc
,
String
the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.
signature
,
String[]
the internal names of the method's exception classes (see Type#getInternalName()). May be null.
exceptions
)

Overrides aj.org.objectweb.asm.ClassVisitor.visitMethod.

Visits a method of the class.
Inherited from aj.org.objectweb.asm.ClassVisitor:
getDelegatevisitvisitAnnotationvisitAttributevisitEndvisitFieldvisitInnerClassvisitModulevisitNestHostvisitNestMembervisitOuterClassvisitPermittedSubclassvisitRecordComponentvisitSourcevisitTypeAnnotation

Constructor Detail

AspectJClassVisitorback to summary
public AspectJClassVisitor(ClassVisitor classwriter)

Method Detail

visitMethodback to summary
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)

Overrides aj.org.objectweb.asm.ClassVisitor.visitMethod.

Doc from aj.org.objectweb.asm.ClassVisitor.visitMethod.

Visits a method of the class. This method must return a new MethodVisitor instance (or null) each time it is called, i.e., it should not return a previously returned visitor.

Parameters
access:int

the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.

name:String

the method's name.

desc:String

the method's descriptor (see Type).

signature:String

the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.

exceptions:String[]

the internal names of the method's exception classes (see Type#getInternalName()). May be null.

Returns:MethodVisitor

an object to visit the byte code of the method, or null if this class visitor is not interested in visiting the code of this method.

Annotations
@Override
org.aspectj.weaver.bcel.asm back to summary

pack-priv Class StackMapAdder.AspectJClassVisitor.AJMethodVisitor

extends MethodVisitor
Class Inheritance

Field Summary

Inherited from aj.org.objectweb.asm.MethodVisitor:
apimv

Constructor Summary

AccessConstructor and Description
public

Constructor Detail

AJMethodVisitorback to summary
public AJMethodVisitor(MethodVisitor mv)
org.aspectj.weaver.bcel.asm back to summary

private Class StackMapAdder.AspectJConnectClassWriter

extends ClassWriter
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final World
Inherited from aj.org.objectweb.asm.ClassWriter:
COMPUTE_FRAMESCOMPUTE_MAXS

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String
getCommonSuperClass(final String
the internal name of a class (see Type#getInternalName()).
type1
,
final String
the internal name of another class (see Type#getInternalName()).
type2
)

Overrides aj.org.objectweb.asm.ClassWriter.getCommonSuperClass.

Returns the common super type of the two given types.
Inherited from aj.org.objectweb.asm.ClassWriter:
getClassLoaderhasFlagsnewClassnewConstnewConstantDynamicnewFieldnewHandlenewHandlenewInvokeDynamicnewMethodnewMethodTypenewModulenewNameTypenewPackagenewUTF8toByteArrayvisitvisitAnnotationvisitAttributevisitEndvisitFieldvisitInnerClassvisitMethodvisitModulevisitNestHostvisitNestMembervisitOuterClassvisitPermittedSubclassvisitRecordComponentvisitSourcevisitTypeAnnotation

Field Detail

worldback to summary
private final World world

Constructor Detail

AspectJConnectClassWriterback to summary
public AspectJConnectClassWriter(ClassReader cr, World w)

Method Detail

getCommonSuperClassback to summary
protected String getCommonSuperClass(final String type1, final String type2)

Overrides aj.org.objectweb.asm.ClassWriter.getCommonSuperClass.

Doc from aj.org.objectweb.asm.ClassWriter.getCommonSuperClass.

Returns the common super type of the two given types. The default implementation of this method loads the two given classes and uses the java.lang.Class methods to find the common super class. It can be overridden to compute this common super type in other ways, in particular without actually loading any class, or to take into account the class that is currently being generated by this ClassWriter, which can of course not be loaded since it is under construction.

Parameters
type1:String

the internal name of a class (see Type#getInternalName()).

type2:String

the internal name of another class (see Type#getInternalName()).

Returns:String

the internal name of the common super class of the two given classes (see Type#getInternalName()).

Annotations
@Override