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

## javassist.reflect
Class ClassMetaobject

    java.lang.Object
      |
      +--javassist.reflect.ClassMetaobject

All Implemented Interfaces:
  java.io.Serializable

public class ClassMetaobject
extends java.lang.Object
implements java.io.Serializable

A runtime class metaobject.

A `ClassMetaobject` is created for every class of reflective objects. It can be used to hold values shared among the reflective objects of the same class.

See Also:
  `Metaobject`, Serialized Form

Field Summary
`static boolean` | `useContextClassLoader` Specifies how a `java.lang.Class` object is loaded.

Constructor Summary
`ClassMetaobject(java.lang.String[] params)` Constructs a `ClassMetaobject`.

Method Summary
`java.lang.Class` | `getJavaClass()` Obtains the `java.lang.Class` representing this class.
`java.lang.String` | `getMethodName(int identifier)` Returns the name of the method specified by `identifier`.
`java.lang.String` | `getName()` Obtains the name of this class.
`java.lang.Class[]` | `getParameterTypes(int identifier)` Returns an array of `Class` objects representing the formal parameter types of the method specified by `identifier`.
`java.lang.reflect.Method[]` | `getReflectiveMethods()` Returns an array of the methods defined on the given reflective object.
`java.lang.Class` | `getReturnType(int identifier)` Returns a `Class` objects representing the return type of the method specified by `identifier`.
`static java.lang.Object` | `invoke(java.lang.Object target, int identifier, java.lang.Object[] args)` Invokes a method whose name begins with `methodPrefix "_m_"` and the identifier.
`boolean` | `isInstance(java.lang.Object obj)` Returns true if `obj` is an instance of this class.
`java.lang.Object` | `newInstance(java.lang.Object[] args)` Creates a new instance of the class.
`java.lang.Object` | `trapFieldRead(java.lang.String name)` Is invoked when `static` fields of the base-level class are read and the runtime system intercepts it.
`void` | `trapFieldWrite(java.lang.String name, java.lang.Object value)` Is invoked when `static` fields of the base-level class are modified and the runtime system intercepts it.
`java.lang.Object` | `trapMethodcall(int identifier, java.lang.Object[] args)` Is invoked when `static` methods of the base-level class are called and the runtime system intercepts it.

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

Field Detail

### useContextClassLoader

    public static boolean useContextClassLoader

  Specifies how a `java.lang.Class` object is loaded.

  If true, it is loaded by:

      Thread.currentThread().getContextClassLoader().loadClass()

  If false, it is loaded by `Class.forName()`. The default value is false.

Constructor Detail

### ClassMetaobject

    public ClassMetaobject(java.lang.String[] params)

  Constructs a `ClassMetaobject`.

Parameters:
  `params` - `params[0]` is the name of the class of the reflective objects.

Method Detail

### getJavaClass

    public final java.lang.Class getJavaClass()

  Obtains the `java.lang.Class` representing this class.

### getName

    public final java.lang.String getName()

  Obtains the name of this class.

### isInstance

    public final boolean isInstance(java.lang.Object obj)

  Returns true if `obj` is an instance of this class.

### newInstance

    public final java.lang.Object newInstance(java.lang.Object[] args)
                                       throws CannotCreateException

  Creates a new instance of the class.

  Parameters:
    `args` - the arguments passed to the constructor.
    `CannotCreateException`

### trapFieldRead

    public java.lang.Object trapFieldRead(java.lang.String name)

  Is invoked when `static` fields of the base-level class are read and the runtime system intercepts it. This method simply returns the value of the field.

  Every subclass of this class should redefine this method.

### trapFieldWrite

    public void trapFieldWrite(java.lang.String name,
                               java.lang.Object value)

  Is invoked when `static` fields of the base-level class are modified and the runtime system intercepts it. This method simply sets the field to the given value.

  Every subclass of this class should redefine this method.

### invoke

    public static java.lang.Object invoke(java.lang.Object target,
                                          int identifier,
                                          java.lang.Object[] args)
                                   throws java.lang.Throwable

  Invokes a method whose name begins with `methodPrefix "_m_"` and the identifier.

  Throws:
    `CannotInvokeException` - if the invocation fails.
    `java.lang.Throwable`

### trapMethodcall

    public java.lang.Object trapMethodcall(int identifier,
                                           java.lang.Object[] args)
                                    throws java.lang.Throwable

  Is invoked when `static` methods of the base-level class are called and the runtime system intercepts it. This method simply executes the intercepted method invocation with the original parameters and returns the resulting value.

  Every subclass of this class should redefine this method.

    `java.lang.Throwable`

### getReflectiveMethods

    public final java.lang.reflect.Method[] getReflectiveMethods()

  Returns an array of the methods defined on the given reflective object. This method is for the internal use only.

### getMethodName

    public final java.lang.String getMethodName(int identifier)

  Returns the name of the method specified by `identifier`.

### getParameterTypes

    public final java.lang.Class[] getParameterTypes(int identifier)

  Returns an array of `Class` objects representing the formal parameter types of the method specified by `identifier`.

### getReturnType

    public final java.lang.Class getReturnType(int identifier)

  Returns a `Class` objects representing the return type of the method specified by `identifier`.

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.