edu.rit.classfile
Class Reflection

java.lang.Object
  extended by edu.rit.classfile.Reflection

public class Reflection
extends Object

Class Reflection provides static convenience methods for using Java Reflection in conjunction with the RIT Classfile Library.


Method Summary
static ClassReference getClassReference(Class theClass)
          Returns a class reference for the given class.
static MethodReference getMethodReference(ClassReference theClass, Method theMethod)
          Returns a method reference for the given method.
static TypeReference getTypeReference(Class theClass)
          Returns a type reference for the given class.
static SynthesizedMethodDescription synthesizeMethod(SynthesizedClassDescription theClass, Method theMethod)
          Returns a synthesized method description for the given method in the given synthesized class description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTypeReference

public static TypeReference getTypeReference(Class theClass)
Returns a type reference for the given class.

Parameters:
theClass - Class; it may denote a non-primitive type (class, interface, or array), a primitive type, or void.
Returns:
Type reference for theClass. If theClass denotes void, null is returned.
Throws:
NullPointerException - (unchecked exception) Thrown if theClass is null.

getClassReference

public static ClassReference getClassReference(Class theClass)
Returns a class reference for the given class.

Parameters:
theClass - Class; it may only denote a class or interface.
Returns:
Class reference for theClass.
Throws:
NullPointerException - (unchecked exception) Thrown if theClass is null.
IllegalArgumentException - (unchecked exception) Thrown if theClass denotes an array, a primitive type, or void.

getMethodReference

public static MethodReference getMethodReference(ClassReference theClass,
                                                 Method theMethod)
                                          throws ListFullException
Returns a method reference for the given method. The method reference has the same name, return type, and argument types as the given method.

Parameters:
theClass - Class reference for the method's class or interface.
theMethod - Information about the method, obtained by reflection.
Returns:
Method reference.
Throws:
NullPointerException - (unchecked exception) Thrown if theClass is null or theMethod is null.
ListFullException - Thrown if theMethod has more than 254 arguments.

synthesizeMethod

public static SynthesizedMethodDescription synthesizeMethod(SynthesizedClassDescription theClass,
                                                            Method theMethod)
                                                     throws ListFullException
Returns a synthesized method description for the given method in the given synthesized class description. The synthesized method description has the same name, modes (except for abstract), return type, argument types, and thrown exceptions as the given method. The synthesized method description has no bytecode instructions, has max_stack = 0, and has max_locals = 0. The synthesized method description is always for a non-abstract method, even if the given method is abstract.

Parameters:
theClass - Synthesized class description to which to add the method.
theMethod - Information about the method to add, obtained by reflection.
Returns:
Synthesized method description.
Throws:
NullPointerException - (unchecked exception) Thrown if theClass is null or theMethod is null.
ListFullException - Thrown if theClass's subroutine list is full (i.e., contains 65535 subroutines).


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.