View Javadoc

    1   /*
    2    * @(#) PROCESSINVOKESTATIC.java Jan 8, 2004
    3    *
    4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
    5    * the Netherlands All rights reserved.
    6    *
    7    * This software is proprietary information of Delft University of Technology
    8    * The code is published under the General Public License
    9    */
    10  package nl.tudelft.simulation.dsol.formalisms.process;
    11
    12  import java.io.DataInput;
    13  import java.io.IOException;
    14  import java.lang.reflect.Method;
    15  import java.lang.reflect.Modifier;
    16
    17  import nl.tudelft.simulation.dsol.interpreter.Frame;
    18  import nl.tudelft.simulation.dsol.interpreter.Interpreter;
    19  import nl.tudelft.simulation.language.concurrent.Monitor;
    20
    21  /***
    22   * PROCESSINVOKESTATIC <br>
    23   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
    24   * University of Technology </a>, the Netherlands. <br>
    25   * See for project information <a
    26   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
    27   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
    28   * License (GPL) </a>, no warranty <br>
    29   *
    30   * @version 1.0 Jan 8, 2004 <br>
    31   * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
    32   *         Jacobs </a> <br>
    33   *         <a
    34   *         href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
    35   *         Verbraeck </a>
    36   */
    37  public class PROCESSINVOKESTATIC
    38  		extends
    39  		nl.tudelft.simulation.dsol.interpreter.operations.reflection.INVOKESTATIC
    40  {
    41  	/***
    42  	 * constructs a new PROCESSINVOKESTATIC
    43  	 *
    44  	 * @param dataInput the dataInput
    45  	 * @throws IOException on IOfailure
    46  	 */
    47  	public PROCESSINVOKESTATIC(final DataInput dataInput) throws IOException
    48  	{
    49  		super(dataInput);
    50  	}
    51
    52  	/***
    53  	 * executes the operation and returns a new Frame
    54  	 *
    55  	 * @param frame the original frame
    56  	 * @param objectRef the object on which to invoke the method
    57  	 * @param arguments the arguments with which to invoke the method
    58  	 * @param method the method to invoke
    59  	 * @throws Exception on invocation exception
    60  	 * @return a new frame
    61  	 */
    62  	public Frame execute(final Frame frame, final Object objectRef,
    63  			final Method method, final Object[] arguments) throws Exception
    64  	{
    65  		if (Modifier.isNative(method.getModifiers())
    66  				|| !Process.class.isAssignableFrom(objectRef.getClass()))
    67  		{
    68  			return super.execute(frame, objectRef, method, arguments);
    69  		}
    70  		if (Modifier.isSynchronized(method.getModifiers()))
    71  		{
    72  			Monitor.lock(objectRef);
    73  		}
    74  		return Interpreter.createFrame(objectRef, method, arguments);
    75  	}
    76  }