Jode 1.90-CVS
Build Aug 6, 2004

net.sf.jode.jvm
Class SimpleRuntimeEnvironment

java.lang.Object
  extended bynet.sf.jode.jvm.SimpleRuntimeEnvironment
All Implemented Interfaces:
RuntimeEnvironment
Direct Known Subclasses:
ConstantRuntimeEnvironment

public class SimpleRuntimeEnvironment
extends java.lang.Object
implements RuntimeEnvironment

This is a runtime environment using reflection. Monitors are not supported by this class so exit/enterMonitor will through an InterpreterException.


Constructor Summary
SimpleRuntimeEnvironment()
           
 
Method Summary
 void enterMonitor(java.lang.Object obj)
          Enter a monitor.
 void exitMonitor(java.lang.Object obj)
          Exit a monitor.
static java.lang.Object fromReflectType(java.lang.String typeSig, java.lang.Object value)
           
 java.lang.Object getField(Reference ref, java.lang.Object obj)
          Get the value of a field member.
 boolean instanceOf(java.lang.Object obj, java.lang.String className)
          Check if obj is an instance of className
 java.lang.Object invokeConstructor(Reference ref, java.lang.Object[] params)
          Create a new instance of an object.
 java.lang.Object invokeMethod(Reference ref, boolean isVirtual, java.lang.Object cls, java.lang.Object[] params)
          Invoke a method.
 java.lang.Object newArray(java.lang.String type, int[] dimensions)
          Create a new multidimensional Array.
 void putField(Reference ref, java.lang.Object obj, java.lang.Object value)
          Set the value of a field member.
static java.lang.Object toReflectType(java.lang.String typeSig, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleRuntimeEnvironment

public SimpleRuntimeEnvironment()
Method Detail

fromReflectType

public static java.lang.Object fromReflectType(java.lang.String typeSig,
                                               java.lang.Object value)

toReflectType

public static java.lang.Object toReflectType(java.lang.String typeSig,
                                             java.lang.Object value)

getField

public java.lang.Object getField(Reference ref,
                                 java.lang.Object obj)
                          throws InterpreterException
Description copied from interface: RuntimeEnvironment
Get the value of a field member.

Specified by:
getField in interface RuntimeEnvironment
Parameters:
ref - the Reference of the field.
obj - the object of which the field should be taken, null if the field is static.
Returns:
the field value. Primitive types are wrapped to Object.
Throws:
InterpreterException - if the field does not exists, the object is not supported etc.

putField

public void putField(Reference ref,
                     java.lang.Object obj,
                     java.lang.Object value)
              throws InterpreterException
Description copied from interface: RuntimeEnvironment
Set the value of a field member.

Specified by:
putField in interface RuntimeEnvironment
Parameters:
ref - the Reference of the field.
obj - the object of which the field should be taken, null if the field is static.
value - the field value. Primitive types are wrapped to Object.
Throws:
InterpreterException - if the field does not exists, the object is not supported etc.

invokeConstructor

public java.lang.Object invokeConstructor(Reference ref,
                                          java.lang.Object[] params)
                                   throws InterpreterException,
                                          java.lang.reflect.InvocationTargetException
Description copied from interface: RuntimeEnvironment
Create a new instance of an object.

Specified by:
invokeConstructor in interface RuntimeEnvironment
Parameters:
ref - the reference of the constructor to invoke
params - the params of the method.
Returns:
the new object.
Throws:
InterpreterException
java.lang.reflect.InvocationTargetException

invokeMethod

public java.lang.Object invokeMethod(Reference ref,
                                     boolean isVirtual,
                                     java.lang.Object cls,
                                     java.lang.Object[] params)
                              throws InterpreterException,
                                     java.lang.reflect.InvocationTargetException
Description copied from interface: RuntimeEnvironment
Invoke a method.

Specified by:
invokeMethod in interface RuntimeEnvironment
Parameters:
ref - the reference to the method.
isVirtual - true, iff the call is virtual
cls - the object on which the method should be called, null if the method is static.
params - the params of the method.
Returns:
the return value of the method. Void type is ignored, may be null.
Throws:
InterpreterException - if the field does not exists, the object is not supported etc.
java.lang.reflect.InvocationTargetException

instanceOf

public boolean instanceOf(java.lang.Object obj,
                          java.lang.String className)
                   throws InterpreterException
Description copied from interface: RuntimeEnvironment
Check if obj is an instance of className

Specified by:
instanceOf in interface RuntimeEnvironment
Parameters:
className - the type signature of the class.
Returns:
true, if obj is an instance of className, false otherwise.
Throws:
InterpreterException

newArray

public java.lang.Object newArray(java.lang.String type,
                                 int[] dimensions)
                          throws InterpreterException,
                                 java.lang.NegativeArraySizeException
Description copied from interface: RuntimeEnvironment
Create a new multidimensional Array.

Specified by:
newArray in interface RuntimeEnvironment
Parameters:
type - the type of the elements.
dimensions - the size in every dimension.
Returns:
the new array (this must be an array, see class comment).
Throws:
InterpreterException
java.lang.NegativeArraySizeException

enterMonitor

public void enterMonitor(java.lang.Object obj)
                  throws InterpreterException
Description copied from interface: RuntimeEnvironment
Enter a monitor.

Specified by:
enterMonitor in interface RuntimeEnvironment
Parameters:
obj - the object whose monitor should be taken.
Throws:
InterpreterException

exitMonitor

public void exitMonitor(java.lang.Object obj)
                 throws InterpreterException
Description copied from interface: RuntimeEnvironment
Exit a monitor.

Specified by:
exitMonitor in interface RuntimeEnvironment
Parameters:
obj - the object whose monitor should be freed.
Throws:
InterpreterException

Jode 1.90-CVS
Build Aug 6, 2004

Copyright © 1998-2004 by Jochen Hoenicke.