public class ClassFile extends Object implements WritableEntry
Constructor and Description |
---|
ClassFile(String name,
int accessFlags,
String superclass,
String... interfaces) |
ClassFile(String name,
String superclass,
String... interfaces) |
Modifier and Type | Method and Description |
---|---|
ClassMethod |
addConstructor(Constructor<?> method)
Adds a constructor with the same signiture as the given constrcutor, including exception types
|
ClassField |
addField(Field field) |
ClassField |
addField(int accessFlags,
String name,
Class<?> type) |
ClassField |
addField(int accessFlags,
String name,
Class<?> type,
String genericSignature) |
ClassField |
addField(int accessFlags,
String name,
String descriptor)
Adds a field with the given name and descriptor.
|
ClassField |
addField(int accessFlags,
String name,
String descriptor,
String signature) |
void |
addInterface(String iface) |
ClassMethod |
addMethod(int accessFlags,
String name,
String returnType,
String... parameters) |
ClassMethod |
addMethod(Method method)
Adds a method with the same signiture as the given method, including exception types
|
Class<?> |
define(ClassLoader loader) |
Class<?> |
define(ClassLoader loader,
ProtectionDomain domain)
Definines the class using the given ClassLoader and ProtectionDomain
|
ConstPool |
getConstPool() |
String |
getDescriptor()
returns the type descriptor for the class
|
Set<ClassField> |
getFields() |
List<String> |
getInterfaces() |
Set<ClassMethod> |
getMethods() |
String |
getName()
Returns the generated class name
|
AnnotationsAttribute |
getRuntimeVisibleAnnotationsAttribute() |
String |
getSuperclass() |
byte[] |
toBytecode() |
void |
write(ByteArrayDataOutputStream stream) |
public void addInterface(String iface)
public ClassField addField(int accessFlags, String name, String descriptor)
public ClassField addField(int accessFlags, String name, String descriptor, String signature)
public ClassField addField(int accessFlags, String name, Class<?> type)
public ClassField addField(int accessFlags, String name, Class<?> type, String genericSignature)
public ClassField addField(Field field)
public ClassMethod addMethod(int accessFlags, String name, String returnType, String... parameters)
public ClassMethod addMethod(Method method)
The new method will have the same modifier as the original method, except that the abstract and native flags will be stripped.
TODO: annotations and signiture attribute
public ClassMethod addConstructor(Constructor<?> method)
TODO: annotations and signiture attribute
public void write(ByteArrayDataOutputStream stream) throws IOException
write
in interface WritableEntry
IOException
public Class<?> define(ClassLoader loader)
public Class<?> define(ClassLoader loader, ProtectionDomain domain)
public byte[] toBytecode()
public ConstPool getConstPool()
public String getDescriptor()
public AnnotationsAttribute getRuntimeVisibleAnnotationsAttribute()
public String getName()
public String getSuperclass()
public Set<ClassField> getFields()
public Set<ClassMethod> getMethods()
Copyright © 2017 JBoss, a division of Red Hat, Inc.. All Rights Reserved.