Jode 1.90-CVS
Build Aug 6, 2004

net.sf.jode.jvm
Interface RuntimeEnvironment

All Known Implementing Classes:
SimpleRuntimeEnvironment

public interface RuntimeEnvironment

This interface is used by the Interpreter to actually modify objects, invoke methods, etc.
The objects used in this runtime environment need not to be of the real type, but can be some other type of your choice. But some mappings must be preserved, since they are used inside the Interpreter:

Author:
Jochen Hoenicke
See Also:
SimpleRuntimeEnvironment

Method Summary
 void enterMonitor(java.lang.Object obj)
          Enter a monitor.
 void exitMonitor(java.lang.Object obj)
          Exit a monitor.
 java.lang.Object getField(Reference fieldref, 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 methodRef, java.lang.Object[] params)
          Create a new instance of an object.
 java.lang.Object invokeMethod(Reference methodRef, 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 fieldref, java.lang.Object obj, java.lang.Object value)
          Set the value of a field member.
 

Method Detail

getField

public java.lang.Object getField(Reference fieldref,
                                 java.lang.Object obj)
                          throws InterpreterException
Get the value of a field member.

Parameters:
fieldref - 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 fieldref,
                     java.lang.Object obj,
                     java.lang.Object value)
              throws InterpreterException
Set the value of a field member.

Parameters:
fieldref - 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.

invokeMethod

public java.lang.Object invokeMethod(Reference methodRef,
                                     boolean isVirtual,
                                     java.lang.Object cls,
                                     java.lang.Object[] params)
                              throws InterpreterException,
                                     java.lang.reflect.InvocationTargetException
Invoke a method.

Parameters:
methodRef - 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

invokeConstructor

public java.lang.Object invokeConstructor(Reference methodRef,
                                          java.lang.Object[] params)
                                   throws InterpreterException,
                                          java.lang.reflect.InvocationTargetException
Create a new instance of an object.

Parameters:
methodRef - the reference of the constructor to invoke
params - the params of the method.
Returns:
the new object.
Throws:
InterpreterException
java.lang.reflect.InvocationTargetException

instanceOf

public boolean instanceOf(java.lang.Object obj,
                          java.lang.String className)
                   throws InterpreterException
Check if obj is an instance of className

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
Create a new multidimensional Array.

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

enterMonitor

public void enterMonitor(java.lang.Object obj)
                  throws InterpreterException
Enter a monitor.

Parameters:
obj - the object whose monitor should be taken.
Throws:
InterpreterException

exitMonitor

public void exitMonitor(java.lang.Object obj)
                 throws InterpreterException
Exit a monitor.

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.