Package org.jboss.classfilewriter

## Class ClassFile

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

All Implemented Interfaces:
  `WritableEntry`

    public class ClassFile
    extends java.lang.Object
    implements WritableEntry

Author:
  Stuart Douglas

### Constructor Summary

Constructors
`ClassFile​(java.lang.String name, int accessFlags, java.lang.String superclass, int version, java.lang.ClassLoader classLoader, java.lang.String... interfaces)` Deprecated.
`ClassFile​(java.lang.String name, int accessFlags, java.lang.String superclass, int version, java.lang.ClassLoader classLoader, ClassFactory classFactory, java.lang.String... interfaces)`
`ClassFile​(java.lang.String name, int accessFlags, java.lang.String superclass, java.lang.ClassLoader classLoader, java.lang.String... interfaces)` Deprecated.
`ClassFile​(java.lang.String name, int accessFlags, java.lang.String superclass, java.lang.ClassLoader classLoader, ClassFactory classFactory, java.lang.String... interfaces)`
`ClassFile​(java.lang.String name, int accessFlags, java.lang.String superclass, java.lang.String... interfaces)` Deprecated.
`ClassFile​(java.lang.String name, java.lang.String superclass, java.lang.ClassLoader classLoader, java.lang.String... interfaces)` Deprecated.
`ClassFile​(java.lang.String name, java.lang.String superclass, java.lang.ClassLoader classLoader, ClassFactory classFactory, java.lang.String... interfaces)`
`ClassFile​(java.lang.String name, java.lang.String superclass, java.lang.String... interfaces)` Deprecated.

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`ClassMethod` `addConstructor​(java.lang.reflect.Constructor<?> method)` Adds a constructor with the same signiture as the given constrcutor, including exception types
`ClassField` `addField​(int accessFlags, java.lang.String name, java.lang.Class<?> type)`
`ClassField` `addField​(int accessFlags, java.lang.String name, java.lang.Class<?> type, java.lang.String genericSignature)`
`ClassField` `addField​(int accessFlags, java.lang.String name, java.lang.String descriptor)` Adds a field with the given name and descriptor.
`ClassField` `addField​(int accessFlags, java.lang.String name, java.lang.String descriptor, java.lang.String signature)`
`ClassField` `addField​(java.lang.reflect.Field field)`
`void` `addInterface​(java.lang.String iface)`
`ClassMethod` `addMethod​(int accessFlags, java.lang.String name, java.lang.String returnType, java.lang.String... parameters)`
`ClassMethod` `addMethod​(java.lang.reflect.Method method)` Adds a method with the same signiture as the given method, including exception types
`java.lang.Class<?>` `define()`
`java.lang.Class<?>` `define​(java.lang.ClassLoader loader)` Deprecated.
`java.lang.Class<?>` `define​(java.lang.ClassLoader loader, java.security.ProtectionDomain domain)` Deprecated.
`java.lang.Class<?>` `define​(java.security.ProtectionDomain domain)`
`java.lang.ClassLoader` `getClassLoader()`
`ConstPool` `getConstPool()`
`java.lang.String` `getDescriptor()` returns the type descriptor for the class
`java.util.Set<ClassField>` `getFields()`
`java.util.List<java.lang.String>` `getInterfaces()`
`java.util.Set<ClassMethod>` `getMethods()`
`java.lang.String` `getName()` Returns the generated class name
`AnnotationsAttribute` `getRuntimeVisibleAnnotationsAttribute()`
`java.lang.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 Detail

#### ClassFile

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

Deprecated.

#### ClassFile

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

Deprecated.

#### ClassFile

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

Deprecated.

#### ClassFile

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

Deprecated.

#### ClassFile

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

Deprecated.

#### ClassFile

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

#### ClassFile

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

#### ClassFile

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

### Method Detail

#### addInterface

    public void addInterface​(java.lang.String iface)

#### addField

    public ClassField addField​(int accessFlags,
                               java.lang.String name,
                               java.lang.String descriptor)

Adds a field with the given name and descriptor.

#### addField

    public ClassField addField​(int accessFlags,
                               java.lang.String name,
                               java.lang.String descriptor,
                               java.lang.String signature)

#### addField

    public ClassField addField​(int accessFlags,
                               java.lang.String name,
                               java.lang.Class<?> type)

#### addField

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

#### addField

    public ClassField addField​(java.lang.reflect.Field field)

#### addMethod

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

#### addMethod

    public ClassMethod addMethod​(java.lang.reflect.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​(java.lang.reflect.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 java.io.IOException

Specified by:
  `write` in interface `WritableEntry`
Throws:
  `java.io.IOException`

#### define

    public java.lang.Class<?> define()

#### define

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

Deprecated.

#### define

    public java.lang.Class<?> define​(java.security.ProtectionDomain domain)

#### define

    @Deprecated
    public java.lang.Class<?> define​(java.lang.ClassLoader loader,
                                     java.security.ProtectionDomain domain)

Deprecated.
Definines the class using the given ClassLoader and ProtectionDomain

#### toBytecode

    public byte[] toBytecode()

#### getClassLoader

    public java.lang.ClassLoader getClassLoader()

#### getConstPool

    public ConstPool getConstPool()

#### getDescriptor

    public java.lang.String getDescriptor()

returns the type descriptor for the class

Returns:

#### getRuntimeVisibleAnnotationsAttribute

    public AnnotationsAttribute getRuntimeVisibleAnnotationsAttribute()

#### getName

    public java.lang.String getName()

Returns the generated class name

Returns:
  The generated class name

#### getSuperclass

    public java.lang.String getSuperclass()

Returns:
  The generated superclass name

#### getInterfaces

    public java.util.List<java.lang.String> getInterfaces()

Returns:
  The interfaces implemented by this class

#### getFields

    public java.util.Set<ClassField> getFields()

Returns:
  This class's fields

#### getMethods

    public java.util.Set<ClassMethod> getMethods()

Returns:
  This classes methods