package nl.tudelft.simulation.dsol.interpreter.operations.custom; 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 CUSTOMINVOKESTATIC operation as defined in * * https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5 . *
* Copyright (c) 2002-2022 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See * for project information https://simulation.tudelft.nl. The DSOL * project is distributed under a three-clause BSD-style license, which can be found at * * https://simulation.tudelft.nl/dsol/3.0/license.html. *
* @author Peter Jacobs * @author Alexander Verbraeck */ public class CUSTOMINVOKESTATIC extends nl.tudelft.simulation.dsol.interpreter.operations.reflection.INVOKESTATIC { /** the interpreterOracle to use. */ private final InterpreterOracleInterface interpreterOracle; /** * constructs a new CUSTOMINVOKESTATIC. * @param interpreterOracle InterpreterOracleInterface; the interpreterOracle to use * @param dataInput DataInput; the dataInput * @throws IOException on IOfailure */ public CUSTOMINVOKESTATIC(final InterpreterOracleInterface interpreterOracle, final DataInput dataInput) throws IOException { super(dataInput); this.interpreterOracle = interpreterOracle; } /** {@inheritDoc} */ @Override public Frame execute(final Frame frame, final Object objectRef, final Method method, final Object[] arguments) throws Exception { if (!this.interpreterOracle.shouldBeInterpreted(method) || 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); } }