Package com.aparapi.internal.model
Class ClassModel
java.lang.Object
com.aparapi.internal.model.ClassModel
Class represents a ClassFile (MyClass.class).
A ClassModel is constructed from an instance of a
java.lang.Class.
If the java class mode changes we may need to modify this to accommodate.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumclassclassclassclassclassstatic enumstatic interfacestatic interfacestatic classprivate static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate ClassModel.AttributePoolprivate static final ValueCache<Class<?>, ClassModel, ClassParseException> private static ClassLoaderprivate Class<?> private ClassModel.ConstantPoolprivate final ValueCache<EntrypointKey, Entrypoint, AparapiException> private final List<ClassModel.ClassModelField> private final List<ClassModel.ClassModelInterface> private static Loggerprivate intprivate intprivate ValueCache<MethodKey, MethodModel, AparapiException> private final List<ClassModel.ClassModelMethod> private intprivate Memoizer<Map<String, Kernel.PrivateMemorySpace>> private ValueCache<String, Integer, ClassParseException> static final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charprivate final ArrayList<ClassModel.ConstantPool.FieldEntry> private final ArrayList<InstructionSet.TypeSpec> private intprivate ClassModelprivate intprivate int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateClassModel(Class<?> _class) Create a ClassModel representing a given Class.(package private)ClassModel(Class<?> _clazz, byte[] _bytes) -
Method Summary
Modifier and TypeMethodDescription(package private) EntrypointcomputeBasicEntrypoint(EntrypointKey entrypointKey) private MethodModelcomputeMethodModel(MethodKey methodKey) private Map<String, Kernel.PrivateMemorySpace> private IntegercomputePrivateMemorySize(String fieldName) static Stringstatic Stringstatic Stringstatic ClassModelcreateClassModel(Class<?> _class) private static ClassModelcreateClassModelInternal(Class<?> key) intClass<?> getEntrypoint(String _entrypointName, Object _k) (package private) EntrypointgetEntrypoint(String _entrypointName, String _descriptor, Object _k) intgetMagic()intgetMethod(ClassModel.ConstantPool.MethodEntry _methodEntry, boolean _isSpecial) Look up a ConstantPool MethodEntry and return the corresponding Method.static ClassModel.MethodDescriptiongetMethodDescription(String _string) getMethodModel(String _name, String _signature) Create a MethodModel for a given method name and signature.private ClassModel.ClassModelMethodgetMethodOrNull(String _name, String _descriptor) intgetPrivateMemorySize(String fieldName) If a field does not satisfy the private memory conditions, null, otherwise the size of private memory required.static Integerstatic IntegergetPrivateMemorySizeFromFieldName(String fieldName) intGetter for superClazzintintstatic voidbooleanisSuperClass(Class<?> other) Determine if this is the superclass of some other class.booleanisSuperClass(String otherClassName) Determine if this is the superclass of some other named class.(package private) voidvoidvoidsetTotalStructSize(int x) toString()static StringtypeName(char _typeChar) Convert a given JNI character type (say 'I') to its type name ('int').
-
Field Details
-
SIGC_VOID
public static final char SIGC_VOID- See Also:
-
SIGC_BOOLEAN
public static final char SIGC_BOOLEAN- See Also:
-
SIGC_BYTE
public static final char SIGC_BYTE- See Also:
-
SIGC_CHAR
public static final char SIGC_CHAR- See Also:
-
SIGC_SHORT
public static final char SIGC_SHORT- See Also:
-
SIGC_INT
public static final char SIGC_INT- See Also:
-
SIGC_LONG
public static final char SIGC_LONG- See Also:
-
SIGC_FLOAT
public static final char SIGC_FLOAT- See Also:
-
SIGC_DOUBLE
public static final char SIGC_DOUBLE- See Also:
-
SIGC_ARRAY
public static final char SIGC_ARRAY- See Also:
-
SIGC_CLASS
public static final char SIGC_CLASS- See Also:
-
SIGC_START_METHOD
public static final char SIGC_START_METHOD- See Also:
-
SIGC_END_CLASS
public static final char SIGC_END_CLASS- See Also:
-
SIGC_END_METHOD
public static final char SIGC_END_METHOD- See Also:
-
SIGC_PACKAGE
public static final char SIGC_PACKAGE- See Also:
-
logger
-
superClazz
-
noClMethods
-
privateMemoryFields
-
privateMemorySizes
-
classModelCache
-
magic
private int magic -
minorVersion
private int minorVersion -
majorVersion
private int majorVersion -
constantPool
-
accessFlags
private int accessFlags -
thisClassConstantPoolIndex
private int thisClassConstantPoolIndex -
superClassConstantPoolIndex
private int superClassConstantPoolIndex -
interfaces
-
fields
-
methods
-
attributePool
-
classModelLoader
-
clazz
-
methodModelCache
-
structMembers
-
structMemberOffsets
-
structMemberTypes
-
totalStructSize
private int totalStructSize -
entrypointCache
-
-
Constructor Details
-
ClassModel
Create 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(Class<?> _clazz, byte[] _bytes) throws ClassParseException - Throws:
ClassParseException
-
-
Method Details
-
isSuperClass
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
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
Getter for superClazz- Returns:
- the superClazz ClassModel
-
replaceSuperClazz
-
typeName
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
If a field does not satisfy the private memory conditions, null, otherwise the size of private memory required.- Throws:
ClassParseException
-
computePrivateMemorySize
- Throws:
ClassParseException
-
computePrivateMemoryFields
-
getPrivateMemorySizeFromField
-
getPrivateMemorySizeFromFieldName
public static Integer getPrivateMemorySizeFromFieldName(String fieldName) throws ClassParseException - Throws:
ClassParseException
-
getNoCLMethods
-
computeNoCLMethods
-
convert
-
convert
-
convert
-
getMethodDescription
-
createClassModelInternal
- Throws:
ClassParseException
-
createClassModel
- Throws:
ClassParseException
-
parse
-
getMagic
public int getMagic() -
getMajorVersion
public int getMajorVersion() -
getMinorVersion
public int getMinorVersion() -
getAccessFlags
public int getAccessFlags() -
getConstantPool
-
getThisClassConstantPoolIndex
public int getThisClassConstantPoolIndex() -
getSuperClassConstantPoolIndex
public int getSuperClassConstantPoolIndex() -
getAttributePool
-
getField
-
getField
-
getMethod
-
getMethodOrNull
-
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
Create a MethodModel for a given method name and signature.- Parameters:
_name-_signature-- Returns:
- Throws:
AparapiException
-
computeMethodModel
- Throws:
AparapiException
-
getStructMembers
-
getStructMemberOffsets
-
getStructMemberTypes
-
getTotalStructSize
public int getTotalStructSize() -
setTotalStructSize
public void setTotalStructSize(int x) -
getEntrypoint
Entrypoint getEntrypoint(String _entrypointName, String _descriptor, Object _k) throws AparapiException - Throws:
AparapiException
-
computeBasicEntrypoint
- Throws:
AparapiException
-
getClassWeAreModelling
-
getEntrypoint
- Throws:
AparapiException
-
getEntrypoint
- Throws:
AparapiException
-
invalidateCaches
public static void invalidateCaches() -
toString
-