package nl.tudelft.simulation.dsol.interpreter.operations; import java.io.DataInput; import java.io.IOException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import nl.tudelft.simulation.dsol.interpreter.Frame; import nl.tudelft.simulation.dsol.interpreter.Interpreter; import nl.tudelft.simulation.language.concurrent.Monitor; /** * The INVOKEVIRTUAL operation as defined in * http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc6.html . *
* (c) copyright 2002-2014 Delft University of Technology.
* BSD-style license. See DSOL License.
* @author Peter Jacobs
* @author Alexander Verbraeck
*/
public class INVOKEVIRTUAL extends nl.tudelft.simulation.dsol.interpreter.operations.reflection.INVOKEVIRTUAL
{
/**
* constructs a new INVOKEVIRTUAL.
* @param dataInput the dataInput
* @throws IOException on IOfailure
*/
public INVOKEVIRTUAL(final DataInput dataInput) throws IOException
{
super(dataInput);
}
/** {@inheritDoc} */
@Override
public final Frame execute(final Frame frame, final Object objectRef, final Method method, final Object[] arguments)
throws Exception
{
if (Modifier.isNative(method.getModifiers()))
{
return super.execute(frame, objectRef, method, arguments);
}
if (Modifier.isSynchronized(method.getModifiers()))
{
Monitor.lock(objectRef);
}
return Interpreter.createFrame(objectRef, method, arguments);
}
}