Class SubClass

  • All Implemented Interfaces:
    javax.lang.model.AnnotatedConstruct, javax.lang.model.element.Element, javax.lang.model.element.Parameterizable, javax.lang.model.element.QualifiedNameable, javax.lang.model.element.TypeElement, Writable

    public class SubClass
    extends ClassFile
    • Field Detail

      • intfLock

        private final java.util.concurrent.locks.ReentrantLock intfLock
      • fieldLock

        private final java.util.concurrent.locks.ReentrantLock fieldLock
      • attrLock

        private final java.util.concurrent.locks.ReentrantLock attrLock
      • methodLock

        private final java.util.concurrent.locks.ReentrantLock methodLock
      • constantLock

        private final java.util.concurrent.locks.ReentrantReadWriteLock constantLock
      • constantReadLock

        private final java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock constantReadLock
      • constantWriteLock

        private final java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock constantWriteLock
    • Constructor Detail

      • SubClass

        public SubClass​(java.lang.Class<?> superClass,
                        java.lang.String qualifiedName,
                        javax.lang.model.element.Modifier... modifiers)
                 throws java.io.IOException
        Throws:
        java.io.IOException
      • SubClass

        public SubClass​(javax.lang.model.element.TypeElement superClass,
                        java.lang.String qualifiedName,
                        javax.lang.model.element.Modifier... modifiers)
                 throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • resolveFieldIndex

        int resolveFieldIndex​(javax.lang.model.element.VariableElement field)
        Returns the constant map index to field. If entry doesn't exist it is created.
        Parameters:
        field -
        Returns:
      • resolveFieldIndex

        private int resolveFieldIndex​(javax.lang.model.element.TypeElement declaringClass,
                                      java.lang.String name,
                                      java.lang.String descriptor)
        Returns the constant map index to field If entry doesn't exist it is created.
        Parameters:
        declaringClass -
        name -
        descriptor -
        Returns:
      • resolveMethodIndex

        int resolveMethodIndex​(javax.lang.model.element.ExecutableElement method)
        Returns the constant map index to method If entry doesn't exist it is created.
        Parameters:
        method -
        Returns:
      • resolveInterfaceMethodIndex

        int resolveInterfaceMethodIndex​(javax.lang.model.element.ExecutableElement method)
        Returns the constant map index to method If entry doesn't exist it is created.
        Parameters:
        method -
        Returns:
      • resolveNameIndex

        final int resolveNameIndex​(java.lang.CharSequence name)
        Returns the constant map index to name If entry doesn't exist it is created.
        Parameters:
        name -
        Returns:
      • resolveNameAndTypeIndex

        int resolveNameAndTypeIndex​(java.lang.String name,
                                    java.lang.String descriptor)
        Returns the constant map index to name and type If entry doesn't exist it is created.
        Parameters:
        name -
        descriptor -
        Returns:
      • resolveClassIndex

        public final int resolveClassIndex​(java.lang.Class<?> type)
        Returns the constant map index to class If entry doesn't exist it is created.
        Parameters:
        type -
        Returns:
      • resolveClassIndex

        public final int resolveClassIndex​(javax.lang.model.element.TypeElement type)
        Returns the constant map index to class If entry doesn't exist it is created.
        Parameters:
        type -
        Returns:
      • resolveClassIndex

        public final int resolveClassIndex​(javax.lang.model.type.ArrayType arrayType)
        Returns the constant map index to class If entry doesn't exist it is created.
        Parameters:
        arrayType -
        Returns:
      • resolveConstantIndex

        public final int resolveConstantIndex​(int constant)
        Returns the constant map index to constant If entry doesn't exist it is created.
        Parameters:
        constant -
        Returns:
      • resolveConstantIndex

        public final int resolveConstantIndex​(float constant)
        Returns the constant map index to constant If entry doesn't exist it is created.
        Parameters:
        constant -
        Returns:
      • resolveConstantIndex

        public final int resolveConstantIndex​(double constant)
        Returns the constant map index to constant If entry doesn't exist it is created.
        Parameters:
        constant -
        Returns:
      • resolveConstantIndex

        public final int resolveConstantIndex​(long constant)
        Returns the constant map index to constant If entry doesn't exist it is created.
        Parameters:
        constant -
        Returns:
      • resolveConstantIndex

        public final int resolveConstantIndex​(java.lang.String constant)
        Returns the constant map index to constant If entry doesn't exist it is created.
        Parameters:
        constant -
        Returns:
      • codeDefaultConstructor

        public void codeDefaultConstructor​(FieldInitializer... fis)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • codeDefaultConstructor

        public void codeDefaultConstructor​(FragmentCompiler fc,
                                           FieldInitializer... fis)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • codeStaticInitializer

        public void codeStaticInitializer​(FieldInitializer... fis)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • defineField

        public void defineField​(int modifier,
                                java.lang.String fieldName,
                                java.lang.Class<?> type)
        Define a new field.
        Parameters:
        modifier -
        fieldName -
        type -
      • defineField

        public void defineField​(int modifier,
                                java.lang.String fieldName,
                                javax.lang.model.type.TypeMirror type)
        Define a new field.
        Parameters:
        modifier -
        fieldName -
        type -
      • defineConstantField

        public void defineConstantField​(int modifier,
                                        java.lang.String fieldName,
                                        int constant)
        Define constant field and set the constant value.
        Parameters:
        modifier -
        fieldName -
        constant -
      • defineConstantField

        public void defineConstantField​(int modifier,
                                        java.lang.String fieldName,
                                        long constant)
        Define constant field and set the constant value.
        Parameters:
        modifier -
        fieldName -
        constant -
      • defineConstantField

        public void defineConstantField​(int modifier,
                                        java.lang.String fieldName,
                                        float constant)
        Define constant field and set the constant value.
        Parameters:
        modifier -
        fieldName -
        constant -
      • defineConstantField

        public void defineConstantField​(int modifier,
                                        java.lang.String fieldName,
                                        double constant)
        Define constant field and set the constant value.
        Parameters:
        modifier -
        fieldName -
        constant -
      • defineConstantField

        public void defineConstantField​(int modifier,
                                        java.lang.String fieldName,
                                        java.lang.String constant)
        Define constant field and set the constant value.
        Parameters:
        modifier -
        fieldName -
        constant -
      • createStaticInitializer

        public void createStaticInitializer​(MethodCompiler mc)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • defineMethod

        public void defineMethod​(MethodCompiler mc,
                                 int modifier,
                                 java.lang.String methodName,
                                 java.lang.Class<?> returnType,
                                 java.lang.Class<?>... parameters)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • defineMethod

        public void defineMethod​(MethodCompiler mc,
                                 int modifier,
                                 java.lang.String methodName,
                                 java.lang.Class<?> returnType,
                                 java.lang.Class<?>[] exceptionTypes,
                                 java.lang.Class<?>... parameters)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • overrideConstructor

        public void overrideConstructor​(MethodCompiler mc,
                                        int modifier,
                                        java.lang.Class<?>... parameters)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • overrideMethod

        public void overrideMethod​(MethodCompiler mc,
                                   int modifier,
                                   java.lang.String methodName,
                                   java.lang.Class<?>... parameters)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • overrideMethod

        public void overrideMethod​(MethodCompiler mc,
                                   javax.lang.model.element.ExecutableElement method,
                                   javax.lang.model.element.Modifier... modifiers)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • overrideMethod

        public void overrideMethod​(MethodCompiler mc,
                                   javax.lang.model.element.ExecutableElement method,
                                   java.util.Set<javax.lang.model.element.Modifier> modifiers)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • defineMethod

        public void defineMethod​(MethodCompiler mc,
                                 javax.lang.model.element.ExecutableElement method)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • defineMethod

        private void defineMethod​(MethodCompiler mc,
                                  SubClass.Method method)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • newInstance

        public java.lang.Object newInstance()
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • load

        public java.lang.Class<?> load()
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • createSourceFile

        public void createSourceFile​(javax.annotation.processing.ProcessingEnvironment env)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • dump

        public void dump()
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • save

        public void save​(javax.annotation.processing.ProcessingEnvironment env)
                  throws java.io.IOException
        Saves subclass as class file
        Parameters:
        env -
        Throws:
        java.io.IOException
      • write

        public void write​(java.io.DataOutput out)
                   throws java.io.IOException
        Writes the class
        Specified by:
        write in interface Writable
        Overrides:
        write in class ClassFile
        Parameters:
        out -
        Throws:
        java.io.IOException
      • addSignatureIfNeed

        private void addSignatureIfNeed()
      • getVariableFor

        javax.lang.model.element.VariableElement getVariableFor​(javax.lang.model.element.VariableElement ve)
      • hasTypeParameters

        private boolean hasTypeParameters​(javax.lang.model.element.VariableElement ve)
      • hasTypeParameters

        private boolean hasTypeParameters​(javax.lang.model.type.TypeMirror type)
      • getActualType

        private javax.lang.model.type.TypeMirror getActualType​(javax.lang.model.type.TypeMirror type)
      • getActualTypeFor

        private javax.lang.model.type.TypeMirror getActualTypeFor​(javax.lang.model.element.TypeParameterElement typeParameter)