harpoon.ClassFile
Interface HClassMutator


public interface HClassMutator

An HClassMutator allows you to change members and properties of an HClass.

Version:
$Id: HClassMutator.java,v 1.3 2003/03/18 03:52:53 salcianu Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
HClass.getMutator()

Method Summary
 HInitializer addClassInitializer()
           
 HConstructor addConstructor(HClass[] paramTypes)
           
 HConstructor addConstructor(HConstructor template)
           
 HConstructor addConstructor(String descriptor)
           
 HField addDeclaredField(String name, HClass type)
          Adds a field to the underlying class.
 HField addDeclaredField(String name, HField template)
          Adds a new field named name to the underlying class.
 HField addDeclaredField(String name, String descriptor)
          Adds a field to the underlying class.
 HMethod addDeclaredMethod(String name, HClass[] paramTypes, HClass returnType)
          Adds a method to the underlying HClass.
 HMethod addDeclaredMethod(String name, HMethod template)
          Adds a method named name to the underlying HClass.
 HMethod addDeclaredMethod(String name, String descriptor)
          Adds a method to the underlying HClass.
 void addInterface(HClass in)
           
 void addModifiers(int m)
           
 void removeAllInterfaces()
           
 void removeClassInitializer(HInitializer m)
           
 void removeConstructor(HConstructor c)
           
 void removeDeclaredField(HField f)
           
 void removeDeclaredMethod(HMethod m)
           
 void removeInterface(HClass in)
           
 void removeModifiers(int m)
           
 void setModifiers(int m)
           
 void setSourceFile(String sourcefilename)
           
 void setSuperclass(HClass sc)
           
 

Method Detail

addDeclaredField

HField addDeclaredField(String name,
                        HClass type)
                        throws DuplicateMemberException
Adds a field to the underlying class. Use HFieldMutator to set the modifiers for the added field.

Parameters:
name - name of the added field
type - type of the added field
Returns:
handle for the added field
Throws:
DuplicateMemberException
See Also:
HFieldMutator

addDeclaredField

HField addDeclaredField(String name,
                        String descriptor)
                        throws DuplicateMemberException
Adds a field to the underlying class. Use HFieldMutator to set the modifiers for the added field.

Parameters:
name - name of the added field
descriptor - descriptor for the type of the added field, formatted as specified in Section 4.3 of the JVM specification.
Returns:
handle for the added field
Throws:
DuplicateMemberException
See Also:
HFieldMutator

addDeclaredField

HField addDeclaredField(String name,
                        HField template)
                        throws DuplicateMemberException
Adds a new field named name to the underlying class. The type and the modifiers are taken from template.

Throws:
DuplicateMemberException

removeDeclaredField

void removeDeclaredField(HField f)
                         throws NoSuchMemberException
Throws:
NoSuchMemberException

addClassInitializer

HInitializer addClassInitializer()
                                 throws DuplicateMemberException
Throws:
DuplicateMemberException

removeClassInitializer

void removeClassInitializer(HInitializer m)
                            throws NoSuchMemberException
Throws:
NoSuchMemberException

addConstructor

HConstructor addConstructor(String descriptor)
                            throws DuplicateMemberException
Throws:
DuplicateMemberException

addConstructor

HConstructor addConstructor(HClass[] paramTypes)
                            throws DuplicateMemberException
Throws:
DuplicateMemberException

addConstructor

HConstructor addConstructor(HConstructor template)
                            throws DuplicateMemberException
Throws:
DuplicateMemberException

removeConstructor

void removeConstructor(HConstructor c)
                       throws NoSuchMemberException
Throws:
NoSuchMemberException

addDeclaredMethod

HMethod addDeclaredMethod(String name,
                          String descriptor)
                          throws DuplicateMemberException
Adds a method to the underlying HClass. Use HMethodMutator to set the method modifiers (public, static etc.)

Parameters:
name - name of the added method
descriptor - descriptor for the type of the added method, as specified in Section 4.3 of the JVM specification.
Returns:
handler for the added method
Throws:
DuplicateMemberException
See Also:
HMethodMutator

addDeclaredMethod

HMethod addDeclaredMethod(String name,
                          HClass[] paramTypes,
                          HClass returnType)
                          throws DuplicateMemberException
Adds a method to the underlying HClass. Later, you can use HMethodMutator to set the method modifiers (public, static etc.)

Parameters:
name - name of the added method
paramTypes - parameter types for the added method
returnType - return type for the added method
Returns:
handler for the added method
Throws:
DuplicateMemberException
See Also:
HMethodMutator

addDeclaredMethod

HMethod addDeclaredMethod(String name,
                          HMethod template)
                          throws DuplicateMemberException
Adds a method named name to the underlying HClass. The method type and modifiers are taken from template.

Throws:
DuplicateMemberException

removeDeclaredMethod

void removeDeclaredMethod(HMethod m)
                          throws NoSuchMemberException
Throws:
NoSuchMemberException

addInterface

void addInterface(HClass in)

removeInterface

void removeInterface(HClass in)
                     throws NoSuchClassException
Throws:
NoSuchClassException

removeAllInterfaces

void removeAllInterfaces()

addModifiers

void addModifiers(int m)

setModifiers

void setModifiers(int m)

removeModifiers

void removeModifiers(int m)

setSuperclass

void setSuperclass(HClass sc)

setSourceFile

void setSourceFile(String sourcefilename)