diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java index b1f9188e7127..1d8ceb6a7c65 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java @@ -631,6 +631,17 @@ public static void updateMaxJavaStackTraceDepth(EconomicMap, Object @Option(help = "JNI functions will return more specific error codes.", type = OptionType.User)// public static final HostedOptionKey JNIEnhancedErrorCodes = new HostedOptionKey<>(false); + @Option(help = "Enable JVM Tool Interface (JVMTI) support.", type = OptionType.User)// + public static final HostedOptionKey JVMTI = new HostedOptionKey<>(false); + + @Option(help = "Loads the specified native agent library. " + + "After the library name, a comma-separated list of options specific to the library can be used.", type = OptionType.User)// + public static final RuntimeOptionKey JVMTIAgentLib = new RuntimeOptionKey<>(null); + + @Option(help = "Loads the specified native agent library specified by the absolute path name. " + + "After the library path, a comma-separated list of options specific to the library can be used.", type = OptionType.User)// + public static final RuntimeOptionKey JVMTIAgentPath = new RuntimeOptionKey<>(null); + @Option(help = "Alignment of AOT and JIT compiled code in bytes.")// public static final HostedOptionKey CodeAlignment = new HostedOptionKey<>(16); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibraries.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibraries.java index 1ca906d0d49f..5daa87344382 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibraries.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibraries.java @@ -68,7 +68,7 @@ protected static PointerBase findSymbol(Collection agents = new ArrayList<>(); + + @Platforms(Platform.HOSTED_ONLY.class) + public JvmtiAgents() { + } + + @Fold + public static JvmtiAgents singleton() { + return ImageSingletons.lookup(JvmtiAgents.class); + } + + public void load() { + String agentLib = SubstrateOptions.JVMTIAgentLib.getValue(); + if (agentLib != null) { + loadAgent(agentLib, true); + } + + String agentPath = SubstrateOptions.JVMTIAgentPath.getValue(); + if (agentPath != null) { + loadAgent(agentPath, false); + } + } + + public void unload() { + for (NativeLibrary lib : agents) { + PointerBase function = lib.findSymbol(AGENT_ON_UNLOAD); + if (function.isNonNull()) { + callOnUnLoadFunction(function); + } + } + agents.clear(); + } + + private void loadAgent(String agentAndOptions, boolean relative) { + if (!agents.isEmpty()) { + throw new AgentInitException("Only a single agent is supported at the moment."); + } + + try { + loadAgent0(agentAndOptions, relative); + } catch (AgentInitException e) { + Log.log().string(e.getMessage()).newline(); + if (!SubstrateOptions.SharedLibrary.getValue()) { + System.exit(1); + } + } + } + + private void loadAgent0(String agentAndOptions, boolean relative) { + String[] values = StringUtil.split(agentAndOptions, "=", 2); + String agent = values[0]; + String options = values.length > 1 ? values[1] : null; + + String agentFile = getAgentFile(agent, relative); + NativeLibrary lib = PlatformNativeLibrarySupport.singleton().createLibrary(agentFile, false); + if (!lib.load()) { + throw new AgentInitException("Could not load agent library '" + agentFile + "'."); + } + + PointerBase function = lib.findSymbol(AGENT_ON_LOAD); + if (function.isNull()) { + throw new AgentInitException("Could not find Agent_OnLoad function in agent library '" + agentFile + "'."); + } + + if (!callOnLoadFunction(function, options)) { + throw new AgentInitException("Initialization of agent library '" + agentFile + "' failed."); + } + agents.add(lib); + } + + private static String getAgentFile(String agent, boolean relative) { + File file; + if (relative) { + String sysPath = NativeLibrarySupport.getImageDirectory(); + String libname = System.mapLibraryName(agent); + file = new File(sysPath, libname); + if (!file.exists()) { + throw new AgentInitException("Could not find agent library '" + agent + "' on the library path."); + } + } else { + file = new File(agent); + if (!file.exists()) { + throw new AgentInitException("Could not find agent library '" + agent + "'."); + } + } + + try { + return file.getCanonicalPath(); + } catch (IOException e) { + throw new AgentInitException("Path of agent library '" + agent + "' is invalid: " + e.getMessage()); + } + } + + private static boolean callOnLoadFunction(PointerBase function, String options) { + JvmtiOnLoadFunctionPointer onLoad = (JvmtiOnLoadFunctionPointer) function; + try (CTypeConversion.CCharPointerHolder holder = CTypeConversion.toCString(options)) { + int result = onLoad.invoke(JNIFunctionTables.singleton().getGlobalJavaVM(), holder.get(), WordFactory.nullPointer()); + /* Any value other than 0 is an error. */ + return result == 0; + } + } + + private static void callOnUnLoadFunction(PointerBase function) { + JvmtiOnUnLoadFunctionPointer onLoad = (JvmtiOnUnLoadFunctionPointer) function; + onLoad.invoke(JNIFunctionTables.singleton().getGlobalJavaVM(), WordFactory.nullPointer()); + } + + private static class AgentInitException extends RuntimeException { + @Serial private static final long serialVersionUID = 3111979452718981714L; + + AgentInitException(String message) { + super(message); + } + } +} + +interface JvmtiOnLoadFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + int invoke(JNIJavaVM vm, CCharPointer options, VoidPointer reserved); +} + +interface JvmtiOnUnLoadFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JNIJavaVM vm, VoidPointer reserved); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiCapabilitiesUtil.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiCapabilitiesUtil.java new file mode 100644 index 000000000000..ba148168cac2 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiCapabilitiesUtil.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti; + +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; +import org.graalvm.nativeimage.c.struct.SizeOf; +import org.graalvm.word.Pointer; + +import com.oracle.svm.core.UnmanagedMemoryUtil; +import com.oracle.svm.core.jvmti.headers.JvmtiCapabilities; + +/** Methods related to {@link JvmtiCapabilities}. */ +public final class JvmtiCapabilitiesUtil { + @Platforms(Platform.HOSTED_ONLY.class) + private JvmtiCapabilitiesUtil() { + } + + public static boolean hasAny(JvmtiCapabilities capabilities) { + assert capabilities.isNonNull(); + + Pointer rawData = (Pointer) capabilities; + for (int i = 0; i < SizeOf.get(JvmtiCapabilities.class); i++) { + if (rawData.readByte(i) != 0) { + return true; + } + } + return false; + } + + public static void clear(JvmtiCapabilities capabilities) { + assert capabilities.isNonNull(); + UnmanagedMemoryUtil.fill((Pointer) capabilities, SizeOf.unsigned(JvmtiCapabilities.class), (byte) 0); + } + + public static void copy(JvmtiCapabilities src, JvmtiCapabilities dst) { + UnmanagedMemoryUtil.copyForward((Pointer) src, (Pointer) dst, SizeOf.unsigned(JvmtiCapabilities.class)); + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnv.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnv.java new file mode 100644 index 000000000000..8e1fb4174127 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnv.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti; + +import org.graalvm.nativeimage.Isolate; +import org.graalvm.nativeimage.c.struct.RawField; +import org.graalvm.nativeimage.c.struct.RawStructure; +import org.graalvm.word.PointerBase; + +/** + * Stores information about a JVMTI environment. JVMTI environments and their lifecycle are managed + * by {@link JvmtiEnvs}. + */ +@RawStructure +public interface JvmtiEnv extends PointerBase { + @RawField + Isolate getIsolate(); + + @RawField + void setIsolate(Isolate value); + + @RawField + int getMagic(); + + @RawField + void setMagic(int value); + + @RawField + JvmtiEnv getNext(); + + @RawField + void setNext(JvmtiEnv env); + + @RawField + long getEventUserEnabled(); + + @RawField + void setEventUserEnabled(long userEnabled); + + // The annotation-based fields above are incomplete because we directly embed other structures + // into this raw struct, see below: + // + // Internal data + // ------------- + // JvmtiCapabilities capabilities; + // JvmtiEventCallbacks callbacks; + // + // Externally visible data (must be at the end of this struct) + // ----------------------------------------------------------- + // JvmtiExternalEnv externalEnv; +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvUtil.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvUtil.java new file mode 100644 index 000000000000..835c93cd17aa --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvUtil.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti; + +import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_NONE; +import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_NOT_AVAILABLE; + +import org.graalvm.nativeimage.CurrentIsolate; +import org.graalvm.nativeimage.Isolate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; +import org.graalvm.nativeimage.c.struct.SizeOf; +import org.graalvm.word.Pointer; +import org.graalvm.word.PointerBase; +import org.graalvm.word.WordFactory; + +import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.config.ConfigurationValues; +import com.oracle.svm.core.jvmti.headers.JvmtiCapabilities; +import com.oracle.svm.core.jvmti.headers.JvmtiError; +import com.oracle.svm.core.jvmti.headers.JvmtiEvent; +import com.oracle.svm.core.jvmti.headers.JvmtiEventCallbacks; +import com.oracle.svm.core.jvmti.headers.JvmtiExternalEnv; +import com.oracle.svm.core.jvmti.headers.JvmtiInterface; +import com.oracle.svm.core.memory.NullableNativeMemory; +import com.oracle.svm.core.nmt.NmtCategory; + +import jdk.graal.compiler.api.replacements.Fold; +import jdk.graal.compiler.core.common.NumUtil; + +/** Methods related to {@link JvmtiEnv}. */ +public final class JvmtiEnvUtil { + private static final int VALID_ENV_MAGIC = 0x71EE; + private static final int DISPOSED_ENV_MAGIC = 0xDEFC; + + @Platforms(Platform.HOSTED_ONLY.class) + private JvmtiEnvUtil() { + } + + static JvmtiEnv allocate() { + JvmtiInterface functionTable = JvmtiFunctionTable.allocateFunctionTable(); + if (functionTable.isNull()) { + return WordFactory.nullPointer(); + } + + JvmtiEnv env = NullableNativeMemory.calloc(WordFactory.unsigned(internalEnvSize()), NmtCategory.JVMTI); + if (env.isNull()) { + JvmtiFunctionTable.freeFunctionTable(functionTable); + return WordFactory.nullPointer(); + } + + env.setIsolate(CurrentIsolate.getIsolate()); + env.setMagic(VALID_ENV_MAGIC); + + JvmtiExternalEnv externalEnv = toExternal(env); + externalEnv.setFunctions(functionTable); + return env; + } + + static void dispose(JvmtiEnv env) { + JvmtiCapabilities capabilities = getCapabilities(env); + relinquishCapabilities(capabilities); + + env.setMagic(DISPOSED_ENV_MAGIC); + } + + static void free(JvmtiEnv env) { + JvmtiExternalEnv externalEnv = toExternal(env); + JvmtiFunctionTable.freeFunctionTable(externalEnv.getFunctions()); + externalEnv.setFunctions(WordFactory.nullPointer()); + + NullableNativeMemory.free(env); + } + + @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) + public static JvmtiEnv toInternal(JvmtiExternalEnv externalEnv) { + assert externalEnv.isNonNull(); + return (JvmtiEnv) ((Pointer) externalEnv).subtract(externalEnvOffset()); + } + + public static JvmtiExternalEnv toExternal(JvmtiEnv env) { + assert env.isNonNull(); + return (JvmtiExternalEnv) ((Pointer) env).add(externalEnvOffset()); + } + + @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) + public static boolean isValid(JvmtiEnv env) { + assert env.isNonNull(); + return env.getMagic() == VALID_ENV_MAGIC; + } + + public static boolean isDead(JvmtiEnv env) { + return env.getMagic() == DISPOSED_ENV_MAGIC; + } + + @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) + public static Isolate getIsolate(JvmtiEnv env) { + assert isValid(env); + return env.getIsolate(); + } + + public static JvmtiCapabilities getCapabilities(JvmtiEnv env) { + assert isValid(env); + return addOffset(env, capabilitiesOffset()); + } + + public static JvmtiError addCapabilities(JvmtiCapabilities capabilities) { + assert capabilities.isNonNull(); + /* We don't support any capabilities at the moment. */ + if (JvmtiCapabilitiesUtil.hasAny(capabilities)) { + return JVMTI_ERROR_NOT_AVAILABLE; + } + return JVMTI_ERROR_NONE; + } + + public static JvmtiError relinquishCapabilities(JvmtiCapabilities capabilities) { + assert capabilities.isNonNull(); + /* Nothing to do because we don't support any capabilities at the moment. */ + return JVMTI_ERROR_NONE; + } + + static JvmtiEventCallbacks getEventCallbacks(JvmtiEnv env) { + assert isValid(env); + return addOffset(env, eventCallbacksOffset()); + } + + public static void setEventCallbacks(JvmtiEnv env, JvmtiEventCallbacks newCallbacks, int sizeOfCallbacks) { + JvmtiEventCallbacks eventCallbacks = getEventCallbacks(env); + JvmtiEventCallbacksUtil.setEventCallbacks(eventCallbacks, newCallbacks, sizeOfCallbacks); + } + + public static boolean hasEventCapability() { + /* At the moment, we only support events that don't need any specific capabilities. */ + return true; + } + + public static void setEventUserEnabled(JvmtiEnv env, Thread javaEventThread, JvmtiEvent eventType, boolean value) { + assert javaEventThread == null : "thread-local events are not supported at the moment"; + + long enabledBits = env.getEventUserEnabled(); + long bit = JvmtiEvent.getBit(eventType); + if (value) { + enabledBits |= bit; + } else { + enabledBits &= ~bit; + } + env.setEventUserEnabled(enabledBits); + } + + public static boolean isEventEnabled(JvmtiEnv env, JvmtiEvent eventType) { + /* At the moment, this only checks if an event is user-enabled. */ + return (env.getEventUserEnabled() & JvmtiEvent.getBit(eventType)) != 0; + } + + @SuppressWarnings("unchecked") + private static T addOffset(JvmtiEnv env, int offset) { + return (T) ((Pointer) env).add(offset); + } + + @Fold + static int capabilitiesOffset() { + return NumUtil.roundUp(SizeOf.get(JvmtiEnv.class), ConfigurationValues.getTarget().wordSize); + } + + @Fold + static int eventCallbacksOffset() { + return NumUtil.roundUp(capabilitiesOffset() + SizeOf.get(JvmtiCapabilities.class), ConfigurationValues.getTarget().wordSize); + } + + @Fold + static int externalEnvOffset() { + return NumUtil.roundUp(eventCallbacksOffset() + SizeOf.get(JvmtiEventCallbacks.class), ConfigurationValues.getTarget().wordSize); + } + + @Fold + static int internalEnvSize() { + return externalEnvOffset() + SizeOf.get(JvmtiExternalEnv.class); + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvs.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvs.java new file mode 100644 index 000000000000..65678fb6d34e --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEnvs.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti; + +import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; +import org.graalvm.word.WordFactory; + +import com.oracle.svm.core.jvmti.headers.JvmtiExternalEnv; +import com.oracle.svm.core.locks.VMMutex; + +import jdk.graal.compiler.api.replacements.Fold; + +/** + * Stores information about all currently existing JVMTI environments and manages their lifecycle. + */ +public final class JvmtiEnvs { + private final VMMutex mutex = new VMMutex("jvmtiEnvManager"); + + private JvmtiEnv headEnv; + private JvmtiEnv tailEnv; + + private int threadsIteratingEnvs; + private boolean hasDisposedEnvs; + + @Platforms(Platform.HOSTED_ONLY.class) + public JvmtiEnvs() { + } + + @Fold + public static JvmtiEnvs singleton() { + return ImageSingletons.lookup(JvmtiEnvs.class); + } + + public JvmtiEnv getHead() { + return headEnv; + } + + public JvmtiExternalEnv create() { + JvmtiEnv env = JvmtiEnvUtil.allocate(); + if (env.isNull()) { + return WordFactory.nullPointer(); + } + + mutex.lock(); + try { + if (headEnv.isNull()) { + headEnv = env; + } else { + tailEnv.setNext(env); + } + tailEnv = env; + assert env.getNext().isNull(); + return JvmtiEnvUtil.toExternal(env); + } finally { + mutex.unlock(); + } + } + + public void dispose(JvmtiEnv env) { + mutex.lock(); + try { + JvmtiEnvUtil.dispose(env); + hasDisposedEnvs = true; + } finally { + mutex.unlock(); + } + } + + public void enterEnvIteration() { + mutex.lock(); + try { + threadsIteratingEnvs++; + } finally { + mutex.unlock(); + } + } + + public void leaveEnvIteration() { + mutex.lock(); + try { + int remainingThreads = threadsIteratingEnvs--; + assert remainingThreads >= 0; + if (remainingThreads == 0 && hasDisposedEnvs) { + cleanup(); + } + } finally { + mutex.unlock(); + } + } + + private void cleanup() { + assert mutex.isOwner(); + assert hasDisposedEnvs; + + JvmtiEnv cur = headEnv; + JvmtiEnv prev = WordFactory.nullPointer(); + while (cur.isNonNull()) { + if (JvmtiEnvUtil.isDead(cur)) { + remove(cur, prev); + JvmtiEnvUtil.free(cur); + } + + prev = cur; + cur = cur.getNext(); + } + + hasDisposedEnvs = false; + } + + private void remove(JvmtiEnv cur, JvmtiEnv prev) { + assert mutex.isOwner(); + if (prev.isNull()) { + headEnv = cur.getNext(); + } else { + prev.setNext(cur.getNext()); + } + + if (tailEnv == cur) { + tailEnv = prev; + } + cur.setNext(null); + } + + public void teardown() { + JvmtiEnv cur = headEnv; + while (cur.isNonNull()) { + JvmtiEnv next = cur.getNext(); + JvmtiEnvUtil.free(cur); + cur = next; + } + + headEnv = WordFactory.nullPointer(); + tailEnv = WordFactory.nullPointer(); + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEventCallbacksUtil.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEventCallbacksUtil.java new file mode 100644 index 000000000000..bfadc921eafc --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEventCallbacksUtil.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti; + +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; +import org.graalvm.nativeimage.c.struct.SizeOf; +import org.graalvm.word.Pointer; +import org.graalvm.word.WordFactory; + +import com.oracle.svm.core.UnmanagedMemoryUtil; +import com.oracle.svm.core.jdk.UninterruptibleUtils; +import com.oracle.svm.core.jvmti.headers.JvmtiEventCallbacks; + +/** Methods related to {@link JvmtiEventCallbacks}. */ +public final class JvmtiEventCallbacksUtil { + @Platforms(Platform.HOSTED_ONLY.class) + private JvmtiEventCallbacksUtil() { + } + + public static void setEventCallbacks(JvmtiEventCallbacks envEventCallbacks, JvmtiEventCallbacks newCallbacks, int sizeOfCallbacks) { + int internalStructSize = SizeOf.get(JvmtiEventCallbacks.class); + UnmanagedMemoryUtil.fill((Pointer) envEventCallbacks, WordFactory.unsigned(internalStructSize), (byte) 0); + + if (newCallbacks.isNonNull()) { + int bytesToCopy = UninterruptibleUtils.Math.min(internalStructSize, sizeOfCallbacks); + UnmanagedMemoryUtil.copy((Pointer) newCallbacks, (Pointer) envEventCallbacks, WordFactory.unsigned(bytesToCopy)); + } + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEvents.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEvents.java new file mode 100644 index 000000000000..d53718662365 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiEvents.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti; + +import com.oracle.svm.core.jni.JNIObjectHandles; +import com.oracle.svm.core.jni.JNIThreadLocalEnvironment; +import com.oracle.svm.core.jvmti.headers.JThread; +import com.oracle.svm.core.jvmti.headers.JvmtiEvent; +import com.oracle.svm.core.jvmti.headers.JvmtiEventCallbacks.JvmtiEventVMDeathFunctionPointer; +import com.oracle.svm.core.jvmti.headers.JvmtiEventCallbacks.JvmtiEventVMInitFunctionPointer; +import com.oracle.svm.core.jvmti.headers.JvmtiEventCallbacks.JvmtiEventVMStartFunctionPointer; + +/** The methods in this class can be used to trigger JVMTI events. */ +public final class JvmtiEvents { + public static void postVMInit() { + JvmtiEnvs manager = JvmtiEnvs.singleton(); + manager.enterEnvIteration(); + try { + for (JvmtiEnv cur = manager.getHead(); cur.isNonNull(); cur = cur.getNext()) { + if (JvmtiEnvUtil.isEventEnabled(cur, JvmtiEvent.JVMTI_EVENT_VM_INIT)) { + JvmtiEventVMInitFunctionPointer callback = JvmtiEnvUtil.getEventCallbacks(cur).getVMInit(); + if (callback.isNonNull()) { + JThread currentThread = (JThread) JNIObjectHandles.createLocal(Thread.currentThread()); + try { + callback.invoke(JvmtiEnvUtil.toExternal(cur), JNIThreadLocalEnvironment.getAddress(), currentThread); + } finally { + JNIObjectHandles.deleteLocalRef(currentThread); + } + } + } + } + } finally { + manager.leaveEnvIteration(); + } + } + + public static void postVMStart() { + JvmtiEnvs manager = JvmtiEnvs.singleton(); + manager.enterEnvIteration(); + try { + for (JvmtiEnv cur = manager.getHead(); cur.isNonNull(); cur = cur.getNext()) { + if (JvmtiEnvUtil.isEventEnabled(cur, JvmtiEvent.JVMTI_EVENT_VM_START)) { + JvmtiEventVMStartFunctionPointer callback = JvmtiEnvUtil.getEventCallbacks(cur).getVMStart(); + if (callback.isNonNull()) { + callback.invoke(JvmtiEnvUtil.toExternal(cur), JNIThreadLocalEnvironment.getAddress()); + } + } + } + } finally { + manager.leaveEnvIteration(); + } + } + + public static void postVMDeath() { + JvmtiEnvs manager = JvmtiEnvs.singleton(); + manager.enterEnvIteration(); + try { + for (JvmtiEnv cur = manager.getHead(); cur.isNonNull(); cur = cur.getNext()) { + if (JvmtiEnvUtil.isEventEnabled(cur, JvmtiEvent.JVMTI_EVENT_VM_DEATH)) { + JvmtiEventVMDeathFunctionPointer callback = JvmtiEnvUtil.getEventCallbacks(cur).getVMDeath(); + if (callback.isNonNull()) { + callback.invoke(JvmtiEnvUtil.toExternal(cur), JNIThreadLocalEnvironment.getAddress()); + } + } + } + } finally { + manager.leaveEnvIteration(); + } + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiFunctionTable.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiFunctionTable.java new file mode 100644 index 000000000000..90d57ccc53d2 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiFunctionTable.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti; + +import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; +import org.graalvm.nativeimage.c.function.CFunctionPointer; +import org.graalvm.nativeimage.c.struct.SizeOf; +import org.graalvm.word.Pointer; +import org.graalvm.word.UnsignedWord; + +import com.oracle.svm.core.UnmanagedMemoryUtil; +import com.oracle.svm.core.c.NonmovableArray; +import com.oracle.svm.core.c.NonmovableArrays; +import com.oracle.svm.core.config.ConfigurationValues; +import com.oracle.svm.core.jvmti.headers.JvmtiInterface; +import com.oracle.svm.core.memory.NullableNativeMemory; +import com.oracle.svm.core.nmt.NmtCategory; + +import jdk.graal.compiler.api.replacements.Fold; + +public final class JvmtiFunctionTable { + /** + * A table with function pointers to all JVMTI entry points (see {@link JvmtiFunctions}). This + * table is filled at image-build-time. + */ + private final CFunctionPointer[] readOnlyFunctionTable; + + @Platforms(Platform.HOSTED_ONLY.class) + public JvmtiFunctionTable() { + int length = bytesToWords(SizeOf.get(JvmtiInterface.class)); + readOnlyFunctionTable = new CFunctionPointer[length]; + } + + @Fold + public static JvmtiFunctionTable singleton() { + return ImageSingletons.lookup(JvmtiFunctionTable.class); + } + + @Platforms(Platform.HOSTED_ONLY.class) + public void init(int offsetInBytes, CFunctionPointer functionPointer) { + int index = bytesToWords(offsetInBytes); + readOnlyFunctionTable[index] = functionPointer; + } + + @Platforms(Platform.HOSTED_ONLY.class) + private static int bytesToWords(int bytes) { + assert bytes % ConfigurationValues.getTarget().wordSize == 0; + return bytes / ConfigurationValues.getTarget().wordSize; + } + + @Platforms(Platform.HOSTED_ONLY.class) + public CFunctionPointer[] getReadOnlyFunctionTable() { + return readOnlyFunctionTable; + } + + public static JvmtiInterface allocateFunctionTable() { + UnsignedWord size = SizeOf.unsigned(JvmtiInterface.class); + JvmtiInterface result = NullableNativeMemory.malloc(size, NmtCategory.JVMTI); + if (result.isNonNull()) { + NonmovableArray readOnlyData = NonmovableArrays.fromImageHeap(singleton().readOnlyFunctionTable); + assert size.equal(NonmovableArrays.lengthOf(readOnlyData) * ConfigurationValues.getTarget().wordSize); + UnmanagedMemoryUtil.copyForward(NonmovableArrays.getArrayBase(readOnlyData), (Pointer) result, size); + } + return result; + } + + public static void freeFunctionTable(JvmtiInterface table) { + NullableNativeMemory.free(table); + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiFunctions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiFunctions.java new file mode 100644 index 000000000000..a06baf29a457 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiFunctions.java @@ -0,0 +1,1423 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti; + +import static com.oracle.svm.core.heap.RestrictHeapAccess.Access.NO_ALLOCATION; +import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_ACCESS_DENIED; +import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_ILLEGAL_ARGUMENT; +import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_INVALID_EVENT_TYPE; +import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_MUST_POSSESS_CAPABILITY; +import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_NONE; +import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_NULL_POINTER; +import static com.oracle.svm.core.jvmti.headers.JvmtiError.JVMTI_ERROR_OUT_OF_MEMORY; + +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; +import org.graalvm.nativeimage.c.function.CEntryPoint; +import org.graalvm.nativeimage.c.function.CFunctionPointer; +import org.graalvm.nativeimage.c.struct.CPointerTo; +import org.graalvm.nativeimage.c.type.CCharPointer; +import org.graalvm.nativeimage.c.type.CCharPointerPointer; +import org.graalvm.nativeimage.c.type.CConst; +import org.graalvm.nativeimage.c.type.CDoublePointer; +import org.graalvm.nativeimage.c.type.CFloatPointer; +import org.graalvm.nativeimage.c.type.CIntPointer; +import org.graalvm.nativeimage.c.type.CLongPointer; +import org.graalvm.nativeimage.c.type.VoidPointer; +import org.graalvm.word.Pointer; +import org.graalvm.word.PointerBase; +import org.graalvm.word.UnsignedWord; +import org.graalvm.word.WordFactory; + +import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.c.function.CEntryPointActions; +import com.oracle.svm.core.c.function.CEntryPointErrors; +import com.oracle.svm.core.c.function.CEntryPointOptions; +import com.oracle.svm.core.heap.GCCause; +import com.oracle.svm.core.heap.Heap; +import com.oracle.svm.core.heap.RestrictHeapAccess; +import com.oracle.svm.core.jdk.UninterruptibleUtils; +import com.oracle.svm.core.jni.JNIObjectHandles; +import com.oracle.svm.core.jni.headers.JNIFieldId; +import com.oracle.svm.core.jni.headers.JNIFieldIdPointerPointer; +import com.oracle.svm.core.jni.headers.JNIMethodId; +import com.oracle.svm.core.jni.headers.JNIMethodIdPointer; +import com.oracle.svm.core.jni.headers.JNIMethodIdPointerPointer; +import com.oracle.svm.core.jni.headers.JNINativeInterface; +import com.oracle.svm.core.jni.headers.JNINativeInterfacePointer; +import com.oracle.svm.core.jni.headers.JNIObjectHandle; +import com.oracle.svm.core.jvmti.headers.BooleanPointer; +import com.oracle.svm.core.jvmti.headers.JClass; +import com.oracle.svm.core.jvmti.headers.JClassPointer; +import com.oracle.svm.core.jvmti.headers.JClassPointerPointer; +import com.oracle.svm.core.jvmti.headers.JNIObjectHandlePointer; +import com.oracle.svm.core.jvmti.headers.JNIObjectHandlePointerPointer; +import com.oracle.svm.core.jvmti.headers.JRawMonitorId; +import com.oracle.svm.core.jvmti.headers.JRawMonitorIdPointer; +import com.oracle.svm.core.jvmti.headers.JThread; +import com.oracle.svm.core.jvmti.headers.JThreadGroup; +import com.oracle.svm.core.jvmti.headers.JThreadGroupPointer; +import com.oracle.svm.core.jvmti.headers.JThreadPointer; +import com.oracle.svm.core.jvmti.headers.JThreadPointerPointer; +import com.oracle.svm.core.jvmti.headers.JvmtiCapabilities; +import com.oracle.svm.core.jvmti.headers.JvmtiClassDefinition; +import com.oracle.svm.core.jvmti.headers.JvmtiError; +import com.oracle.svm.core.jvmti.headers.JvmtiErrorPointer; +import com.oracle.svm.core.jvmti.headers.JvmtiEvent; +import com.oracle.svm.core.jvmti.headers.JvmtiEventCallbacks; +import com.oracle.svm.core.jvmti.headers.JvmtiEventMode; +import com.oracle.svm.core.jvmti.headers.JvmtiExtensionFunctionInfoPointer; +import com.oracle.svm.core.jvmti.headers.JvmtiExternalEnv; +import com.oracle.svm.core.jvmti.headers.JvmtiFrameInfo; +import com.oracle.svm.core.jvmti.headers.JvmtiHeapCallbacks; +import com.oracle.svm.core.jvmti.headers.JvmtiHeapObjectCallback; +import com.oracle.svm.core.jvmti.headers.JvmtiHeapRootCallback; +import com.oracle.svm.core.jvmti.headers.JvmtiLineNumberEntryPointer; +import com.oracle.svm.core.jvmti.headers.JvmtiLocalVariableEntryPointer; +import com.oracle.svm.core.jvmti.headers.JvmtiMonitorStackDepthInfoPointer; +import com.oracle.svm.core.jvmti.headers.JvmtiMonitorUsage; +import com.oracle.svm.core.jvmti.headers.JvmtiObjectReferenceCallback; +import com.oracle.svm.core.jvmti.headers.JvmtiStackInfoPointer; +import com.oracle.svm.core.jvmti.headers.JvmtiStackReferenceCallback; +import com.oracle.svm.core.jvmti.headers.JvmtiStartFunctionPointer; +import com.oracle.svm.core.jvmti.headers.JvmtiThreadGroupInfo; +import com.oracle.svm.core.jvmti.headers.JvmtiThreadInfo; +import com.oracle.svm.core.jvmti.headers.JvmtiTimerInfo; +import com.oracle.svm.core.jvmti.headers.JvmtiVersion; +import com.oracle.svm.core.jvmti.headers.VoidPointerPointer; +import com.oracle.svm.core.memory.NullableNativeMemory; +import com.oracle.svm.core.nmt.NmtCategory; + +/** + * Defines all JVMTI entry points. This class may only contain methods that are annotated with + * {@link CEntryPoint}. + * + * Each JVMTI function is annotated with {@link RestrictHeapAccess}, to ensure that it does not + * allocate any Java heap memory nor use Java synchronization. This is necessary because: + *
    + *
  • JVMTI functions may be called from JVMTI event callbacks where we can't execute normal Java + * code (e.g., when the VM is out of Java heap memory)
  • + *
  • JVMTI functions must not execute any code that could trigger JVMTI events (this could result + * in endless recursion otherwise)
  • + *
+ * + * Depending on the JVMTI events that we want to support, it may be necessary to mark most of the + * JVMTI infrastructure as {@link Uninterruptible} in the future to prevent that JVMTI events are + * triggered recursively. + */ +@SuppressWarnings("unused") +public final class JvmtiFunctions { + @Platforms(Platform.HOSTED_ONLY.class) + private JvmtiFunctions() { + } + + // Checkstyle: stop: MethodName + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int Allocate(JvmtiExternalEnv externalEnv, long size, CCharPointerPointer memPtr) { + if (memPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } else if (size < 0) { + memPtr.write(WordFactory.nullPointer()); + return JVMTI_ERROR_ILLEGAL_ARGUMENT.getCValue(); + } + + if (size == 0) { + memPtr.write(WordFactory.nullPointer()); + } else { + CCharPointer mem = NullableNativeMemory.malloc(WordFactory.unsigned(size), NmtCategory.JVMTI); + memPtr.write(mem); + if (mem.isNull()) { + return JVMTI_ERROR_OUT_OF_MEMORY.getCValue(); + } + } + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int Deallocate(JvmtiExternalEnv externalEnv, CCharPointer mem) { + NullableNativeMemory.free(mem); + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetThreadState(JvmtiExternalEnv externalEnv, JThread thread, CIntPointer threadStatePtr) { + if (threadStatePtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetCurrentThread(JvmtiExternalEnv externalEnv, JThreadPointer threadPtr) { + if (threadPtr.equal(WordFactory.nullPointer())) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetAllThreads(JvmtiExternalEnv externalEnv, CIntPointer threadsCountPtr, JThreadPointerPointer threadsPtr) { + if (threadsCountPtr.isNull() || threadsPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SuspendThread(JvmtiExternalEnv externalEnv, JThread thread) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SuspendThreadList(JvmtiExternalEnv externalEnv, int requestCount, @CConst JThreadPointer requestList, JvmtiErrorPointer results) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SuspendAllVirtualThreads(JvmtiExternalEnv externalEnv, int exceptCount, @CConst JThreadPointer exceptList) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ResumeThread(JvmtiExternalEnv externalEnv, JThread thread) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ResumeThreadList(JvmtiExternalEnv externalEnv, int requestCount, @CConst JThreadPointer requestList, JvmtiErrorPointer results) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ResumeAllVirtualThreads(JvmtiExternalEnv externalEnv, int exceptCount, @CConst JThreadPointer exceptList) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int StopThread(JvmtiExternalEnv externalEnv, JThread thread, JNIObjectHandle exception) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int InterruptThread(JvmtiExternalEnv externalEnv, JThread thread) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetThreadInfo(JvmtiExternalEnv externalEnv, JThread thread, JvmtiThreadInfo infoPtr) { + if (infoPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetOwnedMonitorInfo(JvmtiExternalEnv externalEnv, JThread thread, CIntPointer ownedMonitorCountPtr, JNIObjectHandlePointerPointer ownedMonitorsPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetOwnedMonitorStackDepthInfo(JvmtiExternalEnv externalEnv, JThread thread, CIntPointer monitorInfoCountPtr, JvmtiMonitorStackDepthInfoPointer monitorInfoPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetCurrentContendedMonitor(JvmtiExternalEnv externalEnv, JThread thread, JNIObjectHandlePointer monitorPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int RunAgentThread(JvmtiExternalEnv externalEnv, JThread thread, JvmtiStartFunctionPointer proc, @CConst VoidPointer arg, int priority) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetThreadLocalStorage(JvmtiExternalEnv externalEnv, JThread thread, @CConst VoidPointer data) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetThreadLocalStorage(JvmtiExternalEnv externalEnv, JThread thread, VoidPointerPointer dataPtr) { + if (dataPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetTopThreadGroups(JvmtiExternalEnv externalEnv, CIntPointer groupCountPtr, JThreadGroupPointer groupsPtr) { + if (groupsPtr.isNull() || groupCountPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetThreadGroupInfo(JvmtiExternalEnv externalEnv, JThreadGroup group, JvmtiThreadGroupInfo infoPtr) { + if (infoPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetThreadGroupChildren(JvmtiExternalEnv externalEnv, JThreadGroup group, CIntPointer threadCountPtr, JThreadPointerPointer threadsPtr, CIntPointer groupCountPtr, + JThreadGroupPointer groupsPtr) { + if (threadCountPtr.isNull() || threadsPtr.isNull() || groupCountPtr.isNull() || groupsPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetStackTrace(JvmtiExternalEnv externalEnv, JThread thread, int startDepth, int maxFrameCount, JvmtiFrameInfo frameBuffer, CIntPointer countPtr) { + if (maxFrameCount < 0) { + return JVMTI_ERROR_ILLEGAL_ARGUMENT.getCValue(); + } else if (frameBuffer.isNull() || countPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetAllStackTraces(JvmtiExternalEnv externalEnv, int maxFrameCount, JvmtiStackInfoPointer stackInfoPtr, CIntPointer threadCountPtr) { + if (stackInfoPtr.isNull() || threadCountPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } else if (maxFrameCount < 0) { + return JVMTI_ERROR_ILLEGAL_ARGUMENT.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetThreadListStackTraces(JvmtiExternalEnv externalEnv, int threadCount, @CConst JThreadPointer threadList, int maxFrameCount, JvmtiStackInfoPointer stackInfoPtr) { + if (stackInfoPtr.isNull() || threadList.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } else if (maxFrameCount < 0 || threadCount < 0) { + return JVMTI_ERROR_ILLEGAL_ARGUMENT.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetFrameCount(JvmtiExternalEnv externalEnv, JThread thread, CIntPointer countPtr) { + if (countPtr.isNull()) { + return JvmtiError.JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int PopFrame(JvmtiExternalEnv externalEnv, JThread thread) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetFrameLocation(JvmtiExternalEnv externalEnv, JThread thread, int depth, JNIMethodIdPointer methodPtr, CLongPointer locationPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int NotifyFramePop(JvmtiExternalEnv externalEnv, JThread thread, int depth) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ForceEarlyReturnObject(JvmtiExternalEnv externalEnv, JThread thread, JNIObjectHandle value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ForceEarlyReturnInt(JvmtiExternalEnv externalEnv, JThread thread, int value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ForceEarlyReturnLong(JvmtiExternalEnv externalEnv, JThread thread, long value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ForceEarlyReturnFloat(JvmtiExternalEnv externalEnv, JThread thread, float value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ForceEarlyReturnDouble(JvmtiExternalEnv externalEnv, JThread thread, double value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ForceEarlyReturnVoid(JvmtiExternalEnv externalEnv, JThread thread) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int FollowReferences(JvmtiExternalEnv externalEnv, int heapFilter, JClass klass, JNIObjectHandle initialObject, @CConst JvmtiHeapCallbacks callbacks, @CConst VoidPointer userData) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IterateThroughHeap(JvmtiExternalEnv externalEnv, int heapFilter, JClass klass, @CConst JvmtiHeapCallbacks callbacks, @CConst VoidPointer userData) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetTag(JvmtiExternalEnv externalEnv, JNIObjectHandle object, CLongPointer tagPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetTag(JvmtiExternalEnv externalEnv, JNIObjectHandle object, long tag) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetObjectsWithTags(JvmtiExternalEnv externalEnv, int tagCount, @CConst CLongPointer tags, CIntPointer countPtr, JNIObjectHandlePointerPointer objectResultPtr, + CLongPointerPointer tagResultPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ForceGarbageCollection(JvmtiExternalEnv externalEnv) { + Heap.getHeap().getGC().collectCompletely(GCCause.JvmtiForceGC); + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IterateOverObjectsReachableFromObject(JvmtiExternalEnv externalEnv, JNIObjectHandle object, JvmtiObjectReferenceCallback objectReferenceCallback, @CConst VoidPointer userData) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IterateOverReachableObjects(JvmtiExternalEnv externalEnv, JvmtiHeapRootCallback heapRootCallback, JvmtiStackReferenceCallback stackRefCallback, + JvmtiObjectReferenceCallback objectRefCallback, + @CConst VoidPointer userData) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IterateOverHeap(JvmtiExternalEnv externalEnv, int heapObjectFilter, JvmtiHeapObjectCallback heapObjectCallback, @CConst VoidPointer userData) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IterateOverInstancesOfClass(JvmtiExternalEnv externalEnv, JClass klass, int heapObjectFilter, JvmtiHeapObjectCallback heapObjectCallback, + @CConst VoidPointer userData) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetLocalObject(JvmtiExternalEnv externalEnv, JThread thread, int depth, int slot, JNIObjectHandlePointer valuePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetLocalInstance(JvmtiExternalEnv externalEnv, JThread thread, int depth, JNIObjectHandlePointer valuePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetLocalInt(JvmtiExternalEnv externalEnv, JThread thread, int depth, int slot, CIntPointer valuePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetLocalLong(JvmtiExternalEnv externalEnv, JThread thread, int depth, int slot, CLongPointer valuePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetLocalFloat(JvmtiExternalEnv externalEnv, JThread thread, int depth, int slot, CFloatPointer valuePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetLocalDouble(JvmtiExternalEnv externalEnv, JThread thread, int depth, int slot, CDoublePointer valuePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetLocalObject(JvmtiExternalEnv externalEnv, JThread thread, int depth, int slot, JNIObjectHandle value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetLocalInt(JvmtiExternalEnv externalEnv, JThread thread, int depth, int slot, int value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetLocalLong(JvmtiExternalEnv externalEnv, JThread thread, int depth, int slot, long value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetLocalFloat(JvmtiExternalEnv externalEnv, JThread thread, int depth, int slot, float value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetLocalDouble(JvmtiExternalEnv externalEnv, JThread thread, int depth, int slot, double value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetBreakpoint(JvmtiExternalEnv externalEnv, JNIMethodId method, long location) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ClearBreakpoint(JvmtiExternalEnv externalEnv, JNIMethodId method, long location) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetFieldAccessWatch(JvmtiExternalEnv externalEnv, JClass klass, JNIFieldId field) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ClearFieldAccessWatch(JvmtiExternalEnv externalEnv, JClass klass, JNIFieldId field) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetFieldModificationWatch(JvmtiExternalEnv externalEnv, JClass klass, JNIFieldId field) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int ClearFieldModificationWatch(JvmtiExternalEnv externalEnv, JClass klass, JNIFieldId field) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetAllModules(JvmtiExternalEnv externalEnv, CIntPointer moduleCountPtr, JNIObjectHandlePointerPointer modulesPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetNamedModule(JvmtiExternalEnv externalEnv, JNIObjectHandle classLoader, @CConst CCharPointer packageName, JNIObjectHandlePointer modulePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int AddModuleReads(JvmtiExternalEnv externalEnv, JNIObjectHandle module, JNIObjectHandle toModule) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int AddModuleExports(JvmtiExternalEnv externalEnv, JNIObjectHandle module, @CConst CCharPointer pkgName, JNIObjectHandle toModule) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int AddModuleOpens(JvmtiExternalEnv externalEnv, JNIObjectHandle module, @CConst CCharPointer pkgName, JNIObjectHandle toModule) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int AddModuleUses(JvmtiExternalEnv externalEnv, JNIObjectHandle module, JClass service) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int AddModuleProvides(JvmtiExternalEnv externalEnv, JNIObjectHandle module, JClass service, JClass impl_class) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IsModifiableModule(JvmtiExternalEnv externalEnv, JNIObjectHandle module, BooleanPointer isModifiableModulePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetLoadedClasses(JvmtiExternalEnv externalEnv, CIntPointer classCountPtr, JClassPointerPointer classesPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetClassLoaderClasses(JvmtiExternalEnv externalEnv, JNIObjectHandle initiatingLoader, CIntPointer classCountPtr, JClassPointerPointer classesPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetClassSignature(JvmtiExternalEnv externalEnv, JClass klass, CCharPointerPointer signaturePtr, CCharPointerPointer genericPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetClassStatus(JvmtiExternalEnv externalEnv, JClass klass, CIntPointer statusPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetSourceFileName(JvmtiExternalEnv externalEnv, JClass klass, CCharPointerPointer sourceNamePtr) { + if (sourceNamePtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetClassModifiers(JvmtiExternalEnv externalEnv, JClass klass, CIntPointer modifiersPtr) { + if (modifiersPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetClassMethods(JvmtiExternalEnv externalEnv, JClass klass, CIntPointer methodCountPtr, JNIMethodIdPointerPointer methodsPtr) { + if (methodCountPtr.isNull() || methodsPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetClassFields(JvmtiExternalEnv externalEnv, JClass klass, CIntPointer fieldCountPtr, JNIFieldIdPointerPointer fieldsPtr) { + if (fieldCountPtr.isNull() || fieldsPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetImplementedInterfaces(JvmtiExternalEnv externalEnv, JClass klass, CIntPointer interfaceCountPtr, JClassPointerPointer interfacesPtr) { + if (interfacesPtr.isNull() || interfaceCountPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetClassVersionNumbers(JvmtiExternalEnv externalEnv, JClass klass, CIntPointer minorVersionPtr, CIntPointer majorVersionPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetConstantPool(JvmtiExternalEnv externalEnv, JClass klass, CIntPointer constantPoolCountPtr, CIntPointer constantPoolByteCountPtr, CCharPointerPointer constantPoolBytesPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IsInterface(JvmtiExternalEnv externalEnv, JClass klass, BooleanPointer isInterfacePtr) { + if (isInterfacePtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IsArrayClass(JvmtiExternalEnv externalEnv, JClass klass, BooleanPointer isArrayClassPtr) { + if (isArrayClassPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IsModifiableClass(JvmtiExternalEnv externalEnv, JClass klass, BooleanPointer isModifiableClassPtr) { + if (isModifiableClassPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetClassLoader(JvmtiExternalEnv externalEnv, JClass klass, JNIObjectHandlePointer classloaderPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetSourceDebugExtension(JvmtiExternalEnv externalEnv, JClass klass, CCharPointerPointer sourceDebugExtensionPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int RetransformClasses(JvmtiExternalEnv externalEnv, int classCount, @CConst JClassPointer classes) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int RedefineClasses(JvmtiExternalEnv externalEnv, int classCount, @CConst JvmtiClassDefinition classDefinitions) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetObjectSize(JvmtiExternalEnv externalEnv, JNIObjectHandle object, CLongPointer sizePtr) { + if (sizePtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetObjectHashCode(JvmtiExternalEnv externalEnv, JNIObjectHandle object, CIntPointer hashCodePtr) { + if (hashCodePtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetObjectMonitorUsage(JvmtiExternalEnv externalEnv, JNIObjectHandle object, JvmtiMonitorUsage infoPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetFieldName(JvmtiExternalEnv externalEnv, JClass klass, JNIFieldId field, CCharPointerPointer namePtr, CCharPointerPointer signaturePtr, CCharPointerPointer genericPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetFieldDeclaringClass(JvmtiExternalEnv externalEnv, JClass klass, JNIFieldId field, JClassPointer declaringClassPtr) { + if (declaringClassPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetFieldModifiers(JvmtiExternalEnv externalEnv, JClass klass, JNIFieldId field, CIntPointer modifiersPtr) { + if (modifiersPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IsFieldSynthetic(JvmtiExternalEnv externalEnv, JClass klass, JNIFieldId field, BooleanPointer isSyntheticPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetMethodName(JvmtiExternalEnv externalEnv, JNIMethodId method, CCharPointerPointer namePtr, CCharPointerPointer signaturePtr, CCharPointerPointer genericPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetMethodDeclaringClass(JvmtiExternalEnv externalEnv, JNIMethodId method, JClassPointer declaringClassPtr) { + if (declaringClassPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetMethodModifiers(JvmtiExternalEnv externalEnv, JNIMethodId method, CIntPointer modifiersPtr) { + if (modifiersPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetMaxLocals(JvmtiExternalEnv externalEnv, JNIMethodId method, CIntPointer maxPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetArgumentsSize(JvmtiExternalEnv externalEnv, JNIMethodId method, CIntPointer sizePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetLineNumberTable(JvmtiExternalEnv externalEnv, JNIMethodId method, CIntPointer entryCountPtr, JvmtiLineNumberEntryPointer tablePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetMethodLocation(JvmtiExternalEnv externalEnv, JNIMethodId method, CLongPointer startLocationPtr, CLongPointer endLocationPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetLocalVariableTable(JvmtiExternalEnv externalEnv, JNIMethodId method, CIntPointer entryCountPtr, JvmtiLocalVariableEntryPointer tablePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetBytecodes(JvmtiExternalEnv externalEnv, JNIMethodId method, CIntPointer bytecodeCountPtr, CCharPointerPointer bytecodesPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IsMethodNative(JvmtiExternalEnv externalEnv, JNIMethodId method, BooleanPointer isNativePtr) { + if (isNativePtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IsMethodSynthetic(JvmtiExternalEnv externalEnv, JNIMethodId method, BooleanPointer isSyntheticPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int IsMethodObsolete(JvmtiExternalEnv externalEnv, JNIMethodId method, BooleanPointer isObsoletePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetNativeMethodPrefix(JvmtiExternalEnv externalEnv, @CConst CCharPointer prefix) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetNativeMethodPrefixes(JvmtiExternalEnv externalEnv, int prefixCount, CCharPointerPointer prefixes) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int CreateRawMonitor(JvmtiExternalEnv externalEnv, @CConst CCharPointer name, JRawMonitorIdPointer monitorPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int DestroyRawMonitor(JvmtiExternalEnv externalEnv, JRawMonitorId monitor) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int RawMonitorEnter(JvmtiExternalEnv externalEnv, JRawMonitorId monitor) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int RawMonitorExit(JvmtiExternalEnv externalEnv, JRawMonitorId monitor) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int RawMonitorWait(JvmtiExternalEnv externalEnv, JRawMonitorId monitor, long millis) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int RawMonitorNotify(JvmtiExternalEnv externalEnv, JRawMonitorId monitor) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int RawMonitorNotifyAll(JvmtiExternalEnv externalEnv, JRawMonitorId monitor) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetJNIFunctionTable(JvmtiExternalEnv externalEnv, @CConst JNINativeInterface functionTable) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetJNIFunctionTable(JvmtiExternalEnv externalEnv, JNINativeInterfacePointer functionTable) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetEventCallbacks(JvmtiExternalEnv externalEnv, @CConst JvmtiEventCallbacks callbacks, int sizeOfCallbacks) { + if (sizeOfCallbacks <= 0) { + return JVMTI_ERROR_ILLEGAL_ARGUMENT.getCValue(); + } + + JvmtiEnv env = JvmtiEnvUtil.toInternal(externalEnv); + JvmtiEnvUtil.setEventCallbacks(env, callbacks, sizeOfCallbacks); + return JVMTI_ERROR_NONE.getCValue(); + } + + /** Note that this method uses varargs (the vararg part is reserved for future expansions). */ + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetEventNotificationMode(JvmtiExternalEnv externalEnv, int eventMode, JvmtiEvent eventType, JThread eventThread) { + if (eventType == null) { + return JVMTI_ERROR_INVALID_EVENT_TYPE.getCValue(); + } else if (eventMode != JvmtiEventMode.JVMTI_ENABLE() && eventMode != JvmtiEventMode.JVMTI_DISABLE()) { + return JVMTI_ERROR_ILLEGAL_ARGUMENT.getCValue(); + } else if (!eventType.isSupported() && eventMode == JvmtiEventMode.JVMTI_ENABLE()) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + /* Check that the needed capabilities are present. */ + boolean enable = (eventMode == JvmtiEventMode.JVMTI_ENABLE()); + JvmtiEnv env = JvmtiEnvUtil.toInternal(externalEnv); + if (enable && !JvmtiEnvUtil.hasEventCapability()) { + return JVMTI_ERROR_MUST_POSSESS_CAPABILITY.getCValue(); + } + + if (eventThread.equal(JNIObjectHandles.nullHandle())) { + /* Change global event status. */ + JvmtiEnvUtil.setEventUserEnabled(env, null, eventType, enable); + } else { + /* Change thread-local event status. */ + if (eventType.isGlobal()) { + /* Global events cannot be controlled at thread level. */ + return JVMTI_ERROR_ILLEGAL_ARGUMENT.getCValue(); + } + + /* At the moment, we don't support enabling events for specific threads. */ + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GenerateEvents(JvmtiExternalEnv externalEnv, int eventType) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetExtensionFunctions(JvmtiExternalEnv externalEnv, CIntPointer extensionCountPtr, JvmtiExtensionFunctionInfoPointer extensions) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetExtensionEvents(JvmtiExternalEnv externalEnv, CIntPointer extensionCountPtr, JvmtiExtensionFunctionInfoPointer extensions) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetExtensionEventCallback(JvmtiExternalEnv externalEnv, int extensionEventIndex, CFunctionPointer callback) { + /* The callback is a vararg callback that we can't model easily. */ + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetPotentialCapabilities(JvmtiExternalEnv externalEnv, JvmtiCapabilities result) { + if (result.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + + /* We don't support any capabilities at the moment. */ + JvmtiCapabilitiesUtil.clear(result); + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetCapabilities(JvmtiExternalEnv externalEnv, JvmtiCapabilities result) { + if (result.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + + JvmtiEnv env = JvmtiEnvUtil.toInternal(externalEnv); + JvmtiCapabilitiesUtil.copy(JvmtiEnvUtil.getCapabilities(env), result); + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int AddCapabilities(JvmtiExternalEnv externalEnv, @CConst JvmtiCapabilities capabilities) { + if (capabilities.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JvmtiEnvUtil.addCapabilities(capabilities).getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int RelinquishCapabilities(JvmtiExternalEnv externalEnv, @CConst JvmtiCapabilities capabilities) { + if (capabilities.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JvmtiEnvUtil.relinquishCapabilities(capabilities).getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetCurrentThreadCpuTimerInfo(JvmtiExternalEnv externalEnv, JvmtiTimerInfo infoPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetCurrentThreadCpuTime(JvmtiExternalEnv externalEnv, CLongPointer nanosPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetThreadCpuTimerInfo(JvmtiExternalEnv externalEnv, JvmtiTimerInfo infoPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetThreadCpuTime(JvmtiExternalEnv externalEnv, JThread thread, CLongPointer nanosPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetTimerInfo(JvmtiExternalEnv externalEnv, JvmtiTimerInfo infoPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetTime(JvmtiExternalEnv externalEnv, CLongPointer nanosPtr) { + if (nanosPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + nanosPtr.write(System.nanoTime()); + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetAvailableProcessors(JvmtiExternalEnv externalEnv, CIntPointer processorCountPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int AddToBootstrapClassLoaderSearch(JvmtiExternalEnv externalEnv, @CConst CCharPointer segment) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int AddToSystemClassLoaderSearch(JvmtiExternalEnv externalEnv, @CConst CCharPointer segment) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetSystemProperties(JvmtiExternalEnv externalEnv, CIntPointer countPtr, CCharPointerPointerPointer propertyPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetSystemProperty(JvmtiExternalEnv externalEnv, @CConst CCharPointer property, CCharPointerPointer valuePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetSystemProperty(JvmtiExternalEnv externalEnv, @CConst CCharPointer property, @CConst CCharPointer valuePtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetPhase(JvmtiExternalEnv externalEnv, CIntPointer phasePtr) { + if (phasePtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + phasePtr.write(JvmtiSupport.singleton().getPhase().getCValue()); + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int DisposeEnvironment(JvmtiExternalEnv externalEnv) { + JvmtiEnv env = JvmtiEnvUtil.toInternal(externalEnv); + JvmtiEnvs.singleton().dispose(env); + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetEnvironmentLocalStorage(JvmtiExternalEnv externalEnv, @CConst VoidPointer data) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetEnvironmentLocalStorage(JvmtiExternalEnv externalEnv, VoidPointerPointer dataPtr) { + if (dataPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetVersionNumber(JvmtiExternalEnv externalEnv, CIntPointer versionPtr) { + if (versionPtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } + versionPtr.write(JvmtiVersion.CURRENT_VERSION); + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetErrorName(JvmtiExternalEnv externalEnv, JvmtiError jvmtiError, CCharPointerPointer namePtr) { + if (namePtr.isNull()) { + return JVMTI_ERROR_NULL_POINTER.getCValue(); + } else if (jvmtiError == null) { + namePtr.write(WordFactory.nullPointer()); + return JVMTI_ERROR_ILLEGAL_ARGUMENT.getCValue(); + } + + String name = jvmtiError.name(); + UnsignedWord bufferSize = WordFactory.unsigned(name.length() + 1); + Pointer mem = NullableNativeMemory.malloc(bufferSize, NmtCategory.JVMTI); + namePtr.write((CCharPointer) mem); + if (mem.isNull()) { + return JVMTI_ERROR_OUT_OF_MEMORY.getCValue(); + } + + /* Errors are ASCII only. */ + assert bufferSize.equal(UninterruptibleUtils.String.modifiedUTF8Length(name, true)); + UninterruptibleUtils.String.toModifiedUTF8(name, mem, mem.add(bufferSize), true); + return JVMTI_ERROR_NONE.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetVerboseFlag(JvmtiExternalEnv externalEnv, int verboseFlag, boolean value) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int GetJLocationFormat(JvmtiExternalEnv externalEnv, CIntPointer formatPtr) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + @RestrictHeapAccess(access = NO_ALLOCATION, reason = "JVMTI function.") + @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished) + @CEntryPointOptions(prologue = JvmtiEnvEnterPrologue.class) + static int SetHeapSamplingInterval(JvmtiExternalEnv externalEnv, int samplingInterval) { + return JVMTI_ERROR_ACCESS_DENIED.getCValue(); + } + + // Checkstyle: resume + + private static class JvmtiEnvEnterPrologue implements CEntryPointOptions.Prologue { + /** + * In the prologue, we need to be careful that we don't access any image heap data before + * the heap base is set up, so we use @CConstant instead of @CEnum. + */ + @Uninterruptible(reason = "prologue") + public static int enter(JvmtiExternalEnv externalEnv) { + if (externalEnv.isNull()) { + return JvmtiError.invalidEnvironment(); + } + + JvmtiEnv env = JvmtiEnvUtil.toInternal(externalEnv); + if (!JvmtiEnvUtil.isValid(env)) { + return JvmtiError.invalidEnvironment(); + } + + int error = CEntryPointActions.enterByIsolate(JvmtiEnvUtil.getIsolate(env)); + if (error == CEntryPointErrors.UNATTACHED_THREAD) { + return JvmtiError.unattachedThread(); + } else if (error != CEntryPointErrors.NO_ERROR) { + return JvmtiError.internal(); + } + + return JvmtiError.none(); + } + } + + @CPointerTo(CCharPointerPointer.class) + private interface CCharPointerPointerPointer extends PointerBase { + } + + @CPointerTo(CLongPointer.class) + private interface CLongPointerPointer extends PointerBase { + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiSupport.java new file mode 100644 index 000000000000..0b241b4afdf2 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/JvmtiSupport.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti; + +import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + +import com.oracle.svm.core.jdk.RuntimeSupport; +import com.oracle.svm.core.jvmti.headers.JvmtiPhase; + +import jdk.graal.compiler.api.replacements.Fold; + +/** Handles the JVMTI lifecycle (e.g., startup, phase changes, teardown). */ +public final class JvmtiSupport { + private JvmtiPhase phase = JvmtiPhase.JVMTI_PHASE_LIVE; + + @Platforms(Platform.HOSTED_ONLY.class) + public JvmtiSupport() { + } + + @Fold + public static JvmtiSupport singleton() { + return ImageSingletons.lookup(JvmtiSupport.class); + } + + public JvmtiPhase getPhase() { + return phase; + } + + public void setPhase(JvmtiPhase phase) { + this.phase = phase; + } + + public static RuntimeSupport.Hook initializationHook() { + return (firstIsolate) -> { + JvmtiAgents.singleton().load(); + JvmtiEvents.postVMInit(); + JvmtiEvents.postVMStart(); + }; + } + + public static RuntimeSupport.Hook teardownHook() { + return (firstIsolate) -> { + JvmtiEvents.postVMDeath(); + JvmtiSupport.singleton().setPhase(JvmtiPhase.JVMTI_PHASE_DEAD); + JvmtiAgents.singleton().unload(); + JvmtiEnvs.singleton().teardown(); + }; + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/BooleanPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/BooleanPointer.java new file mode 100644 index 000000000000..b1764ce043b3 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/BooleanPointer.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.struct.CPointerTo; +import org.graalvm.word.PointerBase; + +@CPointerTo(nameOfCType = "unsigned char") +public interface BooleanPointer extends PointerBase { + boolean read(); + + void write(boolean value); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JClass.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JClass.java new file mode 100644 index 000000000000..ea239f55a117 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JClass.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import com.oracle.svm.core.jni.headers.JNIObjectHandle; + +public interface JClass extends JNIObjectHandle { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JClassPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JClassPointer.java new file mode 100644 index 000000000000..580136295105 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JClassPointer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.word.PointerBase; + +public interface JClassPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JClassPointerPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JClassPointerPointer.java new file mode 100644 index 000000000000..22f322ab8bd0 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JClassPointerPointer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.word.PointerBase; + +public interface JClassPointerPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JNIObjectHandlePointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JNIObjectHandlePointer.java new file mode 100644 index 000000000000..e6104f981771 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JNIObjectHandlePointer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.word.PointerBase; + +public interface JNIObjectHandlePointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JNIObjectHandlePointerPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JNIObjectHandlePointerPointer.java new file mode 100644 index 000000000000..fc51a729ac3e --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JNIObjectHandlePointerPointer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.word.PointerBase; + +public interface JNIObjectHandlePointerPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JRawMonitorId.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JRawMonitorId.java new file mode 100644 index 000000000000..8d771ad4cd02 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JRawMonitorId.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct(value = "_jrawMonitorID", addStructKeyword = true, isIncomplete = true) +public interface JRawMonitorId extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JRawMonitorIdPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JRawMonitorIdPointer.java new file mode 100644 index 000000000000..60db4865cf5c --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JRawMonitorIdPointer.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CPointerTo; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CPointerTo(JRawMonitorId.class) +public interface JRawMonitorIdPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThread.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThread.java new file mode 100644 index 000000000000..328ac4fb64db --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThread.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import com.oracle.svm.core.jni.headers.JNIObjectHandle; + +public interface JThread extends JNIObjectHandle { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadGroup.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadGroup.java new file mode 100644 index 000000000000..8142b44819c1 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadGroup.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import com.oracle.svm.core.jni.headers.JNIObjectHandle; + +public interface JThreadGroup extends JNIObjectHandle { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadGroupPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadGroupPointer.java new file mode 100644 index 000000000000..8c0261d3db94 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadGroupPointer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.word.PointerBase; + +public interface JThreadGroupPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadGroupPointerPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadGroupPointerPointer.java new file mode 100644 index 000000000000..8c1b1b5bbc95 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadGroupPointerPointer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.word.PointerBase; + +public interface JThreadGroupPointerPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadPointer.java new file mode 100644 index 000000000000..3176d682e22f --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadPointer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.word.PointerBase; + +public interface JThreadPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadPointerPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadPointerPointer.java new file mode 100644 index 000000000000..72ac6b2a3339 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JThreadPointerPointer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.word.PointerBase; + +public interface JThreadPointerPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiCapabilities.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiCapabilities.java new file mode 100644 index 000000000000..1b9a592f5194 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiCapabilities.java @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CBitfield; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct("jvmtiCapabilities") +public interface JvmtiCapabilities extends PointerBase { + @CBitfield("can_tag_objects") + void setCanTagObjects(boolean value); + + @CBitfield("can_tag_objects") + boolean getCanTagObjects(); + + @CBitfield("can_generate_field_modification_events") + void setCanGenerateFieldModificationEvents(boolean value); + + @CBitfield("can_generate_field_modification_events") + boolean getCanGenerateFieldModificationEvents(); + + @CBitfield("can_generate_field_access_events") + void setCanGenerateFieldAccessEvents(boolean value); + + @CBitfield("can_generate_field_access_events") + boolean getCanGenerateFieldAccessEvents(); + + @CBitfield("can_get_bytecodes") + void setCanGetBytecodes(boolean value); + + @CBitfield("can_get_bytecodes") + boolean getCanGetBytecodes(); + + @CBitfield("can_get_synthetic_attribute") + void setCanGetSyntheticAttribute(boolean value); + + @CBitfield("can_get_synthetic_attribute") + boolean getCanGetSyntheticAttribute(); + + @CBitfield("can_get_owned_monitor_info") + void setCanGetOwnedMonitorInfo(boolean value); + + @CBitfield("can_get_owned_monitor_info") + boolean getCanGetOwnedMonitorInfo(); + + @CBitfield("can_get_current_contended_monitor") + void setCanGetCurrentContendedMonitor(boolean value); + + @CBitfield("can_get_current_contended_monitor") + boolean getCanGetCurrentContendedMonitor(); + + @CBitfield("can_get_monitor_info") + void setCanGetMonitorInfo(boolean value); + + @CBitfield("can_get_monitor_info") + boolean getCanGetMonitorInfo(); + + @CBitfield("can_pop_frame") + void setCanPopFrame(boolean value); + + @CBitfield("can_pop_frame") + boolean getCanPopFrame(); + + @CBitfield("can_redefine_classes") + void setCanRedefineClasses(boolean value); + + @CBitfield("can_redefine_classes") + boolean getCanRedefineClasses(); + + @CBitfield("can_signal_thread") + void setCanSignalThread(boolean value); + + @CBitfield("can_signal_thread") + boolean getCanSignalThread(); + + @CBitfield("can_get_source_file_name") + void setCanGetSourceFileName(boolean value); + + @CBitfield("can_get_source_file_name") + boolean getCanGetSourceFileName(); + + @CBitfield("can_get_line_numbers") + void setCanGetLineNumbers(boolean value); + + @CBitfield("can_get_line_numbers") + boolean getCanGetLineNumbers(); + + @CBitfield("can_get_source_debug_extension") + void setCanGetSourceDebugExtension(boolean value); + + @CBitfield("can_get_source_debug_extension") + boolean getCanGetSourceDebugExtension(); + + @CBitfield("can_access_local_variables") + void setCanAccessLocalVariables(boolean value); + + @CBitfield("can_access_local_variables") + boolean getCanAccessLocalVariables(); + + @CBitfield("can_maintain_original_method_order") + void setCanMaintainOriginalMethodOrder(boolean value); + + @CBitfield("can_maintain_original_method_order") + boolean getCanMaintainOriginalMethodOrder(); + + @CBitfield("can_generate_single_step_events") + void setCanGenerateSingleStepEvents(boolean value); + + @CBitfield("can_generate_single_step_events") + boolean getCanGenerateSingleStepEvents(); + + @CBitfield("can_generate_exception_events") + void setCanGenerateExceptionEvents(boolean value); + + @CBitfield("can_generate_exception_events") + boolean getCanGenerateExceptionEvents(); + + @CBitfield("can_generate_frame_pop_events") + void setCanGenerateFramePopEvents(boolean value); + + @CBitfield("can_generate_frame_pop_events") + boolean getCanGenerateFramePopEvents(); + + @CBitfield("can_generate_breakpoint_events") + void setCanGenerateBreakpointEvents(boolean value); + + @CBitfield("can_generate_breakpoint_events") + boolean getCanGenerateBreakpointEvents(); + + @CBitfield("can_suspend") + void setCanSuspend(boolean value); + + @CBitfield("can_suspend") + boolean getCanSuspend(); + + @CBitfield("can_redefine_any_class") + void setCanRedefineAnyClass(boolean value); + + @CBitfield("can_redefine_any_class") + boolean getCanRedefineAnyClass(); + + @CBitfield("can_get_current_thread_cpu_time") + void setCanGetCurrentThreadCpuTime(boolean value); + + @CBitfield("can_get_current_thread_cpu_time") + boolean getCanGetCurrentThreadCpuTime(); + + @CBitfield("can_get_thread_cpu_time") + void setCanGetThreadCpuTime(boolean value); + + @CBitfield("can_get_thread_cpu_time") + boolean getCanGetThreadCpuTime(); + + @CBitfield("can_generate_method_entry_events") + void setCanGenerateMethodEntryEvents(boolean value); + + @CBitfield("can_generate_method_entry_events") + boolean getCanGenerateMethodEntryEvents(); + + @CBitfield("can_generate_method_exit_events") + void setCanGenerateMethodExitEvents(boolean value); + + @CBitfield("can_generate_method_exit_events") + boolean getCanGenerateMethodExitEvents(); + + @CBitfield("can_generate_all_class_hook_events") + void setCanGenerateAllClassHookEvents(boolean value); + + @CBitfield("can_generate_all_class_hook_events") + boolean getCanGenerateAllClassHookEvents(); + + @CBitfield("can_generate_compiled_method_load_events") + void setCanGenerateCompiledMethodLoadEvents(boolean value); + + @CBitfield("can_generate_compiled_method_load_events") + boolean getCanGenerateCompiledMethodLoadEvents(); + + @CBitfield("can_generate_monitor_events") + void setCanGenerateMonitorEvents(boolean value); + + @CBitfield("can_generate_monitor_events") + boolean getCanGenerateMonitorEvents(); + + @CBitfield("can_generate_vm_object_alloc_events") + void setCanGenerateVmObjectAllocEvents(boolean value); + + @CBitfield("can_generate_vm_object_alloc_events") + boolean getCanGenerateVmObjectAllocEvents(); + + @CBitfield("can_generate_native_method_bind_events") + void setCanGenerateNativeMethodBindEvents(boolean value); + + @CBitfield("can_generate_native_method_bind_events") + boolean getCanGenerateNativeMethodBindEvents(); + + @CBitfield("can_generate_garbage_collection_events") + void setCanGenerateGarbageCollectionEvents(boolean value); + + @CBitfield("can_generate_garbage_collection_events") + boolean getCanGenerateGarbageCollectionEvents(); + + @CBitfield("can_generate_object_free_events") + void setCanGenerateObjectFreeEvents(boolean value); + + @CBitfield("can_generate_object_free_events") + boolean getCanGenerateObjectFreeEvents(); + + @CBitfield("can_force_early_return") + void setCanForceEarlyReturn(boolean value); + + @CBitfield("can_force_early_return") + boolean getCanForceEarlyReturn(); + + @CBitfield("can_get_owned_monitor_stack_depth_info") + void setCanGetOwnedMonitorStackDepthInfo(boolean value); + + @CBitfield("can_get_owned_monitor_stack_depth_info") + boolean getCanGetOwnedMonitorStackDepthInfo(); + + @CBitfield("can_get_constant_pool") + void setCanGetConstantPool(boolean value); + + @CBitfield("can_get_constant_pool") + boolean getCanGetConstantPool(); + + @CBitfield("can_set_native_method_prefix") + void setCanSetNativeMethodPrefix(boolean value); + + @CBitfield("can_set_native_method_prefix") + boolean getCanSetNativeMethodPrefix(); + + @CBitfield("can_retransform_classes") + void setCanRetransformClasses(boolean value); + + @CBitfield("can_retransform_classes") + boolean getCanRetransformClasses(); + + @CBitfield("can_retransform_any_class") + void setCanRetransformAnyClass(boolean value); + + @CBitfield("can_retransform_any_class") + boolean getCanRetransformAnyClass(); + + @CBitfield("can_generate_resource_exhaustion_heap_events") + void setCanGenerateResourceExhaustionHeapEvents(boolean value); + + @CBitfield("can_generate_resource_exhaustion_heap_events") + boolean getCanGenerateResourceExhaustionHeapEvents(); + + @CBitfield("can_generate_resource_exhaustion_threads_events") + void setCanGenerateResourceExhaustionThreadsEvents(boolean value); + + @CBitfield("can_generate_resource_exhaustion_threads_events") + boolean getCanGenerateResourceExhaustionThreadsEvents(); + + @CBitfield("can_generate_early_vmstart") + void setCanGenerateEarlyVmstart(boolean value); + + @CBitfield("can_generate_early_vmstart") + boolean getCanGenerateEarlyVmstart(); + + @CBitfield("can_generate_early_class_hook_events") + void setCanGenerateEarlyClassHookEvents(boolean value); + + @CBitfield("can_generate_early_class_hook_events") + boolean getCanGenerateEarlyClassHookEvents(); + + @CBitfield("can_generate_sampled_object_alloc_events") + void setCanGenerateSampledObjectAllocEvents(boolean value); + + @CBitfield("can_generate_sampled_object_alloc_events") + boolean getCanGenerateSampledObjectAllocEvents(); + + @CBitfield("can_support_virtual_threads") + void setCanSupportVirtualThreads(boolean value); + + @CBitfield("can_support_virtual_threads") + boolean getCanSupportVirtualThreads(); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiClassDefinition.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiClassDefinition.java new file mode 100644 index 000000000000..7f34b94477e6 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiClassDefinition.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct("jvmtiClassDefinition") +public interface JvmtiClassDefinition extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiDirectives.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiDirectives.java new file mode 100644 index 000000000000..88ebb4ae6085 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiDirectives.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.List; + +import org.graalvm.nativeimage.c.CContext; + +import com.oracle.svm.core.OS; +import com.oracle.svm.core.SubstrateOptions; +import com.oracle.svm.core.util.BasedOnJDKFile; + +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+11/src/hotspot/share/prims/jvmti.xml") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+11/src/hotspot/share/prims/jvmtiH.xsl") +class JvmtiDirectives implements CContext.Directives { + private final Path jdkIncludeDir = Paths.get(System.getProperty("java.home")).resolve("include"); + + @Override + public boolean isInConfiguration() { + return SubstrateOptions.JVMTI.getValue(); + } + + @Override + public List getHeaderFiles() { + return Collections.singletonList("\"" + jdkIncludeDir.resolve("jvmti.h") + "\""); + } + + @Override + public List getOptions() { + return Collections.singletonList("-I" + jdkIncludeDir.resolve(OS.getCurrent() == OS.WINDOWS ? "win32" : OS.getCurrent().asPackageName())); + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiError.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiError.java new file mode 100644 index 000000000000..98dc2d5f56d0 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiError.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CConstant; +import org.graalvm.nativeimage.c.constant.CEnum; +import org.graalvm.nativeimage.c.constant.CEnumLookup; +import org.graalvm.nativeimage.c.constant.CEnumValue; + +@CContext(JvmtiDirectives.class) +@CEnum("jvmtiError") +public enum JvmtiError { + /* Universal errors. */ + JVMTI_ERROR_NONE, + JVMTI_ERROR_NULL_POINTER, + JVMTI_ERROR_OUT_OF_MEMORY, + JVMTI_ERROR_ACCESS_DENIED, + JVMTI_ERROR_UNATTACHED_THREAD, + JVMTI_ERROR_INVALID_ENVIRONMENT, + JVMTI_ERROR_WRONG_PHASE, + JVMTI_ERROR_INTERNAL, + + /* Function specific errors. */ + JVMTI_ERROR_INVALID_PRIORITY, + JVMTI_ERROR_THREAD_NOT_SUSPENDED, + JVMTI_ERROR_THREAD_SUSPENDED, + JVMTI_ERROR_THREAD_NOT_ALIVE, + JVMTI_ERROR_CLASS_NOT_PREPARED, + JVMTI_ERROR_NO_MORE_FRAMES, + JVMTI_ERROR_OPAQUE_FRAME, + JVMTI_ERROR_DUPLICATE, + JVMTI_ERROR_NOT_FOUND, + JVMTI_ERROR_NOT_MONITOR_OWNER, + JVMTI_ERROR_INTERRUPT, + JVMTI_ERROR_UNMODIFIABLE_CLASS, + JVMTI_ERROR_UNMODIFIABLE_MODULE, + JVMTI_ERROR_NOT_AVAILABLE, + JVMTI_ERROR_ABSENT_INFORMATION, + JVMTI_ERROR_INVALID_EVENT_TYPE, + JVMTI_ERROR_NATIVE_METHOD, + JVMTI_ERROR_CLASS_LOADER_UNSUPPORTED, + + /* Function specific agent errors. */ + JVMTI_ERROR_INVALID_THREAD, + JVMTI_ERROR_INVALID_FIELDID, + JVMTI_ERROR_INVALID_MODULE, + JVMTI_ERROR_INVALID_METHODID, + JVMTI_ERROR_INVALID_LOCATION, + JVMTI_ERROR_INVALID_OBJECT, + JVMTI_ERROR_INVALID_CLASS, + JVMTI_ERROR_TYPE_MISMATCH, + JVMTI_ERROR_INVALID_SLOT, + JVMTI_ERROR_MUST_POSSESS_CAPABILITY, + JVMTI_ERROR_INVALID_THREAD_GROUP, + JVMTI_ERROR_INVALID_MONITOR, + JVMTI_ERROR_ILLEGAL_ARGUMENT, + JVMTI_ERROR_INVALID_TYPESTATE, + JVMTI_ERROR_UNSUPPORTED_VERSION, + JVMTI_ERROR_INVALID_CLASS_FORMAT, + JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED, + JVMTI_ERROR_FAILS_VERIFICATION, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED, + JVMTI_ERROR_NAMES_DONT_MATCH, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_ATTRIBUTE_CHANGED, + JVMTI_ERROR_UNSUPPORTED_OPERATION; + + @CConstant("JVMTI_ERROR_NONE") + public static native int none(); + + @CConstant("JVMTI_ERROR_UNATTACHED_THREAD") + public static native int unattachedThread(); + + @CConstant("JVMTI_ERROR_INVALID_ENVIRONMENT") + public static native int invalidEnvironment(); + + @CConstant("JVMTI_ERROR_INTERNAL") + public static native int internal(); + + @CEnumValue + public native int getCValue(); + + @CEnumLookup + public static native JvmtiError fromValue(int value); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiErrorPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiErrorPointer.java new file mode 100644 index 000000000000..cfba40ecae96 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiErrorPointer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.type.CIntPointer; + +public interface JvmtiErrorPointer extends CIntPointer { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiEvent.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiEvent.java new file mode 100644 index 000000000000..edda8bc5a6ce --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiEvent.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CConstant; +import org.graalvm.nativeimage.c.constant.CEnum; +import org.graalvm.nativeimage.c.constant.CEnumLookup; +import org.graalvm.nativeimage.c.constant.CEnumValue; + +import com.oracle.svm.core.collections.EnumBitmask; + +@CContext(JvmtiDirectives.class) +@CEnum("jvmtiEvent") +public enum JvmtiEvent { + JVMTI_EVENT_VM_INIT(true, JvmtiEventFlags.Global), + JVMTI_EVENT_VM_DEATH(true, JvmtiEventFlags.Global), + JVMTI_EVENT_THREAD_START(false, JvmtiEventFlags.Global), + JVMTI_EVENT_THREAD_END(false), + JVMTI_EVENT_CLASS_FILE_LOAD_HOOK(false), + JVMTI_EVENT_CLASS_LOAD(false), + JVMTI_EVENT_CLASS_PREPARE(false), + JVMTI_EVENT_VM_START(true, JvmtiEventFlags.Global), + JVMTI_EVENT_EXCEPTION(false), + JVMTI_EVENT_EXCEPTION_CATCH(false), + JVMTI_EVENT_SINGLE_STEP(false), + JVMTI_EVENT_FRAME_POP(false), + JVMTI_EVENT_BREAKPOINT(false), + JVMTI_EVENT_FIELD_ACCESS(false), + JVMTI_EVENT_FIELD_MODIFICATION(false), + JVMTI_EVENT_METHOD_ENTRY(false), + JVMTI_EVENT_METHOD_EXIT(false), + JVMTI_EVENT_NATIVE_METHOD_BIND(false), + JVMTI_EVENT_COMPILED_METHOD_LOAD(false, JvmtiEventFlags.Global), + JVMTI_EVENT_COMPILED_METHOD_UNLOAD(false, JvmtiEventFlags.Global), + JVMTI_EVENT_DYNAMIC_CODE_GENERATED(false, JvmtiEventFlags.Global), + JVMTI_EVENT_DATA_DUMP_REQUEST(false, JvmtiEventFlags.Global), + JVMTI_EVENT_MONITOR_WAIT(false), + JVMTI_EVENT_MONITOR_WAITED(false), + JVMTI_EVENT_MONITOR_CONTENDED_ENTER(false), + JVMTI_EVENT_MONITOR_CONTENDED_ENTERED(false), + JVMTI_EVENT_RESOURCE_EXHAUSTED(false), + JVMTI_EVENT_GARBAGE_COLLECTION_START(false), + JVMTI_EVENT_GARBAGE_COLLECTION_FINISH(false), + JVMTI_EVENT_OBJECT_FREE(false), + JVMTI_EVENT_VM_OBJECT_ALLOC(false), + JVMTI_EVENT_SAMPLED_OBJECT_ALLOC(false), + JVMTI_EVENT_VIRTUAL_THREAD_START(false, JvmtiEventFlags.Global), + JVMTI_EVENT_VIRTUAL_THREAD_END(false); + + private final boolean isSupported; + private final int flags; + + JvmtiEvent(boolean isSupported, JvmtiEventFlags... flags) { + this.isSupported = isSupported; + this.flags = EnumBitmask.computeBitmask(flags); + + } + + public boolean isSupported() { + return isSupported; + } + + public boolean isGlobal() { + return EnumBitmask.hasBit(flags, JvmtiEventFlags.Global); + } + + public static long getBit(JvmtiEvent eventType) { + int index = eventType.getCValue() - JvmtiEvent.getMinEventType(); + assert index < 64; + return 1L << index; + } + + @CConstant("JVMTI_MIN_EVENT_TYPE_VAL") + public static native int getMinEventType(); + + @CEnumValue + public native int getCValue(); + + @CEnumLookup + public static native JvmtiEvent fromValue(int value); + + private enum JvmtiEventFlags { + Global + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiEventCallbacks.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiEventCallbacks.java new file mode 100644 index 000000000000..3ae06a91fdac --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiEventCallbacks.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.function.CFunctionPointer; +import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; +import org.graalvm.nativeimage.c.struct.CField; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +import com.oracle.svm.core.jni.headers.JNIEnvironment; +import com.oracle.svm.core.jni.headers.JNIObjectHandle; + +/** + * Only a small subset of the callbacks is supported at the moment. All unsupported callbacks use + * the type {@link CFunctionPointer}. + */ +@CContext(JvmtiDirectives.class) +@CStruct("jvmtiEventCallbacks") +public interface JvmtiEventCallbacks extends PointerBase { + @CField + JvmtiEventVMInitFunctionPointer getVMInit(); + + @CField + JvmtiEventVMDeathFunctionPointer getVMDeath(); + + @CField + JvmtiEventThreadStartFunctionPointer getThreadStart(); + + @CField + JvmtiEventThreadEndFunctionPointer getThreadEnd(); + + @CField + CFunctionPointer getClassFileLoadHook(); + + @CField + CFunctionPointer getClassLoad(); + + @CField + CFunctionPointer getClassPrepare(); + + @CField + JvmtiEventVMStartFunctionPointer getVMStart(); + + @CField + CFunctionPointer getException(); + + @CField + CFunctionPointer getExceptionCatch(); + + @CField + CFunctionPointer getSingleStep(); + + @CField + CFunctionPointer getFramePop(); + + @CField + CFunctionPointer getBreakpoint(); + + @CField + CFunctionPointer getFieldAccess(); + + @CField + CFunctionPointer getFieldModification(); + + @CField + CFunctionPointer getMethodEntry(); + + @CField + CFunctionPointer getMethodExit(); + + @CField + CFunctionPointer getNativeMethodBind(); + + @CField + CFunctionPointer getCompiledMethodLoad(); + + @CField + CFunctionPointer getCompiledMethodUnload(); + + @CField + CFunctionPointer getDynamicCodeGenerated(); + + @CField + CFunctionPointer getDataDumpRequest(); + + @CField("reserved72") + CFunctionPointer getReserved72(); + + @CField + JvmtiEventMonitorWaitFunctionPointer getMonitorWait(); + + @CField + JvmtiEventMonitorWaitedFunctionPointer getMonitorWaited(); + + @CField + JvmtiEventMonitorContendedEnterFunctionPointer getMonitorContendedEnter(); + + @CField + JvmtiEventMonitorContendedEnteredFunctionPointer getMonitorContendedEntered(); + + @CField("reserved77") + CFunctionPointer getReserved77(); + + @CField("reserved78") + CFunctionPointer getReserved78(); + + @CField("reserved79") + CFunctionPointer getReserved79(); + + @CField + CFunctionPointer getResourceExhausted(); + + @CField + JvmtiEventGarbageCollectionStartFunctionPointer getGarbageCollectionStart(); + + @CField + JvmtiEventGarbageCollectionFinishFunctionPointer getGarbageCollectionFinish(); + + @CField + CFunctionPointer getObjectFree(); + + @CField + CFunctionPointer getVMObjectAlloc(); + + @CField("reserved85") + CFunctionPointer getReserved85(); + + @CField + CFunctionPointer getSampledObjectAlloc(); + + @CField + CFunctionPointer getVirtualThreadStart(); + + @CField + CFunctionPointer getVirtualThreadEnd(); + + interface JvmtiEventVMInitFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv, JNIEnvironment jniEnv, JThread thread); + } + + interface JvmtiEventVMDeathFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv, JNIEnvironment jniEnv); + } + + interface JvmtiEventVMStartFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv, JNIEnvironment jniEnv); + } + + interface JvmtiEventGarbageCollectionFinishFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv); + } + + interface JvmtiEventGarbageCollectionStartFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv); + } + + interface JvmtiEventThreadStartFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv, JNIEnvironment jniEnv, JThread jthread); + } + + interface JvmtiEventThreadEndFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv, JNIEnvironment jniEnv, JThread jthread); + } + + interface JvmtiEventMonitorWaitFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv, JNIEnvironment jniEnv, JThread jthread, JNIObjectHandle obj, long timeout); + } + + interface JvmtiEventMonitorWaitedFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv, JNIEnvironment jniEnv, JThread jthread, JNIObjectHandle obj, boolean timedOut); + } + + interface JvmtiEventMonitorContendedEnterFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv, JNIEnvironment jniEnv, JThread thread, JNIObjectHandle obj); + } + + interface JvmtiEventMonitorContendedEnteredFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + void invoke(JvmtiExternalEnv jvmtiEnv, JNIEnvironment jniEnv, JThread thread, JNIObjectHandle obj); + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiEventMode.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiEventMode.java new file mode 100644 index 000000000000..730c147f9b72 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiEventMode.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CConstant; + +@CContext(JvmtiDirectives.class) +public final class JvmtiEventMode { + // Checkstyle: stop: MethodName + + @CConstant + public static native int JVMTI_ENABLE(); + + @CConstant + public static native int JVMTI_DISABLE(); + + // Checkstyle: resume +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiExtensionFunctionInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiExtensionFunctionInfo.java new file mode 100644 index 000000000000..e0b9b3ae2d80 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiExtensionFunctionInfo.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct(value = "jvmtiExtensionFunctionInfo", addStructKeyword = true) +public interface JvmtiExtensionFunctionInfo extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiExtensionFunctionInfoPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiExtensionFunctionInfoPointer.java new file mode 100644 index 000000000000..7f657bd00d24 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiExtensionFunctionInfoPointer.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CPointerTo; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CPointerTo(JvmtiExtensionFunctionInfo.class) +public interface JvmtiExtensionFunctionInfoPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiExternalEnv.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiExternalEnv.java new file mode 100644 index 000000000000..cd9e2e063aff --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiExternalEnv.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CField; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct(value = "_jvmtiEnv", addStructKeyword = true) +public interface JvmtiExternalEnv extends PointerBase { + @CField("functions") + JvmtiInterface getFunctions(); + + @CField("functions") + void setFunctions(JvmtiInterface table); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiFrameInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiFrameInfo.java new file mode 100644 index 000000000000..f6c1c9847f05 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiFrameInfo.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CField; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +import com.oracle.svm.core.jni.headers.JNIMethodId; + +@CContext(JvmtiDirectives.class) +@CStruct(value = "jvmtiFrameInfo", addStructKeyword = true) +public interface JvmtiFrameInfo extends PointerBase { + @CField("method") + JNIMethodId getMethod(); + + @CField("method") + void setMethod(JNIMethodId method); + + @CField("location") + long getLocation(); + + @CField("location") + void setLocation(long location); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapCallbacks.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapCallbacks.java new file mode 100644 index 000000000000..5787e49d9552 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapCallbacks.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct("jvmtiHeapCallbacks") +public interface JvmtiHeapCallbacks extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapObjectCallback.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapObjectCallback.java new file mode 100644 index 000000000000..eda2acac9549 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapObjectCallback.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.function.CFunctionPointer; +import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; +import org.graalvm.nativeimage.c.type.CLongPointer; +import org.graalvm.nativeimage.c.type.VoidPointer; + +public interface JvmtiHeapObjectCallback extends CFunctionPointer { + @InvokeCFunctionPointer + int invoke(long classTag, long size, CLongPointer tagPtr, VoidPointer userData); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapObjectFilter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapObjectFilter.java new file mode 100644 index 000000000000..8e22effb53f3 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapObjectFilter.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CConstant; + +@CContext(JvmtiDirectives.class) +public final class JvmtiHeapObjectFilter { + // Checkstyle: stop: MethodName + + @CConstant + public static native int JVMTI_HEAP_OBJECT_TAGGED(); + + @CConstant + public static native int JVMTI_HEAP_OBJECT_UNTAGGED(); + + @CConstant + public static native int JVMTI_HEAP_OBJECT_EITHER(); + + // Checkstyle: resume +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapRootCallback.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapRootCallback.java new file mode 100644 index 000000000000..cbfe2f956c5f --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapRootCallback.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.function.CFunctionPointer; +import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; +import org.graalvm.nativeimage.c.type.CLongPointer; +import org.graalvm.nativeimage.c.type.VoidPointer; + +public interface JvmtiHeapRootCallback extends CFunctionPointer { + @InvokeCFunctionPointer + int invoke(JvmtiHeapRootKind rootKind, long classTag, long size, CLongPointer tagPtr, VoidPointer userData); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapRootKind.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapRootKind.java new file mode 100644 index 000000000000..1300b932d0cf --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiHeapRootKind.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CConstant; + +@CContext(JvmtiDirectives.class) +public final class JvmtiHeapRootKind { + // Checkstyle: stop: MethodName + + @CConstant + public static native int JVMTI_HEAP_ROOT_JNI_GLOBAL(); + + @CConstant + public static native int JVMTI_HEAP_ROOT_SYSTEM_CLASS(); + + @CConstant + public static native int JVMTI_HEAP_ROOT_MONITOR(); + + @CConstant + public static native int JVMTI_HEAP_ROOT_STACK_LOCAL(); + + @CConstant + public static native int JVMTI_HEAP_ROOT_JNI_LOCAL(); + + @CConstant + public static native int JVMTI_HEAP_ROOT_THREAD(); + + @CConstant + public static native int JVMTI_HEAP_ROOT_OTHER(); + + // Checkstyle: resume +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiInterface.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiInterface.java new file mode 100644 index 000000000000..c256e040bcc0 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiInterface.java @@ -0,0 +1,954 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.function.CFunctionPointer; +import org.graalvm.nativeimage.c.struct.CField; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.nativeimage.c.type.VoidPointer; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct(value = "jvmtiInterface_1_", addStructKeyword = true) +public interface JvmtiInterface extends PointerBase { + @CField + VoidPointer reserved1(); + + @CField + CFunctionPointer getSetEventNotificationMode(); + + @CField + void setSetEventNotificationMode(CFunctionPointer value); + + @CField + CFunctionPointer getGetAllModules(); + + @CField + void setGetAllModules(CFunctionPointer value); + + @CField + CFunctionPointer getGetAllThreads(); + + @CField + void setGetAllThreads(CFunctionPointer value); + + @CField + CFunctionPointer getSuspendThread(); + + @CField + void setSuspendThread(CFunctionPointer value); + + @CField + CFunctionPointer getResumeThread(); + + @CField + void setResumeThread(CFunctionPointer value); + + @CField + CFunctionPointer getStopThread(); + + @CField + void setStopThread(CFunctionPointer value); + + @CField + CFunctionPointer getInterruptThread(); + + @CField + void setInterruptThread(CFunctionPointer value); + + @CField + CFunctionPointer getGetThreadInfo(); + + @CField + void setGetThreadInfo(CFunctionPointer value); + + @CField + CFunctionPointer getGetOwnedMonitorInfo(); + + @CField + void setGetOwnedMonitorInfo(CFunctionPointer value); + + @CField + CFunctionPointer getGetCurrentContendedMonitor(); + + @CField + void setGetCurrentContendedMonitor(CFunctionPointer value); + + @CField + CFunctionPointer getRunAgentThread(); + + @CField + void setRunAgentThread(CFunctionPointer value); + + @CField + CFunctionPointer getGetTopThreadGroups(); + + @CField + void setGetTopThreadGroups(CFunctionPointer value); + + @CField + CFunctionPointer getGetThreadGroupInfo(); + + @CField + void setGetThreadGroupInfo(CFunctionPointer value); + + @CField + CFunctionPointer getGetThreadGroupChildren(); + + @CField + void setGetThreadGroupChildren(CFunctionPointer value); + + @CField + CFunctionPointer getGetFrameCount(); + + @CField + void setGetFrameCount(CFunctionPointer value); + + @CField + CFunctionPointer getGetThreadState(); + + @CField + void setGetThreadState(CFunctionPointer value); + + @CField + CFunctionPointer getGetCurrentThread(); + + @CField + void setGetCurrentThread(CFunctionPointer value); + + @CField + CFunctionPointer getGetFrameLocation(); + + @CField + void setGetFrameLocation(CFunctionPointer value); + + @CField + CFunctionPointer getNotifyFramePop(); + + @CField + void setNotifyFramePop(CFunctionPointer value); + + @CField + CFunctionPointer getGetLocalObject(); + + @CField + void setGetLocalObject(CFunctionPointer value); + + @CField + CFunctionPointer getGetLocalInt(); + + @CField + void setGetLocalInt(CFunctionPointer value); + + @CField + CFunctionPointer getGetLocalLong(); + + @CField + void setGetLocalLong(CFunctionPointer value); + + @CField + CFunctionPointer getGetLocalFloat(); + + @CField + void setGetLocalFloat(CFunctionPointer value); + + @CField + CFunctionPointer getGetLocalDouble(); + + @CField + void setGetLocalDouble(CFunctionPointer value); + + @CField + CFunctionPointer getSetLocalObject(); + + @CField + void setSetLocalObject(CFunctionPointer value); + + @CField + CFunctionPointer getSetLocalInt(); + + @CField + void setSetLocalInt(CFunctionPointer value); + + @CField + CFunctionPointer getSetLocalLong(); + + @CField + void setSetLocalLong(CFunctionPointer value); + + @CField + CFunctionPointer getSetLocalFloat(); + + @CField + void setSetLocalFloat(CFunctionPointer value); + + @CField + CFunctionPointer getSetLocalDouble(); + + @CField + void setSetLocalDouble(CFunctionPointer value); + + @CField + CFunctionPointer getCreateRawMonitor(); + + @CField + void setCreateRawMonitor(CFunctionPointer value); + + @CField + CFunctionPointer getDestroyRawMonitor(); + + @CField + void setDestroyRawMonitor(CFunctionPointer value); + + @CField + CFunctionPointer getRawMonitorEnter(); + + @CField + void setRawMonitorEnter(CFunctionPointer value); + + @CField + CFunctionPointer getRawMonitorExit(); + + @CField + void setRawMonitorExit(CFunctionPointer value); + + @CField + CFunctionPointer getRawMonitorWait(); + + @CField + void setRawMonitorWait(CFunctionPointer value); + + @CField + CFunctionPointer getRawMonitorNotify(); + + @CField + void setRawMonitorNotify(CFunctionPointer value); + + @CField + CFunctionPointer getRawMonitorNotifyAll(); + + @CField + void setRawMonitorNotifyAll(CFunctionPointer value); + + @CField + CFunctionPointer getSetBreakpoint(); + + @CField + void setSetBreakpoint(CFunctionPointer value); + + @CField + CFunctionPointer getClearBreakpoint(); + + @CField + void setClearBreakpoint(CFunctionPointer value); + + @CField + CFunctionPointer getGetNamedModule(); + + @CField + void setGetNamedModule(CFunctionPointer value); + + @CField + CFunctionPointer getSetFieldAccessWatch(); + + @CField + void setSetFieldAccessWatch(CFunctionPointer value); + + @CField + CFunctionPointer getClearFieldAccessWatch(); + + @CField + void setClearFieldAccessWatch(CFunctionPointer value); + + @CField + CFunctionPointer getSetFieldModificationWatch(); + + @CField + void setSetFieldModificationWatch(CFunctionPointer value); + + @CField + CFunctionPointer getClearFieldModificationWatch(); + + @CField + void setClearFieldModificationWatch(CFunctionPointer value); + + @CField + CFunctionPointer getIsModifiableClass(); + + @CField + void setIsModifiableClass(CFunctionPointer value); + + @CField + CFunctionPointer getAllocate(); + + @CField + void setAllocate(CFunctionPointer value); + + @CField + CFunctionPointer getDeallocate(); + + @CField + void setDeallocate(CFunctionPointer value); + + @CField + CFunctionPointer getGetClassSignature(); + + @CField + void setGetClassSignature(CFunctionPointer value); + + @CField + CFunctionPointer getGetClassStatus(); + + @CField + void setGetClassStatus(CFunctionPointer value); + + @CField + CFunctionPointer getGetSourceFileName(); + + @CField + void setGetSourceFileName(CFunctionPointer value); + + @CField + CFunctionPointer getGetClassModifiers(); + + @CField + void setGetClassModifiers(CFunctionPointer value); + + @CField + CFunctionPointer getGetClassMethods(); + + @CField + void setGetClassMethods(CFunctionPointer value); + + @CField + CFunctionPointer getGetClassFields(); + + @CField + void setGetClassFields(CFunctionPointer value); + + @CField + CFunctionPointer getGetImplementedInterfaces(); + + @CField + void setGetImplementedInterfaces(CFunctionPointer value); + + @CField + CFunctionPointer getIsInterface(); + + @CField + void setIsInterface(CFunctionPointer value); + + @CField + CFunctionPointer getIsArrayClass(); + + @CField + void setIsArrayClass(CFunctionPointer value); + + @CField + CFunctionPointer getGetClassLoader(); + + @CField + void setGetClassLoader(CFunctionPointer value); + + @CField + CFunctionPointer getGetObjectHashCode(); + + @CField + void setGetObjectHashCode(CFunctionPointer value); + + @CField + CFunctionPointer getGetObjectMonitorUsage(); + + @CField + void setGetObjectMonitorUsage(CFunctionPointer value); + + @CField + CFunctionPointer getGetFieldName(); + + @CField + void setGetFieldName(CFunctionPointer value); + + @CField + CFunctionPointer getGetFieldDeclaringClass(); + + @CField + void setGetFieldDeclaringClass(CFunctionPointer value); + + @CField + CFunctionPointer getGetFieldModifiers(); + + @CField + void setGetFieldModifiers(CFunctionPointer value); + + @CField + CFunctionPointer getIsFieldSynthetic(); + + @CField + void setIsFieldSynthetic(CFunctionPointer value); + + @CField + CFunctionPointer getGetMethodName(); + + @CField + void setGetMethodName(CFunctionPointer value); + + @CField + CFunctionPointer getGetMethodDeclaringClass(); + + @CField + void setGetMethodDeclaringClass(CFunctionPointer value); + + @CField + CFunctionPointer getGetMethodModifiers(); + + @CField + void setGetMethodModifiers(CFunctionPointer value); + + @CField + CFunctionPointer reserved67(); + + @CField + CFunctionPointer getGetMaxLocals(); + + @CField + void setGetMaxLocals(CFunctionPointer value); + + @CField + CFunctionPointer getGetArgumentsSize(); + + @CField + void setGetArgumentsSize(CFunctionPointer value); + + @CField + CFunctionPointer getGetLineNumberTable(); + + @CField + void setGetLineNumberTable(CFunctionPointer value); + + @CField + CFunctionPointer getGetMethodLocation(); + + @CField + void setGetMethodLocation(CFunctionPointer value); + + @CField + CFunctionPointer getGetLocalVariableTable(); + + @CField + void setGetLocalVariableTable(CFunctionPointer value); + + @CField + CFunctionPointer getSetNativeMethodPrefix(); + + @CField + void setSetNativeMethodPrefix(CFunctionPointer value); + + @CField + CFunctionPointer getSetNativeMethodPrefixes(); + + @CField + void setSetNativeMethodPrefixes(CFunctionPointer value); + + @CField + CFunctionPointer getGetBytecodes(); + + @CField + void setGetBytecodes(CFunctionPointer value); + + @CField + CFunctionPointer getIsMethodNative(); + + @CField + void setIsMethodNative(CFunctionPointer value); + + @CField + CFunctionPointer getIsMethodSynthetic(); + + @CField + void setIsMethodSynthetic(CFunctionPointer value); + + @CField + CFunctionPointer getGetLoadedClasses(); + + @CField + void setGetLoadedClasses(CFunctionPointer value); + + @CField + CFunctionPointer getGetClassLoaderClasses(); + + @CField + void setGetClassLoaderClasses(CFunctionPointer value); + + @CField + CFunctionPointer getPopFrame(); + + @CField + void setPopFrame(CFunctionPointer value); + + @CField + CFunctionPointer getForceEarlyReturnObject(); + + @CField + void setForceEarlyReturnObject(CFunctionPointer value); + + @CField + CFunctionPointer getForceEarlyReturnInt(); + + @CField + void setForceEarlyReturnInt(CFunctionPointer value); + + @CField + CFunctionPointer getForceEarlyReturnLong(); + + @CField + void setForceEarlyReturnLong(CFunctionPointer value); + + @CField + CFunctionPointer getForceEarlyReturnFloat(); + + @CField + void setForceEarlyReturnFloat(CFunctionPointer value); + + @CField + CFunctionPointer getForceEarlyReturnDouble(); + + @CField + void setForceEarlyReturnDouble(CFunctionPointer value); + + @CField + CFunctionPointer getForceEarlyReturnVoid(); + + @CField + void setForceEarlyReturnVoid(CFunctionPointer value); + + @CField + CFunctionPointer getRedefineClasses(); + + @CField + void setRedefineClasses(CFunctionPointer value); + + @CField + CFunctionPointer getGetVersionNumber(); + + @CField + void setGetVersionNumber(CFunctionPointer value); + + @CField + CFunctionPointer getGetCapabilities(); + + @CField + void setGetCapabilities(CFunctionPointer value); + + @CField + CFunctionPointer getGetSourceDebugExtension(); + + @CField + void setGetSourceDebugExtension(CFunctionPointer value); + + @CField + CFunctionPointer getIsMethodObsolete(); + + @CField + void setIsMethodObsolete(CFunctionPointer value); + + @CField + CFunctionPointer getSuspendThreadList(); + + @CField + void setSuspendThreadList(CFunctionPointer value); + + @CField + CFunctionPointer getResumeThreadList(); + + @CField + void setResumeThreadList(CFunctionPointer value); + + @CField + CFunctionPointer getAddModuleReads(); + + @CField + void setAddModuleReads(CFunctionPointer value); + + @CField + CFunctionPointer getAddModuleExports(); + + @CField + void setAddModuleExports(CFunctionPointer value); + + @CField + CFunctionPointer getAddModuleOpens(); + + @CField + void setAddModuleOpens(CFunctionPointer value); + + @CField + CFunctionPointer getAddModuleUses(); + + @CField + void setAddModuleUses(CFunctionPointer value); + + @CField + CFunctionPointer getAddModuleProvides(); + + @CField + void setAddModuleProvides(CFunctionPointer value); + + @CField + CFunctionPointer getIsModifiableModule(); + + @CField + void setIsModifiableModule(CFunctionPointer value); + + @CField + CFunctionPointer getGetAllStackTraces(); + + @CField + void setGetAllStackTraces(CFunctionPointer value); + + @CField + CFunctionPointer getGetThreadListStackTraces(); + + @CField + void setGetThreadListStackTraces(CFunctionPointer value); + + @CField + CFunctionPointer getGetThreadLocalStorage(); + + @CField + void setGetThreadLocalStorage(CFunctionPointer value); + + @CField + CFunctionPointer getSetThreadLocalStorage(); + + @CField + void setSetThreadLocalStorage(CFunctionPointer value); + + @CField + CFunctionPointer getGetStackTrace(); + + @CField + void setGetStackTrace(CFunctionPointer value); + + @CField + CFunctionPointer reserved105(); + + @CField + CFunctionPointer getGetTag(); + + @CField + void setGetTag(CFunctionPointer value); + + @CField + CFunctionPointer getSetTag(); + + @CField + void setSetTag(CFunctionPointer value); + + @CField + CFunctionPointer getForceGarbageCollection(); + + @CField + void setForceGarbageCollection(CFunctionPointer value); + + @CField + CFunctionPointer getIterateOverObjectsReachableFromObject(); + + @CField + void setIterateOverObjectsReachableFromObject(CFunctionPointer value); + + @CField + CFunctionPointer getIterateOverReachableObjects(); + + @CField + void setIterateOverReachableObjects(CFunctionPointer value); + + @CField + CFunctionPointer getIterateOverHeap(); + + @CField + void setIterateOverHeap(CFunctionPointer value); + + @CField + CFunctionPointer getIterateOverInstancesOfClass(); + + @CField + void setIterateOverInstancesOfClass(CFunctionPointer value); + + @CField + CFunctionPointer reserved113(); + + @CField + CFunctionPointer getGetObjectsWithTags(); + + @CField + void setGetObjectsWithTags(CFunctionPointer value); + + @CField + CFunctionPointer getFollowReferences(); + + @CField + void setFollowReferences(CFunctionPointer value); + + @CField + CFunctionPointer getIterateThroughHeap(); + + @CField + void setIterateThroughHeap(CFunctionPointer value); + + @CField + CFunctionPointer reserved117(); + + @CField + CFunctionPointer getSuspendAllVirtualThreads(); + + @CField + void setSuspendAllVirtualThreads(CFunctionPointer value); + + @CField + CFunctionPointer getResumeAllVirtualThreads(); + + @CField + void setResumeAllVirtualThreads(CFunctionPointer value); + + @CField + CFunctionPointer getSetJNIFunctionTable(); + + @CField + void setSetJNIFunctionTable(CFunctionPointer value); + + @CField + CFunctionPointer getGetJNIFunctionTable(); + + @CField + void setGetJNIFunctionTable(CFunctionPointer value); + + @CField + CFunctionPointer getSetEventCallbacks(); + + @CField + void setSetEventCallbacks(CFunctionPointer value); + + @CField + CFunctionPointer getGenerateEvents(); + + @CField + void setGenerateEvents(CFunctionPointer value); + + @CField + CFunctionPointer getGetExtensionFunctions(); + + @CField + void setGetExtensionFunctions(CFunctionPointer value); + + @CField + CFunctionPointer getGetExtensionEvents(); + + @CField + void setGetExtensionEvents(CFunctionPointer value); + + @CField + CFunctionPointer getSetExtensionEventCallback(); + + @CField + void setSetExtensionEventCallback(CFunctionPointer value); + + @CField + CFunctionPointer getDisposeEnvironment(); + + @CField + void setDisposeEnvironment(CFunctionPointer value); + + @CField + CFunctionPointer getGetErrorName(); + + @CField + void setGetErrorName(CFunctionPointer value); + + @CField + CFunctionPointer getGetJLocationFormat(); + + @CField + void setGetJLocationFormat(CFunctionPointer value); + + @CField + CFunctionPointer getGetSystemProperties(); + + @CField + void setGetSystemProperties(CFunctionPointer value); + + @CField + CFunctionPointer getGetSystemProperty(); + + @CField + void setGetSystemProperty(CFunctionPointer value); + + @CField + CFunctionPointer getSetSystemProperty(); + + @CField + void setSetSystemProperty(CFunctionPointer value); + + @CField + CFunctionPointer getGetPhase(); + + @CField + void setGetPhase(CFunctionPointer value); + + @CField + CFunctionPointer getGetCurrentThreadCpuTimerInfo(); + + @CField + void setGetCurrentThreadCpuTimerInfo(CFunctionPointer value); + + @CField + CFunctionPointer getGetCurrentThreadCpuTime(); + + @CField + void setGetCurrentThreadCpuTime(CFunctionPointer value); + + @CField + CFunctionPointer getGetThreadCpuTimerInfo(); + + @CField + void setGetThreadCpuTimerInfo(CFunctionPointer value); + + @CField + CFunctionPointer getGetThreadCpuTime(); + + @CField + void setGetThreadCpuTime(CFunctionPointer value); + + @CField + CFunctionPointer getGetTimerInfo(); + + @CField + void setGetTimerInfo(CFunctionPointer value); + + @CField + CFunctionPointer getGetTime(); + + @CField + void setGetTime(CFunctionPointer value); + + @CField + CFunctionPointer getGetPotentialCapabilities(); + + @CField + void setGetPotentialCapabilities(CFunctionPointer value); + + @CField + CFunctionPointer reserved141(); + + @CField + CFunctionPointer getAddCapabilities(); + + @CField + void setAddCapabilities(CFunctionPointer value); + + @CField + CFunctionPointer getRelinquishCapabilities(); + + @CField + void setRelinquishCapabilities(CFunctionPointer value); + + @CField + CFunctionPointer getGetAvailableProcessors(); + + @CField + void setGetAvailableProcessors(CFunctionPointer value); + + @CField + CFunctionPointer getGetClassVersionNumbers(); + + @CField + void setGetClassVersionNumbers(CFunctionPointer value); + + @CField + CFunctionPointer getGetConstantPool(); + + @CField + void setGetConstantPool(CFunctionPointer value); + + @CField + CFunctionPointer getGetEnvironmentLocalStorage(); + + @CField + void setGetEnvironmentLocalStorage(CFunctionPointer value); + + @CField + CFunctionPointer getSetEnvironmentLocalStorage(); + + @CField + void setSetEnvironmentLocalStorage(CFunctionPointer value); + + @CField + CFunctionPointer getAddToBootstrapClassLoaderSearch(); + + @CField + void setAddToBootstrapClassLoaderSearch(CFunctionPointer value); + + @CField + CFunctionPointer getSetVerboseFlag(); + + @CField + void setSetVerboseFlag(CFunctionPointer value); + + @CField + CFunctionPointer getAddToSystemClassLoaderSearch(); + + @CField + void setAddToSystemClassLoaderSearch(CFunctionPointer value); + + @CField + CFunctionPointer getRetransformClasses(); + + @CField + void setRetransformClasses(CFunctionPointer value); + + @CField + CFunctionPointer getGetOwnedMonitorStackDepthInfo(); + + @CField + void setGetOwnedMonitorStackDepthInfo(CFunctionPointer value); + + @CField + CFunctionPointer getGetObjectSize(); + + @CField + void setGetObjectSize(CFunctionPointer value); + + @CField + CFunctionPointer getGetLocalInstance(); + + @CField + void setGetLocalInstance(CFunctionPointer value); + + @CField + CFunctionPointer getSetHeapSamplingInterval(); + + @CField + void setSetHeapSamplingInterval(CFunctionPointer value); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiIterationControl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiIterationControl.java new file mode 100644 index 000000000000..a8040229aa8f --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiIterationControl.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CConstant; + +@CContext(JvmtiDirectives.class) +public final class JvmtiIterationControl { + // Checkstyle: stop: MethodName + + @CConstant + public static native int JVMTI_ITERATION_CONTINUE(); + + @CConstant + public static native int JVMTI_ITERATION_IGNORE(); + + @CConstant + public static native int JVMTI_ITERATION_ABORT(); + + // Checkstyle: resume +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLineNumberEntry.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLineNumberEntry.java new file mode 100644 index 000000000000..e96c2c7c05e7 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLineNumberEntry.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct(value = "jvmtiLineNumberEntry", addStructKeyword = true) +public interface JvmtiLineNumberEntry extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLineNumberEntryPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLineNumberEntryPointer.java new file mode 100644 index 000000000000..e1492de581c7 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLineNumberEntryPointer.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CPointerTo; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CPointerTo(JvmtiLineNumberEntry.class) +public interface JvmtiLineNumberEntryPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLocalVariableEntry.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLocalVariableEntry.java new file mode 100644 index 000000000000..bb89e0c9a4b8 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLocalVariableEntry.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct(value = "jvmtiLocalVariableEntry", addStructKeyword = true) +public interface JvmtiLocalVariableEntry extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLocalVariableEntryPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLocalVariableEntryPointer.java new file mode 100644 index 000000000000..8a52962b9e05 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiLocalVariableEntryPointer.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CPointerTo; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CPointerTo(JvmtiLocalVariableEntry.class) +public interface JvmtiLocalVariableEntryPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiMonitorStackDepthInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiMonitorStackDepthInfo.java new file mode 100644 index 000000000000..872a280c4cf1 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiMonitorStackDepthInfo.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct(value = "jvmtiMonitorStackDepthInfo", addStructKeyword = true) +public interface JvmtiMonitorStackDepthInfo extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiMonitorStackDepthInfoPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiMonitorStackDepthInfoPointer.java new file mode 100644 index 000000000000..3766c8f686bb --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiMonitorStackDepthInfoPointer.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CPointerTo; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CPointerTo(JvmtiMonitorStackDepthInfo.class) +public interface JvmtiMonitorStackDepthInfoPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiMonitorUsage.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiMonitorUsage.java new file mode 100644 index 000000000000..2598f0d8fc54 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiMonitorUsage.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct("jvmtiMonitorUsage") +public interface JvmtiMonitorUsage extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiObjectReferenceCallback.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiObjectReferenceCallback.java new file mode 100644 index 000000000000..b4938dd61146 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiObjectReferenceCallback.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.function.CFunctionPointer; +import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; +import org.graalvm.nativeimage.c.type.CLongPointer; +import org.graalvm.nativeimage.c.type.VoidPointer; + +public interface JvmtiObjectReferenceCallback extends CFunctionPointer { + @InvokeCFunctionPointer + int invoke(int objectReferenceKind, long classTag, long size, CLongPointer tagPtr, long referrerTag, int referrerIndex, VoidPointer userData); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiObjectReferenceKind.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiObjectReferenceKind.java new file mode 100644 index 000000000000..ca6cb54937ff --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiObjectReferenceKind.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CConstant; + +@CContext(JvmtiDirectives.class) +public final class JvmtiObjectReferenceKind { + // Checkstyle: stop: MethodName + + @CConstant + public static native int JVMTI_REFERENCE_CLASS(); + + @CConstant + public static native int JVMTI_REFERENCE_FIELD(); + + @CConstant + public static native int JVMTI_REFERENCE_ARRAY_ELEMENT(); + + @CConstant + public static native int JVMTI_REFERENCE_CLASS_LOADER(); + + @CConstant + public static native int JVMTI_REFERENCE_SIGNERS(); + + @CConstant + public static native int JVMTI_REFERENCE_PROTECTION_DOMAIN(); + + @CConstant + public static native int JVMTI_REFERENCE_INTERFACE(); + + @CConstant + public static native int JVMTI_REFERENCE_STATIC_FIELD(); + + @CConstant + public static native int JVMTI_REFERENCE_CONSTANT_POOL(); + + // Checkstyle: resume +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiPhase.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiPhase.java new file mode 100644 index 000000000000..9b82a1f24c5f --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiPhase.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CEnum; +import org.graalvm.nativeimage.c.constant.CEnumLookup; +import org.graalvm.nativeimage.c.constant.CEnumValue; + +@CContext(JvmtiDirectives.class) +@CEnum("jvmtiPhase") +public enum JvmtiPhase { + JVMTI_PHASE_ONLOAD, + JVMTI_PHASE_PRIMORDIAL, + JVMTI_PHASE_START, + JVMTI_PHASE_LIVE, + JVMTI_PHASE_DEAD; + + @CEnumValue + public native int getCValue(); + + @CEnumLookup + public static native JvmtiPhase fromValue(int value); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStackInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStackInfo.java new file mode 100644 index 000000000000..c58a93f7013f --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStackInfo.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CField; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct(value = "jvmtiStackInfo", addStructKeyword = true) +public interface JvmtiStackInfo extends PointerBase { + @CField("thread") + void setThread(JThread thread); + + @CField("thread") + JThread getThread(); + + @CField("state") + void setState(int state); + + @CField("state") + int getState(); + + @CField("frame_buffer") + void setFrameInfo(JvmtiFrameInfo frameInfo); + + @CField("frame_buffer") + JvmtiFrameInfo getFrameInfo(); + + @CField("frame_count") + void setFrameCount(int frameCount); + + @CField("frame_count") + int getFrameCount(); + +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStackInfoPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStackInfoPointer.java new file mode 100644 index 000000000000..6e7fe9ce3a84 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStackInfoPointer.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CPointerTo; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CPointerTo(JvmtiStackInfo.class) +public interface JvmtiStackInfoPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStackReferenceCallback.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStackReferenceCallback.java new file mode 100644 index 000000000000..17f54923a3d4 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStackReferenceCallback.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.function.CFunctionPointer; +import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; +import org.graalvm.nativeimage.c.type.CLongPointer; +import org.graalvm.nativeimage.c.type.VoidPointer; + +import com.oracle.svm.core.jni.headers.JNIMethodId; + +public interface JvmtiStackReferenceCallback extends CFunctionPointer { + @InvokeCFunctionPointer + int invoke(int heapRootKind, long classTag, long size, CLongPointer tagPtr, long threadTag, int depth, JNIMethodId method, int slot, VoidPointer userData); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStartFunctionPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStartFunctionPointer.java new file mode 100644 index 000000000000..5276357b4273 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiStartFunctionPointer.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.function.CFunctionPointer; +import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; +import org.graalvm.nativeimage.c.type.CCharPointer; + +import com.oracle.svm.core.jni.headers.JNIObjectHandle; + +public interface JvmtiStartFunctionPointer extends CFunctionPointer { + @InvokeCFunctionPointer + JNIObjectHandle invoke(JvmtiExternalEnv env, CCharPointer name); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiThreadGroupInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiThreadGroupInfo.java new file mode 100644 index 000000000000..70da8d80aac6 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiThreadGroupInfo.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CField; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.nativeimage.c.type.CCharPointer; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct("jvmtiThreadGroupInfo") +public interface JvmtiThreadGroupInfo extends PointerBase { + @CField("parent") + JThreadGroup getParent(); + + @CField("parent") + void setParent(JThreadGroup parent); + + @CField("name") + CCharPointer getName(); + + @CField("name") + void setName(CCharPointer name); + + @CField("max_priority") + int getMaxPriority(); + + @CField("max_priority") + void setMaxPriority(int maxPriority); + + @CField("is_daemon") + boolean getIsDaemon(); + + @CField("is_daemon") + void setIsDaemon(boolean isDaemon); + +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiThreadInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiThreadInfo.java new file mode 100644 index 000000000000..321cbaf5a835 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiThreadInfo.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CField; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.nativeimage.c.type.CCharPointer; +import org.graalvm.word.PointerBase; + +import com.oracle.svm.core.jni.headers.JNIObjectHandle; + +@CContext(JvmtiDirectives.class) +@CStruct("jvmtiThreadInfo") +public interface JvmtiThreadInfo extends PointerBase { + @CField("name") + CCharPointer getName(); + + @CField("name") + void setName(CCharPointer name); + + @CField("priority") + int getPriority(); + + @CField("priority") + void setPriority(int priority); + + @CField("is_daemon") + boolean getIsDaemon(); + + @CField("is_daemon") + void setIsDaemon(boolean isDaemon); + + @CField("thread_group") + JThreadGroup getThreadGroup(); + + @CField("thread_group") + void setThreadGroup(JThreadGroup jThreadGroup); + + @CField("context_class_loader") + JNIObjectHandle getContextClassLoader(); + + @CField("context_class_loader") + void setContextClassLoader(JNIObjectHandle contextClassLoader); + +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiThreadState.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiThreadState.java new file mode 100644 index 000000000000..c87b884b5485 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiThreadState.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CEnum; +import org.graalvm.nativeimage.c.constant.CEnumLookup; +import org.graalvm.nativeimage.c.constant.CEnumValue; + +@CContext(JvmtiDirectives.class) +@CEnum +public enum JvmtiThreadState { + JVMTI_THREAD_STATE_ALIVE, + JVMTI_THREAD_STATE_TERMINATED, + JVMTI_THREAD_STATE_RUNNABLE, + JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, + JVMTI_THREAD_STATE_WAITING, + JVMTI_THREAD_STATE_WAITING_INDEFINITELY, + JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT, + JVMTI_THREAD_STATE_SLEEPING, + JVMTI_THREAD_STATE_IN_OBJECT_WAIT, + JVMTI_THREAD_STATE_PARKED, + JVMTI_THREAD_STATE_SUSPENDED, + JVMTI_THREAD_STATE_INTERRUPTED, + JVMTI_THREAD_STATE_IN_NATIVE; + + @CEnumValue + public native int getCValue(); + + @CEnumLookup + public static native JvmtiThreadState fromValue(int value); +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiTimerInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiTimerInfo.java new file mode 100644 index 000000000000..906a86fe2a29 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiTimerInfo.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.struct.CStruct; +import org.graalvm.word.PointerBase; + +@CContext(JvmtiDirectives.class) +@CStruct("jvmtiTimerInfo") +public interface JvmtiTimerInfo extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiVerboseFlag.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiVerboseFlag.java new file mode 100644 index 000000000000..d7f907f3478b --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiVerboseFlag.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CConstant; + +@CContext(JvmtiDirectives.class) +public final class JvmtiVerboseFlag { + // Checkstyle: stop: MethodName + + @CConstant + public static native int JVMTI_VERBOSE_OTHER(); + + @CConstant + public static native int JVMTI_VERBOSE_GC(); + + @CConstant + public static native int JVMTI_VERBOSE_CLASS(); + + @CConstant + public static native int JVMTI_VERBOSE_JNI(); + + // Checkstyle: resume +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiVersion.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiVersion.java new file mode 100644 index 000000000000..f6e6724b9d2a --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiVersion.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; +import org.graalvm.nativeimage.c.CContext; +import org.graalvm.nativeimage.c.constant.CConstant; + +@CContext(JvmtiDirectives.class) +public final class JvmtiVersion { + private static final int JVMTI_VERSION_INTERFACE_JVMTI = 0x30000000; + private static final int LATEST_SUPPORTED_MAJOR_VERSION = 21; + + public static final int CURRENT_VERSION = JVMTI_VERSION_INTERFACE_JVMTI + LATEST_SUPPORTED_MAJOR_VERSION * 0x10000; + + @Platforms(Platform.HOSTED_ONLY.class) + private JvmtiVersion() { + } + + public static boolean isSupported(int version) { + if (isJvmtiVersion(version)) { + return isSupported0(version); + } + return false; + } + + private static boolean isJvmtiVersion(int version) { + return (version & JVMTI_VERSION_MASK_INTERFACE_TYPE()) == JVMTI_VERSION_INTERFACE_JVMTI; + } + + private static boolean isSupported0(int version) { + int major = (version & JVMTI_VERSION_MASK_MAJOR()) >> JVMTI_VERSION_SHIFT_MAJOR(); + int minor = (version & JVMTI_VERSION_MASK_MINOR()) >> JVMTI_VERSION_SHIFT_MINOR(); + /* The "micro" part of the version doesn't matter at the moment. */ + + if (major == 1) { + return minor >= 0 && minor <= 2; + } else if (major == 9 || major == 11) { + return minor == 0; + } else { + /* Since version 13, we do not care about minor versions. */ + return major >= 13 && major <= LATEST_SUPPORTED_MAJOR_VERSION; + } + } + + // Checkstyle: stop: MethodName + + @CConstant + private static native int JVMTI_VERSION_MASK_INTERFACE_TYPE(); + + @CConstant + private static native int JVMTI_VERSION_MASK_MAJOR(); + + @CConstant + private static native int JVMTI_VERSION_MASK_MINOR(); + + @CConstant + private static native int JVMTI_VERSION_SHIFT_MAJOR(); + + @CConstant + private static native int JVMTI_VERSION_SHIFT_MINOR(); + + // Checkstyle: resume +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/VoidPointerPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/VoidPointerPointer.java new file mode 100644 index 000000000000..17c4ae4e5cc3 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/VoidPointerPointer.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jvmti.headers; + +import org.graalvm.nativeimage.c.struct.CPointerTo; +import org.graalvm.nativeimage.c.type.VoidPointer; +import org.graalvm.word.PointerBase; + +@CPointerTo(VoidPointer.class) +public interface VoidPointerPointer extends PointerBase { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nmt/NmtCategory.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nmt/NmtCategory.java index ff71cdfabaed..9fb47fcd21eb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nmt/NmtCategory.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nmt/NmtCategory.java @@ -43,6 +43,8 @@ public enum NmtCategory { JNI("JNI"), /** JVM stat / perf data. */ JvmStat("jvmstat"), + /** Java Virtual Machine Tool Interface. */ + JVMTI("JVMTI"), /** NMT itself. */ NMT("Native Memory Tracking"), /** Profile-guided optimizations. */ diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ameta/HostedDynamicHubFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ameta/HostedDynamicHubFeature.java index a002f68a1f99..dfb9325d404a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ameta/HostedDynamicHubFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ameta/HostedDynamicHubFeature.java @@ -25,9 +25,9 @@ package com.oracle.svm.hosted.ameta; import com.oracle.graal.pointsto.meta.AnalysisMetaAccess; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.hub.DynamicHub; -import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.SVMHost; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jvmti/JvmtiFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jvmti/JvmtiFeature.java new file mode 100644 index 000000000000..fffdd5e340f7 --- /dev/null +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jvmti/JvmtiFeature.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.hosted.jvmti; + +import org.graalvm.nativeimage.AnnotationAccess; +import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.c.function.CEntryPoint; +import org.graalvm.nativeimage.c.function.CFunctionPointer; + +import com.oracle.graal.pointsto.meta.AnalysisMetaAccess; +import com.oracle.graal.pointsto.meta.AnalysisMethod; +import com.oracle.graal.pointsto.meta.AnalysisType; +import com.oracle.svm.core.SubstrateOptions; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.jdk.RuntimeSupport; +import com.oracle.svm.core.jvmti.JvmtiAgents; +import com.oracle.svm.core.jvmti.JvmtiEnvs; +import com.oracle.svm.core.jvmti.JvmtiFunctionTable; +import com.oracle.svm.core.jvmti.JvmtiFunctions; +import com.oracle.svm.core.jvmti.JvmtiSupport; +import com.oracle.svm.core.jvmti.headers.JvmtiInterface; +import com.oracle.svm.core.meta.MethodPointer; +import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.util.UserError; +import com.oracle.svm.core.util.VMError; +import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; +import com.oracle.svm.hosted.FeatureImpl.BeforeCompilationAccessImpl; +import com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl; +import com.oracle.svm.hosted.c.NativeLibraries; +import com.oracle.svm.hosted.c.info.ElementInfo; +import com.oracle.svm.hosted.c.info.StructFieldInfo; +import com.oracle.svm.hosted.c.info.StructInfo; +import com.oracle.svm.hosted.code.CEntryPointCallStubSupport; +import com.oracle.svm.hosted.code.CEntryPointData; +import com.oracle.svm.hosted.meta.HostedMethod; +import com.oracle.svm.hosted.meta.HostedType; + +import jdk.vm.ci.meta.MetaAccessProvider; +import jdk.vm.ci.meta.ResolvedJavaType; + +/** + * Prepares the JVMTI infrastructure and puts it into the image so that JVMTI support is available + * at run-time. For more information on JVMTI in general, please refer to the + * specification. + */ +@AutomaticallyRegisteredFeature +public class JvmtiFeature implements InternalFeature { + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return SubstrateOptions.JVMTI.getValue(); + } + + @Override + public void duringSetup(DuringSetupAccess access) { + UserError.guarantee(SubstrateOptions.JNI.getValue(), "JVMTI requires JNI. Please use option '%s' to enable JNI.", SubstrateOptionsParser.commandArgument(SubstrateOptions.JNI, "+")); + + ImageSingletons.add(JvmtiSupport.class, new JvmtiSupport()); + ImageSingletons.add(JvmtiAgents.class, new JvmtiAgents()); + ImageSingletons.add(JvmtiEnvs.class, new JvmtiEnvs()); + ImageSingletons.add(JvmtiFunctionTable.class, new JvmtiFunctionTable()); + + RuntimeSupport.getRuntimeSupport().addInitializationHook(JvmtiSupport.initializationHook()); + RuntimeSupport.getRuntimeSupport().addTearDownHook(JvmtiSupport.teardownHook()); + } + + @Override + public void beforeAnalysis(BeforeAnalysisAccess arg) { + BeforeAnalysisAccessImpl access = (BeforeAnalysisAccessImpl) arg; + AnalysisMetaAccess metaAccess = access.getMetaAccess(); + registerCEntryPoints(metaAccess); + } + + private static void registerCEntryPoints(AnalysisMetaAccess metaAccess) { + /* Manually add the CEntryPoints, so that this is only done when JVMTI is enabled. */ + AnalysisType type = metaAccess.lookupJavaType(JvmtiFunctions.class); + for (AnalysisMethod method : type.getDeclaredMethods(false)) { + VMError.guarantee(AnnotationAccess.getAnnotation(method, CEntryPoint.class) != null, "Method %s does not have a @CEntryPoint annotation.", method.format("%H.%n(%p)")); + CEntryPointCallStubSupport.singleton().registerStubForMethod(method, () -> CEntryPointData.create(method)); + } + } + + @Override + public void beforeCompilation(BeforeCompilationAccess a) { + BeforeCompilationAccessImpl access = (BeforeCompilationAccessImpl) a; + fillJvmtiFunctionTable(access); + + /* CFunctionPointers are relocatable, so they must be in the read-only image heap. */ + access.registerAsImmutable(JvmtiFunctionTable.singleton().getReadOnlyFunctionTable()); + } + + private static void fillJvmtiFunctionTable(CompilationAccessImpl access) { + NativeLibraries nativeLibraries = access.getNativeLibraries(); + MetaAccessProvider metaAccess = access.getMetaAccess(); + + ResolvedJavaType jvmtiInterface = metaAccess.lookupJavaType(JvmtiInterface.class); + StructInfo jvmtiInterfaceMetadata = (StructInfo) nativeLibraries.findElementInfo(jvmtiInterface); + + JvmtiFunctionTable functionTable = JvmtiFunctionTable.singleton(); + HostedType type = access.getMetaAccess().lookupJavaType(JvmtiFunctions.class); + for (HostedMethod method : type.getDeclaredMethods(false)) { + StructFieldInfo field = findFieldFor(jvmtiInterfaceMetadata, method.getName()); + int offset = field.getOffsetInfo().getProperty(); + functionTable.init(offset, getStubFunctionPointer(access, method)); + } + } + + private static CFunctionPointer getStubFunctionPointer(CompilationAccessImpl access, HostedMethod method) { + AnalysisMethod stub = CEntryPointCallStubSupport.singleton().getStubForMethod(method.getWrapped()); + return new MethodPointer(access.getUniverse().lookup(stub)); + } + + private static StructFieldInfo findFieldFor(StructInfo info, String name) { + for (ElementInfo element : info.getChildren()) { + if (element instanceof StructFieldInfo field) { + if (field.getName().equals(name)) { + return field; + } + } + } + throw VMError.shouldNotReachHere("Cannot find function table field for: " + name); + } +}