View Javadoc

1   /*
2    * @(#) INVOKEINTERFACE.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.interpreter.operations;
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   * The INVOKEINTERFACE operation as defined in <a
23   * href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc6.html">
24   * http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc6.html
25   * </a>.
26   * <p>
27   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
28   * University of Technology </a>, the Netherlands. <br>
29   * See for project information <a
30   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
31   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
32   * License (GPL) </a>, no warranty <br>
33   * 
34   * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
35   *         Jacobs </a><a
36   *         href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
37   *         Verbraeck </a>
38   * @version 1.3 Apr 6, 2004
39   * @since 1.4
40   */
41  public class INVOKEINTERFACE
42  		extends
43  		nl.tudelft.simulation.dsol.interpreter.operations.reflection.INVOKEINTERFACE
44  {
45  	/***
46  	 * constructs a new INVOKEINTERFACE
47  	 * 
48  	 * @param dataInput the dataInput
49  	 * @throws IOException on IOfailure
50  	 */
51  	public INVOKEINTERFACE(final DataInput dataInput) throws IOException
52  	{
53  		super(dataInput);
54  	}
55  
56  	/***
57  	 * @see nl.tudelft.simulation.dsol.interpreter.operations.reflection.INVOKEINTERFACE
58  	 *      #execute(nl.tudelft.simulation.dsol.interpreter.Frame,
59  	 *      java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
60  	 */
61  	public Frame execute(final Frame frame, final Object objectRef,
62  			final Method method, final Object[] arguments) throws Exception
63  	{
64  		if (Modifier.isNative(method.getModifiers()))
65  		{
66  			return super.execute(frame, objectRef, method, arguments);
67  		}
68  		if (Modifier.isSynchronized(method.getModifiers()))
69  		{
70  			Monitor.lock(objectRef);
71  		}
72  		return Interpreter.createFrame(objectRef, method, arguments);
73  	}
74  
75  }