Class SubClass
java.lang.Object
org.vesalainen.bcc.ClassFile
org.vesalainen.bcc.SubClass
- All Implemented Interfaces:
AnnotatedConstruct, Element, Parameterizable, QualifiedNameable, TypeElement, Writable
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class ClassFile
ClassFile.ClassType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ReentrantLockprivate final ReentrantReadWriteLockprivate final ReentrantReadWriteLock.ReadLockprivate final ReentrantReadWriteLock.WriteLockprivate final ReentrantLockprivate final ReentrantLockprivate final ReentrantLockFields inherited from class ClassFile
attributes, constant_pool, constantPoolIndexMap, constantPoolMap, enclosedElements, fields, indexedElementMap, interfaces, magic, major_version, methods, minor_version, modifiers, packageElement, qualifiedName, super_class, superClass, this_class, type, typeParameterMap -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidAdds a new attributeprotected intaddConstantInfo(ConstantInfo ci, int fromIndex) voidaddFieldInfo(FieldInfo fieldInfo) voidaddInterface(short intf) voidaddMethodInfo(MethodInfo methodInfo) private voidbuildMethod(String methodName) voidvoidcodeDefaultConstructor(FragmentCompiler fc, FieldInitializer... fis) voidvoidvoidvoiddefineConstantField(int modifier, String fieldName, double constant) Define constant field and set the constant value.voiddefineConstantField(int modifier, String fieldName, float constant) Define constant field and set the constant value.voiddefineConstantField(int modifier, String fieldName, int constant) Define constant field and set the constant value.voiddefineConstantField(int modifier, String fieldName, long constant) Define constant field and set the constant value.voiddefineConstantField(int modifier, String fieldName, String constant) Define constant field and set the constant value.voiddefineField(int modifier, String fieldName, Class<?> type) Define a new field.voiddefineField(int modifier, String fieldName, TypeMirror type) Define a new field.voiddefineMethod(MethodCompiler mc, int modifier, String methodName, Class<?> returnType, Class<?>... parameters) voiddefineMethod(MethodCompiler mc, int modifier, String methodName, Class<?> returnType, Class<?>[] exceptionTypes, Class<?>... parameters) voiddefineMethod(MethodCompiler mc, ExecutableElement method) private voiddefineMethod(MethodCompiler mc, SubClass.Method method) voiddump()private TypeMirrorgetActualType(TypeMirror type) private TypeMirrorgetActualTypeFor(TypeParameterElement typeParameter) (package private) VariableElementprivate booleanprivate booleanhasTypeParameters(TypeMirror type) Class<?> load()voidoverrideConstructor(MethodCompiler mc, int modifier, Class<?>... parameters) voidoverrideMethod(MethodCompiler mc, int modifier, String methodName, Class<?>... parameters) voidoverrideMethod(MethodCompiler mc, ExecutableElement method, Set<Modifier> modifiers) voidoverrideMethod(MethodCompiler mc, ExecutableElement method, Modifier... modifiers) final intresolveClassIndex(Class<?> type) Returns the constant map index to class If entry doesn't exist it is created.final intresolveClassIndex(TypeElement type) Returns the constant map index to class If entry doesn't exist it is created.final intresolveClassIndex(ArrayType arrayType) Returns the constant map index to class If entry doesn't exist it is created.final intresolveConstantIndex(double constant) Returns the constant map index to constant If entry doesn't exist it is created.final intresolveConstantIndex(float constant) Returns the constant map index to constant If entry doesn't exist it is created.final intresolveConstantIndex(int constant) Returns the constant map index to constant If entry doesn't exist it is created.final intresolveConstantIndex(long constant) Returns the constant map index to constant If entry doesn't exist it is created.final intresolveConstantIndex(String constant) Returns the constant map index to constant If entry doesn't exist it is created.private intresolveFieldIndex(TypeElement declaringClass, String name, String descriptor) Returns the constant map index to field If entry doesn't exist it is created.(package private) intresolveFieldIndex(VariableElement field) Returns the constant map index to field.(package private) intReturns the constant map index to method If entry doesn't exist it is created.(package private) intresolveMethodIndex(ExecutableElement method) Returns the constant map index to method If entry doesn't exist it is created.(package private) intresolveNameAndTypeIndex(String name, String descriptor) Returns the constant map index to name and type If entry doesn't exist it is created.(package private) final intresolveNameIndex(CharSequence name) Returns the constant map index to name If entry doesn't exist it is created.voidSaves subclass as class filevoidwrite(DataOutput out) Writes the classMethods inherited from class ClassFile
accept, addIndexedElement, asType, getAnnotation, getAnnotationMirrors, getAnnotationsByType, getClassDescription, getClassIndex, getClassIndex, getConstantIndex, getConstantIndex, getConstantIndex, getConstantIndex, getConstantIndex, getConstantInfo, getConstantPoolSize, getEnclosedElements, getEnclosingElement, getFieldDescription, getFieldIndex, getFieldIndex, getFields, getIndexedType, getInterfaces, getKind, getMethodDescription, getMethodIndex, getMethodInfos, getModifiers, getNameAndTypeIndex, getNameIndex, getNestingKind, getQualifiedName, getReferencedClassnames, getRefIndex, getSimpleName, getString, getSuperclass, getTypeParameters, isImplemented, isSynthetic, referencesClass, referencesMethodMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TypeElement
getPermittedSubclasses, getRecordComponents
-
Field Details
-
intfLock
-
fieldLock
-
attrLock
-
methodLock
-
constantLock
-
constantReadLock
-
constantWriteLock
-
-
Constructor Details
-
SubClass
public SubClass(Class<?> superClass, String qualifiedName, Modifier... modifiers) throws IOException - Throws:
IOException
-
SubClass
public SubClass(TypeElement superClass, String qualifiedName, Modifier... modifiers) throws IOException - Throws:
IOException
-
-
Method Details
-
addAttribute
Description copied from class:ClassFileAdds a new attribute- Overrides:
addAttributein classClassFile- Parameters:
ai-
-
addConstantInfo
- Overrides:
addConstantInfoin classClassFile
-
addFieldInfo
- Overrides:
addFieldInfoin classClassFile
-
addInterface
public void addInterface(short intf) - Overrides:
addInterfacein classClassFile
-
addMethodInfo
- Overrides:
addMethodInfoin classClassFile
-
resolveFieldIndex
Returns the constant map index to field. If entry doesn't exist it is created.- Parameters:
field-- Returns:
-
resolveFieldIndex
Returns the constant map index to field If entry doesn't exist it is created.- Parameters:
declaringClass-name-descriptor-- Returns:
-
resolveMethodIndex
Returns the constant map index to method If entry doesn't exist it is created.- Parameters:
method-- Returns:
-
resolveInterfaceMethodIndex
Returns the constant map index to method If entry doesn't exist it is created.- Parameters:
method-- Returns:
-
resolveNameIndex
Returns the constant map index to name If entry doesn't exist it is created.- Parameters:
name-- Returns:
-
resolveNameAndTypeIndex
-
resolveClassIndex
Returns the constant map index to class If entry doesn't exist it is created.- Parameters:
type-- Returns:
-
resolveClassIndex
Returns the constant map index to class If entry doesn't exist it is created.- Parameters:
type-- Returns:
-
resolveClassIndex
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
Returns the constant map index to constant If entry doesn't exist it is created.- Parameters:
constant-- Returns:
-
codeDefaultConstructor
- Throws:
IOException
-
codeDefaultConstructor
- Throws:
IOException
-
codeStaticInitializer
- Throws:
IOException
-
defineField
-
defineField
Define a new field.- Parameters:
modifier-fieldName-type-
-
defineConstantField
Define constant field and set the constant value.- Parameters:
modifier-fieldName-constant-
-
defineConstantField
Define constant field and set the constant value.- Parameters:
modifier-fieldName-constant-
-
defineConstantField
Define constant field and set the constant value.- Parameters:
modifier-fieldName-constant-
-
defineConstantField
Define constant field and set the constant value.- Parameters:
modifier-fieldName-constant-
-
defineConstantField
-
createStaticInitializer
- Throws:
IOException
-
buildMethod
-
defineMethod
public void defineMethod(MethodCompiler mc, int modifier, String methodName, Class<?> returnType, Class<?>... parameters) throws IOException - Throws:
IOException
-
defineMethod
public void defineMethod(MethodCompiler mc, int modifier, String methodName, Class<?> returnType, Class<?>[] exceptionTypes, Class<?>... parameters) throws IOException - Throws:
IOException
-
overrideConstructor
public void overrideConstructor(MethodCompiler mc, int modifier, Class<?>... parameters) throws IOException - Throws:
IOException
-
overrideMethod
public void overrideMethod(MethodCompiler mc, int modifier, String methodName, Class<?>... parameters) throws IOException - Throws:
IOException
-
overrideMethod
public void overrideMethod(MethodCompiler mc, ExecutableElement method, Modifier... modifiers) throws IOException - Throws:
IOException
-
overrideMethod
public void overrideMethod(MethodCompiler mc, ExecutableElement method, Set<Modifier> modifiers) throws IOException - Throws:
IOException
-
defineMethod
- Throws:
IOException
-
defineMethod
- Throws:
IOException
-
newInstance
- Throws:
IOException
-
load
- Throws:
IOException
-
createSourceFile
- Throws:
IOException
-
dump
- Throws:
IOException
-
save
Saves subclass as class file- Parameters:
env-- Throws:
IOException
-
write
Writes the class- Specified by:
writein interfaceWritable- Overrides:
writein classClassFile- Parameters:
out-- Throws:
IOException
-
addSignatureIfNeed
private void addSignatureIfNeed() -
getVariableFor
-
hasTypeParameters
-
hasTypeParameters
-
getActualType
-
getActualTypeFor
-