Module org.jboss.classfilewriter
Package org.jboss.classfilewriter

# Class ClassFile

java.lang.Object
org.jboss.classfilewriter.ClassFile

All Implemented Interfaces:
  `WritableEntry`

public class ClassFile extends Object implements WritableEntry

Author:
  Stuart Douglas, Richard Opalka

## Constructor Summary

Constructors
Constructor
Description
`ClassFile(String name, int accessFlags, String superclass, int version, ClassLoader classLoader, String... interfaces)`
Deprecated.
`ClassFile(String name, int accessFlags, String superclass, int version, ClassLoader classLoader, ClassFactory classFactory, String... interfaces)`
`ClassFile(String name, int accessFlags, String superclass, ClassLoader classLoader, String... interfaces)`
Deprecated.
`ClassFile(String name, int accessFlags, String superclass, ClassLoader classLoader, ClassFactory classFactory, String... interfaces)`
`ClassFile(String name, int accessFlags, String superclass, String... interfaces)`
Deprecated.
`ClassFile(String name, String superclass, ClassLoader classLoader, String... interfaces)`
Deprecated.
`ClassFile(String name, String superclass, ClassLoader classLoader, ClassFactory classFactory, String... interfaces)`
`ClassFile(String name, String superclass, String... interfaces)`
Deprecated.

## Method Summary

Modifier and Type
Method
Description
`ClassMethod`
`addConstructor(Constructor<?> method)`
Adds a constructor with the same signiture as the given constrcutor, including exception types
`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)`
`ClassField`
`addField(Field field)`
`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()`
`Class<?>`
`define(ClassLoader loader)`
Deprecated.
`Class<?>`
`define(ClassLoader loader, ProtectionDomain domain)`
Deprecated.
`Class<?>`
`define(ProtectionDomain domain)`
`ClassLoader`
`getClassLoader()`
`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)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ClassFile

@Deprecated public ClassFile(String name, String superclass, String... interfaces)
Deprecated.

### ClassFile

@Deprecated public ClassFile(String name, int accessFlags, String superclass, String... interfaces)
Deprecated.

### ClassFile

@Deprecated public ClassFile(String name, String superclass, ClassLoader classLoader, String... interfaces)
Deprecated.

### ClassFile

@Deprecated public ClassFile(String name, int accessFlags, String superclass, ClassLoader classLoader, String... interfaces)
Deprecated.

### ClassFile

@Deprecated public ClassFile(String name, int accessFlags, String superclass, int version, ClassLoader classLoader, String... interfaces)
Deprecated.

### ClassFile

public ClassFile(String name, String superclass, ClassLoader classLoader, ClassFactory classFactory, String... interfaces)

### ClassFile

public ClassFile(String name, int accessFlags, String superclass, ClassLoader classLoader, ClassFactory classFactory, String... interfaces)

### ClassFile

public ClassFile(String name, int accessFlags, String superclass, int version, ClassLoader classLoader, ClassFactory classFactory, String... interfaces)

## Method Details

### addInterface

public void addInterface(String iface)

### addField

public ClassField addField(int accessFlags, String name, String descriptor)
Adds a field with the given name and descriptor.

### addField

public ClassField addField(int accessFlags, String name, String descriptor, String signature)

### addField

public ClassField addField(int accessFlags, String name, Class<?> type)

### addField

public ClassField addField(int accessFlags, String name, Class<?> type, String genericSignature)

### addField

public ClassField addField(Field field)

### addMethod

public ClassMethod addMethod(int accessFlags, String name, String returnType, String... parameters)

### addMethod

public ClassMethod addMethod(Method method)
Adds a method with the same signiture as the given method, including exception types

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

### addConstructor

public ClassMethod addConstructor(Constructor<?> method)
Adds a constructor with the same signiture as the given constrcutor, including exception types

TODO: annotations and signiture attribute

### write

public void write(ByteArrayDataOutputStream stream) throws IOException

Specified by:
  `write` in interface `WritableEntry`
Throws:
  `IOException`

### define

public Class<?> define()

### define

@Deprecated public Class<?> define(ClassLoader loader)
Deprecated.

### define

public Class<?> define(ProtectionDomain domain)

### define

@Deprecated public Class<?> define(ClassLoader loader, ProtectionDomain domain)
Deprecated.
Definines the class using the given ClassLoader and ProtectionDomain

### toBytecode

public byte[] toBytecode()

### getClassLoader

public ClassLoader getClassLoader()

### getConstPool

public ConstPool getConstPool()

### getDescriptor

public String getDescriptor()
returns the type descriptor for the class

Returns:

### getRuntimeVisibleAnnotationsAttribute

public AnnotationsAttribute getRuntimeVisibleAnnotationsAttribute()

### getName

public String getName()
Returns the generated class name

Returns:
  The generated class name

### getSuperclass

public String getSuperclass()

Returns:
  The generated superclass name

### getInterfaces

public List<String> getInterfaces()

Returns:
  The interfaces implemented by this class

### getFields

public Set<ClassField> getFields()

Returns:
  This class's fields

### getMethods

public Set<ClassMethod> getMethods()

Returns:
  This classes methods