Class ClassModel


  • public class ClassModel
    extends java.lang.Object
    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:
    Java 5 Class File Format + * @see Java 7 Class File Format
    • Constructor Detail

      • ClassModel

        private ClassModel​(java.lang.Class<?> _class)
                    throws ClassParseException
        Create a ClassModel representing a given Class. The class's classfile must be available from the class's classloader via getClassLoader().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
    • 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 ClassParseException
        If a field does not satisfy the private memory conditions, null, otherwise the size of private memory required.
        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)
      • getMagic

        public int getMagic()
      • getMajorVersion

        public int getMajorVersion()
      • getMinorVersion

        public int getMinorVersion()
      • getAccessFlags

        public int getAccessFlags()
      • getThisClassConstantPoolIndex

        public int getThisClassConstantPoolIndex()
      • getSuperClassConstantPoolIndex

        public int getSuperClassConstantPoolIndex()
      • 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 support super.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
      • getStructMemberOffsets

        public java.util.ArrayList<java.lang.Long> getStructMemberOffsets()
      • getTotalStructSize

        public int getTotalStructSize()
      • setTotalStructSize

        public void setTotalStructSize​(int x)
      • getClassWeAreModelling

        public java.lang.Class<?> getClassWeAreModelling()
      • invalidateCaches

        public static void invalidateCaches()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object