Package com.aparapi.internal.model
Class ClassModel
- java.lang.Object
-
- com.aparapi.internal.model.ClassModel
-
public class ClassModel extends java.lang.ObjectClass represents a ClassFile (MyClass.class). A ClassModel is constructed from an instance of ajava.lang.Class. If the java class mode changes we may need to modify this to accommodate.- See Also:
- Java 5 Class File Format + * @see Java 7 Class File Format
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClassModel.AccessclassClassModel.AttributePoolclassClassModel.ClassModelFieldclassClassModel.ClassModelInterfaceclassClassModel.ClassModelMethodclassClassModel.ConstantPoolstatic classClassModel.ConstantPoolTypestatic interfaceClassModel.LocalVariableInfostatic interfaceClassModel.LocalVariableTableEntry<T extends ClassModel.LocalVariableInfo>static classClassModel.MethodDescriptionprivate static classClassModel.SignatureParseState
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description privateClassModel(java.lang.Class<?> _class)Create a ClassModel representing a given Class.(package private)ClassModel(java.lang.Class<?> _clazz, byte[] _bytes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) EntrypointcomputeBasicEntrypoint(EntrypointKey entrypointKey)private MethodModelcomputeMethodModel(MethodKey methodKey)private java.util.Set<java.lang.String>computeNoCLMethods()private java.util.Map<java.lang.String,Kernel.PrivateMemorySpace>computePrivateMemoryFields()private java.lang.IntegercomputePrivateMemorySize(java.lang.String fieldName)static java.lang.Stringconvert(java.lang.String _string)static java.lang.Stringconvert(java.lang.String _string, java.lang.String _insert)static java.lang.Stringconvert(java.lang.String _string, java.lang.String _insert, boolean _showFullClassName)static ClassModelcreateClassModel(java.lang.Class<?> _class)private static ClassModelcreateClassModelInternal(java.lang.Class<?> key)intgetAccessFlags()ClassModel.AttributePoolgetAttributePool()java.lang.Class<?>getClassWeAreModelling()ClassModel.ConstantPoolgetConstantPool()EntrypointgetEntrypoint()EntrypointgetEntrypoint(java.lang.String _entrypointName, java.lang.Object _k)(package private) EntrypointgetEntrypoint(java.lang.String _entrypointName, java.lang.String _descriptor, java.lang.Object _k)ClassModel.ClassModelFieldgetField(java.lang.String _name)ClassModel.ClassModelFieldgetField(java.lang.String _name, java.lang.String _descriptor)java.util.List<ClassModel.ClassModelField>getFieldPoolEntries()intgetMagic()intgetMajorVersion()ClassModel.ClassModelMethodgetMethod(ClassModel.ConstantPool.MethodEntry _methodEntry, boolean _isSpecial)Look up a ConstantPool MethodEntry and return the corresponding Method.ClassModel.ClassModelMethodgetMethod(java.lang.String _name, java.lang.String _descriptor)static ClassModel.MethodDescriptiongetMethodDescription(java.lang.String _string)MethodModelgetMethodModel(java.lang.String _name, java.lang.String _signature)Create a MethodModel for a given method name and signature.private ClassModel.ClassModelMethodgetMethodOrNull(java.lang.String _name, java.lang.String _descriptor)intgetMinorVersion()java.util.Set<java.lang.String>getNoCLMethods()java.lang.IntegergetPrivateMemorySize(java.lang.String fieldName)If a field does not satisfy the private memory conditions, null, otherwise the size of private memory required.static java.lang.IntegergetPrivateMemorySizeFromField(java.lang.reflect.Field field)static java.lang.IntegergetPrivateMemorySizeFromFieldName(java.lang.String fieldName)java.util.ArrayList<java.lang.Long>getStructMemberOffsets()java.util.ArrayList<ClassModel.ConstantPool.FieldEntry>getStructMembers()java.util.ArrayList<InstructionSet.TypeSpec>getStructMemberTypes()intgetSuperClassConstantPoolIndex()ClassModelgetSuperClazz()Getter for superClazzintgetThisClassConstantPoolIndex()intgetTotalStructSize()static voidinvalidateCaches()booleanisSuperClass(java.lang.Class<?> other)Determine if this is the superclass of some other class.booleanisSuperClass(java.lang.String otherClassName)Determine if this is the superclass of some other named class.(package private) voidparse(java.lang.Class<?> _class)voidreplaceSuperClazz(ClassModel c)voidsetTotalStructSize(int x)java.lang.StringtoString()static java.lang.StringtypeName(char _typeChar)Convert a given JNI character type (say 'I') to its type name ('int').
-
-
-
Field Detail
-
SIGC_VOID
public static final char SIGC_VOID
- See Also:
- Constant Field Values
-
SIGC_BOOLEAN
public static final char SIGC_BOOLEAN
- See Also:
- Constant Field Values
-
SIGC_BYTE
public static final char SIGC_BYTE
- See Also:
- Constant Field Values
-
SIGC_CHAR
public static final char SIGC_CHAR
- See Also:
- Constant Field Values
-
SIGC_SHORT
public static final char SIGC_SHORT
- See Also:
- Constant Field Values
-
SIGC_INT
public static final char SIGC_INT
- See Also:
- Constant Field Values
-
SIGC_LONG
public static final char SIGC_LONG
- See Also:
- Constant Field Values
-
SIGC_FLOAT
public static final char SIGC_FLOAT
- See Also:
- Constant Field Values
-
SIGC_DOUBLE
public static final char SIGC_DOUBLE
- See Also:
- Constant Field Values
-
SIGC_ARRAY
public static final char SIGC_ARRAY
- See Also:
- Constant Field Values
-
SIGC_CLASS
public static final char SIGC_CLASS
- See Also:
- Constant Field Values
-
SIGC_START_METHOD
public static final char SIGC_START_METHOD
- See Also:
- Constant Field Values
-
SIGC_END_CLASS
public static final char SIGC_END_CLASS
- See Also:
- Constant Field Values
-
SIGC_END_METHOD
public static final char SIGC_END_METHOD
- See Also:
- Constant Field Values
-
SIGC_PACKAGE
public static final char SIGC_PACKAGE
- See Also:
- Constant Field Values
-
logger
private static java.util.logging.Logger logger
-
superClazz
private ClassModel superClazz
-
noClMethods
private Memoizer<java.util.Set<java.lang.String>> noClMethods
-
privateMemoryFields
private Memoizer<java.util.Map<java.lang.String,Kernel.PrivateMemorySpace>> privateMemoryFields
-
privateMemorySizes
private ValueCache<java.lang.String,java.lang.Integer,ClassParseException> privateMemorySizes
-
classModelCache
private static final ValueCache<java.lang.Class<?>,ClassModel,ClassParseException> classModelCache
-
magic
private int magic
-
minorVersion
private int minorVersion
-
majorVersion
private int majorVersion
-
constantPool
private ClassModel.ConstantPool constantPool
-
accessFlags
private int accessFlags
-
thisClassConstantPoolIndex
private int thisClassConstantPoolIndex
-
superClassConstantPoolIndex
private int superClassConstantPoolIndex
-
interfaces
private final java.util.List<ClassModel.ClassModelInterface> interfaces
-
fields
private final java.util.List<ClassModel.ClassModelField> fields
-
methods
private final java.util.List<ClassModel.ClassModelMethod> methods
-
attributePool
private ClassModel.AttributePool attributePool
-
classModelLoader
private static java.lang.ClassLoader classModelLoader
-
clazz
private java.lang.Class<?> clazz
-
methodModelCache
private ValueCache<MethodKey,MethodModel,AparapiException> methodModelCache
-
structMembers
private final java.util.ArrayList<ClassModel.ConstantPool.FieldEntry> structMembers
-
structMemberOffsets
private final java.util.ArrayList<java.lang.Long> structMemberOffsets
-
structMemberTypes
private final java.util.ArrayList<InstructionSet.TypeSpec> structMemberTypes
-
totalStructSize
private int totalStructSize
-
entrypointCache
private final ValueCache<EntrypointKey,Entrypoint,AparapiException> entrypointCache
-
-
Constructor Detail
-
ClassModel
private ClassModel(java.lang.Class<?> _class) throws ClassParseExceptionCreate a ClassModel representing a given Class. The class's classfile must be available from the class's classloader viagetClassLoader().getResourceAsStream(name)). For dynamic languages creating classes on the fly we may need another approach.- Parameters:
_class- The class we will extract the model from- Throws:
ClassParseException
-
ClassModel
ClassModel(java.lang.Class<?> _clazz, byte[] _bytes) throws ClassParseException- Throws:
ClassParseException
-
-
Method Detail
-
isSuperClass
public boolean isSuperClass(java.lang.String otherClassName)
Determine if this is the superclass of some other named class.- Parameters:
otherClassName- The name of the class to compare against- Returns:
- true if 'this' a superclass of another named class
-
isSuperClass
public boolean isSuperClass(java.lang.Class<?> other)
Determine if this is the superclass of some other class.- Parameters:
other- The class to compare against- Returns:
- true if 'this' a superclass of another class
-
getSuperClazz
public ClassModel getSuperClazz()
Getter for superClazz- Returns:
- the superClazz ClassModel
-
replaceSuperClazz
public void replaceSuperClazz(ClassModel c)
-
typeName
public static java.lang.String typeName(char _typeChar)
Convert a given JNI character type (say 'I') to its type name ('int').- Parameters:
_typeChar-- Returns:
- either a mapped type name or null if no mapping exists.
-
getPrivateMemorySize
public java.lang.Integer getPrivateMemorySize(java.lang.String fieldName) throws ClassParseExceptionIf a field does not satisfy the private memory conditions, null, otherwise the size of private memory required.- Throws:
ClassParseException
-
computePrivateMemorySize
private java.lang.Integer computePrivateMemorySize(java.lang.String fieldName) throws ClassParseException- Throws:
ClassParseException
-
computePrivateMemoryFields
private java.util.Map<java.lang.String,Kernel.PrivateMemorySpace> computePrivateMemoryFields()
-
getPrivateMemorySizeFromField
public static java.lang.Integer getPrivateMemorySizeFromField(java.lang.reflect.Field field)
-
getPrivateMemorySizeFromFieldName
public static java.lang.Integer getPrivateMemorySizeFromFieldName(java.lang.String fieldName) throws ClassParseException- Throws:
ClassParseException
-
getNoCLMethods
public java.util.Set<java.lang.String> getNoCLMethods()
-
computeNoCLMethods
private java.util.Set<java.lang.String> computeNoCLMethods()
-
convert
public static java.lang.String convert(java.lang.String _string)
-
convert
public static java.lang.String convert(java.lang.String _string, java.lang.String _insert)
-
convert
public static java.lang.String convert(java.lang.String _string, java.lang.String _insert, boolean _showFullClassName)
-
getMethodDescription
public static ClassModel.MethodDescription getMethodDescription(java.lang.String _string)
-
createClassModelInternal
private static ClassModel createClassModelInternal(java.lang.Class<?> key) throws ClassParseException
- Throws:
ClassParseException
-
createClassModel
public static ClassModel createClassModel(java.lang.Class<?> _class) throws ClassParseException
- Throws:
ClassParseException
-
parse
void parse(java.lang.Class<?> _class) throws ClassParseException, java.lang.ClassNotFoundException- Throws:
ClassParseExceptionjava.lang.ClassNotFoundException
-
getMagic
public int getMagic()
-
getMajorVersion
public int getMajorVersion()
-
getMinorVersion
public int getMinorVersion()
-
getAccessFlags
public int getAccessFlags()
-
getConstantPool
public ClassModel.ConstantPool getConstantPool()
-
getThisClassConstantPoolIndex
public int getThisClassConstantPoolIndex()
-
getSuperClassConstantPoolIndex
public int getSuperClassConstantPoolIndex()
-
getAttributePool
public ClassModel.AttributePool getAttributePool()
-
getField
public ClassModel.ClassModelField getField(java.lang.String _name, java.lang.String _descriptor)
-
getField
public ClassModel.ClassModelField getField(java.lang.String _name)
-
getMethod
public ClassModel.ClassModelMethod getMethod(java.lang.String _name, java.lang.String _descriptor)
-
getMethodOrNull
private ClassModel.ClassModelMethod getMethodOrNull(java.lang.String _name, java.lang.String _descriptor)
-
getFieldPoolEntries
public java.util.List<ClassModel.ClassModelField> getFieldPoolEntries()
-
getMethod
public ClassModel.ClassModelMethod getMethod(ClassModel.ConstantPool.MethodEntry _methodEntry, boolean _isSpecial)
Look up a ConstantPool MethodEntry and return the corresponding Method.- Parameters:
_methodEntry- The ConstantPool MethodEntry we want._isSpecial- True if we wish to delegate to super (to supportsuper.foo())- Returns:
- The Method or null if we fail to locate a given method.
-
getMethodModel
public MethodModel getMethodModel(java.lang.String _name, java.lang.String _signature) throws AparapiException
Create a MethodModel for a given method name and signature.- Parameters:
_name-_signature-- Returns:
- Throws:
AparapiException
-
computeMethodModel
private MethodModel computeMethodModel(MethodKey methodKey) throws AparapiException
- Throws:
AparapiException
-
getStructMembers
public java.util.ArrayList<ClassModel.ConstantPool.FieldEntry> getStructMembers()
-
getStructMemberOffsets
public java.util.ArrayList<java.lang.Long> getStructMemberOffsets()
-
getStructMemberTypes
public java.util.ArrayList<InstructionSet.TypeSpec> getStructMemberTypes()
-
getTotalStructSize
public int getTotalStructSize()
-
setTotalStructSize
public void setTotalStructSize(int x)
-
getEntrypoint
Entrypoint getEntrypoint(java.lang.String _entrypointName, java.lang.String _descriptor, java.lang.Object _k) throws AparapiException
- Throws:
AparapiException
-
computeBasicEntrypoint
Entrypoint computeBasicEntrypoint(EntrypointKey entrypointKey) throws AparapiException
- Throws:
AparapiException
-
getClassWeAreModelling
public java.lang.Class<?> getClassWeAreModelling()
-
getEntrypoint
public Entrypoint getEntrypoint(java.lang.String _entrypointName, java.lang.Object _k) throws AparapiException
- Throws:
AparapiException
-
getEntrypoint
public Entrypoint getEntrypoint() throws AparapiException
- Throws:
AparapiException
-
invalidateCaches
public static void invalidateCaches()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-