Overview | Package | Class | Use | Tree | Deprecated | Index
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javassist
Class CtBehavior

    java.lang.Object
      |
      +--javassist.CtMember
            |
            +--javassist.CtBehavior

Direct Known Subclasses:
  CtConstructor, CtMethod

public abstract class CtBehavior
extends CtMember

`CtBehavior` is the abstract super class of `CtMethod` and `CtConstructor`.

Method Summary
`void` | `addCatch(java.lang.String src, CtClass exceptionType)` Adds a catch clause that handles an exception thrown in the body.
`void` | `addCatch(java.lang.String src, CtClass exceptionType, java.lang.String exceptionName)` Adds a catch clause that handles an exception thrown in the body.
`byte[]` | `getAttribute(java.lang.String name)` Obtains an attribute with the given name.
`CtClass[]` | `getExceptionTypes()` Obtains exceptions that this member may throw.
`MethodInfo` | `getMethodInfo()` Returns the MethodInfo representing this member in the class file.
`MethodInfo` | `getMethodInfo2()` Undocumented method.
`int` | `getModifiers()` Obtains the modifiers of the member.
`abstract java.lang.String` | `getName()` Obtains the name of this member.
`CtClass[]` | `getParameterTypes()` Obtains parameter types of this member.
`java.lang.String` | `getSignature()` Returns the character string representing the parameter types and the return type.
`void` | `insertAfter(java.lang.String src)` Inserts bytecode at the end of the body.
`void` | `insertAfter(java.lang.String src, boolean asFinally)` Inserts bytecode at the end of the body.
`void` | `insertBefore(java.lang.String src)` Inserts bytecode at the beginning of the body.
`void` | `instrument(CodeConverter converter)` Modifies the member body.
`void` | `instrument(ExprEditor editor)` Modifies the member body.
`abstract boolean` | `isEmpty()` Returns true if the body is empty.
`void` | `setAttribute(java.lang.String name, byte[] data)` Adds an attribute.
`void` | `setBody(java.lang.String src)` Sets a member body.
`void` | `setExceptionTypes(CtClass[] types)` Sets exceptions that this member may throw.
`void` | `setModifiers(int mod)` Sets the encoded modifiers of the member.
`void` | `useCflow(java.lang.String name)` Declares to use `$cflow` for this member; If `$cflow` is used, the class files modified with Javassist requires a support class `javassist.runtime.Cflow` at runtime (other Javassist classes are not required at runtime).

Methods inherited from class javassist.CtMember
`getDeclaringClass`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getMethodInfo

    public MethodInfo getMethodInfo()

  Returns the MethodInfo representing this member in the class file.

### getMethodInfo2

    public MethodInfo getMethodInfo2()

  Undocumented method. Do not use; internal-use only.

### getModifiers

    public int getModifiers()

  Obtains the modifiers of the member.

  Specified by:
    `getModifiers` in class `CtMember`
  Returns:
    modifiers encoded with `javassist.Modifier`.
  See Also:
    `Modifier`

### setModifiers

    public void setModifiers(int mod)

  Sets the encoded modifiers of the member.

  Specified by:
    `setModifiers` in class `CtMember`
  See Also:
    `Modifier`

### getName

    public abstract java.lang.String getName()

  Obtains the name of this member.

  Specified by:
    `getName` in class `CtMember`
  See Also:
    `CtConstructor.getName()`

### getParameterTypes

    public CtClass[] getParameterTypes()
                                throws NotFoundException

  Obtains parameter types of this member.

    `NotFoundException`

### getSignature

    public java.lang.String getSignature()

  Returns the character string representing the parameter types and the return type. If two members have the same parameter types and the return type, `getSignature()` returns the same string.

### getExceptionTypes

    public CtClass[] getExceptionTypes()
                                throws NotFoundException

  Obtains exceptions that this member may throw.

    `NotFoundException`

### setExceptionTypes

    public void setExceptionTypes(CtClass[] types)
                           throws NotFoundException

  Sets exceptions that this member may throw.

    `NotFoundException`

### isEmpty

    public abstract boolean isEmpty()

  Returns true if the body is empty.

### setBody

    public void setBody(java.lang.String src)
                 throws CannotCompileException

  Sets a member body.

  Parameters:
    `src` - the source code representing the member body. It must be a single statement or block. If it is `null`, the substituted member body does nothing except returning zero or null.
    `CannotCompileException`

### getAttribute

    public byte[] getAttribute(java.lang.String name)

  Obtains an attribute with the given name. If that attribute is not found in the class file, this method returns null.

  Specified by:
    `getAttribute` in class `CtMember`
  Parameters:
    `name` - attribute name

### setAttribute

    public void setAttribute(java.lang.String name,
                             byte[] data)

  Adds an attribute. The attribute is saved in the class file.

  Specified by:
    `setAttribute` in class `CtMember`
  Parameters:
    `name` - attribute name
    `data` - attribute value

### useCflow

    public void useCflow(java.lang.String name)
                  throws CannotCompileException

  Declares to use `$cflow` for this member; If `$cflow` is used, the class files modified with Javassist requires a support class `javassist.runtime.Cflow` at runtime (other Javassist classes are not required at runtime).

  Every `$cflow` variable is given a unique name. For example, if the given name is `"Point.paint"`, then the variable is indicated by `$cflow(Point.paint)`.

  Parameters:
    `name` - `$cflow` name. It can include alphabets, numbers, `_`, `$`, and `.` (dot).
    `CannotCompileException`
  See Also:
    `Cflow`

### instrument

    public void instrument(CodeConverter converter)
                    throws CannotCompileException

  Modifies the member body.

  Parameters:
    `converter` - specifies how to modify.
    `CannotCompileException`

### instrument

    public void instrument(ExprEditor editor)
                    throws CannotCompileException

  Modifies the member body.

  Parameters:
    `editor` - specifies how to modify.
    `CannotCompileException`

### insertBefore

    public void insertBefore(java.lang.String src)
                      throws CannotCompileException

  Inserts bytecode at the beginning of the body.

  Parameters:
    `src` - the source code representing the inserted bytecode. It must be a single statement or block.
    `CannotCompileException`

### insertAfter

    public void insertAfter(java.lang.String src)
                     throws CannotCompileException

  Inserts bytecode at the end of the body. The bytecode is inserted just before every return insturction. It is not executed when an exception is thrown.

  Parameters:
    `src` - the source code representing the inserted bytecode. It must be a single statement or block.
    `CannotCompileException`

### insertAfter

    public void insertAfter(java.lang.String src,
                            boolean asFinally)
                     throws CannotCompileException

  Inserts bytecode at the end of the body. The bytecode is inserted just before every return insturction.

  Parameters:
    `src` - the source code representing the inserted bytecode. It must be a single statement or block.
    `asFinally` - true if the inserted bytecode is executed not only when the control normally returns but also when an exception is thrown.
    `CannotCompileException`

### addCatch

    public void addCatch(java.lang.String src,
                         CtClass exceptionType)
                  throws CannotCompileException

  Adds a catch clause that handles an exception thrown in the body. The catch clause must end with a return or throw statement.

  Parameters:
    `src` - the source code representing the catch clause. It must be a single statement or block.
    `exceptionType` - the type of the exception handled by the catch clause.
    `CannotCompileException`

### addCatch

    public void addCatch(java.lang.String src,
                         CtClass exceptionType,
                         java.lang.String exceptionName)
                  throws CannotCompileException

  Adds a catch clause that handles an exception thrown in the body. The catch clause must end with a return or throw statement.

  Parameters:
    `src` - the source code representing the catch clause. It must be a single statement or block.
    `exceptionType` - the type of the exception handled by the catch clause.
    `exceptionName` - the name of the variable containing the caught exception, for example, `$e`.
    `CannotCompileException`

Overview | Package | Class | Use | Tree | Deprecated | Index
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Javassist, a Java-bytecode translator toolkit. Copyright (C) 1999-2003 Shigeru Chiba. All Rights Reserved.