diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VMInspectionOptions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VMInspectionOptions.java index 6b7263118918..91dca8316353 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VMInspectionOptions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VMInspectionOptions.java @@ -141,6 +141,12 @@ public static String getHeapDumpNotSupportedMessage() { SubstrateOptionsParser.commandArgument(EnableMonitoringFeatures, MONITORING_HEAPDUMP_NAME) + "'."; } + @Fold + public static String getJfrNotSupportedMessage() { + return "JFR is only supported on Linux and MacOS for native binaries built with '" + + SubstrateOptionsParser.commandArgument(EnableMonitoringFeatures, MONITORING_JFR_NAME) + "'."; + } + private static Set getEnabledMonitoringFeatures() { return new HashSet<>(EnableMonitoringFeatures.getValue().values()); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJavaEvents.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJavaEvents.java index b7be9929e6e1..dbaa73ab9359 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJavaEvents.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJavaEvents.java @@ -35,22 +35,13 @@ */ public class JfrJavaEvents { private static final List> EVENT_CLASSES = new ArrayList<>(); - private static final List> JFR_EVENT_CLASSES = new ArrayList<>(); @Platforms(Platform.HOSTED_ONLY.class) - @SuppressWarnings("unchecked") public static synchronized void registerEventClass(Class eventClass) { EVENT_CLASSES.add(eventClass); - if (jdk.jfr.Event.class.isAssignableFrom(eventClass)) { - JFR_EVENT_CLASSES.add((Class) eventClass); - } } public static List> getAllEventClasses() { return EVENT_CLASSES; } - - public static List> getJfrEventClasses() { - return JFR_EVENT_CLASSES; - } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java index e663f931ccf9..d12027357a6d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java @@ -31,9 +31,12 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.ProcessProperties; +import org.graalvm.nativeimage.hosted.FieldValueTransformer; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.RecomputeFieldValue; +import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.util.VMError; @@ -71,14 +74,25 @@ public static void createNativeJFR() { } } -@TargetClass(className = "jdk.jfr.internal.JVMSupport", onlyWith = HasJfrSupport.class) +@TargetClass(className = "jdk.jfr.internal.JVMSupport") final class Target_jdk_jfr_internal_JVMSupport { + @Alias // + @RecomputeFieldValue(kind = Kind.Custom, declClass = JfrNotAvailableTransformer.class, isFinal = true) // + private static boolean notAvailable; + @Substitute public static String makeFilename(Recording recording) { return JfrFilenameUtil.makeFilename(recording); } } +final class JfrNotAvailableTransformer implements FieldValueTransformer { + @Override + public Object transform(Object receiver, Object originalValue) { + return !HasJfrSupport.get(); + } +} + @TargetClass(className = "jdk.jfr.internal.util.ValueFormatter", onlyWith = HasJfrSupport.class) final class Target_jdk_jfr_internal_util_ValueFormatter { @Alias diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrRecorderThread.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrRecorderThread.java index f586ee49b499..6e28690d99b6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrRecorderThread.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrRecorderThread.java @@ -130,21 +130,13 @@ private void persistBuffers(JfrChunkWriter chunkWriter) { } if (chunkWriter.shouldRotateDisk()) { - Object chunkRotationMonitor = getChunkRotationMonitor(); + Object chunkRotationMonitor = Target_jdk_jfr_internal_JVM.CHUNK_ROTATION_MONITOR; synchronized (chunkRotationMonitor) { chunkRotationMonitor.notifyAll(); } } } - private static Object getChunkRotationMonitor() { - if (HasChunkRotationMonitorField.get()) { - return Target_jdk_jfr_internal_JVM.CHUNK_ROTATION_MONITOR; - } else { - return Target_jdk_jfr_internal_JVM.FILE_DELTA_CHANGE; - } - } - @Uninterruptible(reason = "Locking without transition requires that the whole critical section is uninterruptible.") private static void tryPersistBuffer(JfrChunkWriter chunkWriter, JfrBufferNode node) { if (JfrBufferNodeAccess.tryLock(node)) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java index 62ea29711c24..1a196b5bbbc1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java @@ -24,41 +24,37 @@ */ package com.oracle.svm.core.jfr; +import static com.oracle.svm.core.jfr.Target_jdk_jfr_internal_JVM_Util.jfrNotSupportedException; + import java.util.List; -import java.util.function.BooleanSupplier; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.ProcessProperties; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.VMInspectionOptions; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.container.Container; import com.oracle.svm.core.container.OperatingSystem; import com.oracle.svm.core.jfr.traceid.JfrTraceId; import com.oracle.svm.core.util.PlatformTimeUtils; -import com.oracle.svm.core.util.VMError; -import com.oracle.svm.util.ReflectionUtil; -import jdk.graal.compiler.api.replacements.Fold; import jdk.jfr.internal.JVM; import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.event.EventWriter; +/** + * The substitutions below are always active, even if the JFR support is disabled. Otherwise, we + * would see an {@link UnsatisfiedLinkError} if a JFR native method is called at run-time. + */ @SuppressWarnings({"static-method", "unused"}) -@TargetClass(value = jdk.jfr.internal.JVM.class, onlyWith = HasJfrSupport.class) +@TargetClass(value = jdk.jfr.internal.JVM.class) public final class Target_jdk_jfr_internal_JVM { // Checkstyle: stop @Alias // - @TargetElement(onlyWith = HasChunkRotationMonitorField.class) // static Object CHUNK_ROTATION_MONITOR; - - @Alias // - @TargetElement(onlyWith = HasFileDeltaChangeField.class) // - static Object FILE_DELTA_CHANGE; // Checkstyle: resume @Alias // @@ -70,14 +66,21 @@ public final class Target_jdk_jfr_internal_JVM { private static void registerNatives() { } + /** See {@link JVM#markChunkFinal}. */ @Substitute public static void markChunkFinal() { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().markChunkFinal(); } /** See {@link JVM#beginRecording}. */ @Substitute public static void beginRecording() { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().beginRecording(); } @@ -85,12 +88,19 @@ public static void beginRecording() { @Substitute @Uninterruptible(reason = "Needed for calling SubstrateJVM.isRecording().") public static boolean isRecording() { + if (!HasJfrSupport.get()) { + return false; + } return SubstrateJVM.get().isRecording(); } /** See {@link JVM#endRecording}. */ @Substitute public static void endRecording() { + if (!HasJfrSupport.get()) { + /* Nothing to do. */ + return; + } SubstrateJVM.get().endRecording(); } @@ -122,6 +132,10 @@ public static long getUnloadedEventClassCount() { @Substitute @Uninterruptible(reason = "Needed for SubstrateJVM.getClassId().") public static long getClassId(Class clazz) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } + /* * The result is only valid until the epoch changes but this is fine because EventWriter * instances are invalidated when the epoch changes. @@ -140,6 +154,10 @@ public static String getPid() { @Substitute @Uninterruptible(reason = "Needed for SubstrateJVM.getStackTraceId().") public static long getStackTraceId(int skipCount, long stackFilterId) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } + /* * The result is only valid until the epoch changes but this is fine because EventWriter * instances are invalidated when the epoch changes. @@ -147,17 +165,21 @@ public static long getStackTraceId(int skipCount, long stackFilterId) { return SubstrateJVM.get().getStackTraceId(skipCount); } + /** See {@link JVM#registerStackFilter}. */ @Substitute public static long registerStackFilter(String[] classes, String[] methods) { - throw VMError.unimplemented("JFR StackFilters are not yet supported."); + throw new UnsupportedOperationException("JFR stack filters are not supported at the moment."); } + /** See {@link JVM#unregisterStackFilter}. */ @Substitute public static void unregisterStackFilter(long stackFilterId) { - throw VMError.unimplemented("JFR StackFilters are not yet supported."); + /* Ignore the call for now (registerStackFilter() is not implemented). */ } /** + * See {@link JVM#setMiscellaneous}. + *

* As of 22+27, This method is both used to set cutoff tick values for leak profiling and * for @Deprecated events. Note that this method is called during JFR startup. */ @@ -169,6 +191,9 @@ public static void setMiscellaneous(long eventTypeId, long value) { /** See {@link JVM#getThreadId}. */ @Substitute public static long getThreadId(Thread t) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.getThreadId(t); } @@ -187,18 +212,27 @@ public static long nanosNow() { /** See {@link JVM#log}. */ @Substitute public static void log(int tagSetId, int level, String message) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().log(tagSetId, level, message); } /** See {@link JVM#logEvent}. */ @Substitute public static void logEvent(int level, String[] lines, boolean system) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().logEvent(level, lines, system); } /** See {@link JVM#subscribeLogLevel}. */ @Substitute public static void subscribeLogLevel(LogTag lt, int tagSetId) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().subscribeLogLevel(lt, tagSetId); } @@ -211,42 +245,63 @@ public static synchronized void retransformClasses(Class[] classes) { /** See {@link JVM#setEnabled}. */ @Substitute public static void setEnabled(long eventTypeId, boolean enabled) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setEnabled(eventTypeId, enabled); } /** See {@link JVM#setFileNotification}. */ @Substitute public static void setFileNotification(long delta) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setFileNotification(delta); } /** See {@link JVM#setGlobalBufferCount}. */ @Substitute public static void setGlobalBufferCount(long count) throws IllegalArgumentException, IllegalStateException { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setGlobalBufferCount(count); } /** See {@link JVM#setGlobalBufferSize}. */ @Substitute public static void setGlobalBufferSize(long size) throws IllegalArgumentException { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setGlobalBufferSize(size); } /** See {@link JVM#setMemorySize}. */ @Substitute public static void setMemorySize(long size) throws IllegalArgumentException { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setMemorySize(size); } /** See {@code JVM#setMethodSamplingPeriod}. */ @Substitute public static void setMethodSamplingPeriod(long type, long intervalMillis) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setMethodSamplingInterval(type, intervalMillis); } /** See {@link JVM#setOutput}. */ @Substitute public static void setOutput(String file) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setOutput(file); } @@ -258,36 +313,54 @@ public static void setForceInstrumentation(boolean force) { /** See {@link JVM#setCompressedIntegers}. */ @Substitute public static void setCompressedIntegers(boolean compressed) throws IllegalStateException { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setCompressedIntegers(compressed); } /** See {@link JVM#setStackDepth}. */ @Substitute public static void setStackDepth(int depth) throws IllegalArgumentException, IllegalStateException { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setStackDepth(depth); } /** See {@link JVM#setStackTraceEnabled}. */ @Substitute public static void setStackTraceEnabled(long eventTypeId, boolean enabled) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setStackTraceEnabled(eventTypeId, enabled); } /** See {@link JVM#setThreadBufferSize}. */ @Substitute public static void setThreadBufferSize(long size) throws IllegalArgumentException, IllegalStateException { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setThreadBufferSize(size); } /** See {@link JVM#setThreshold}. */ @Substitute public static boolean setThreshold(long eventTypeId, long ticks) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().setThreshold(eventTypeId, ticks); } /** See {@link JVM#storeMetadataDescriptor}. */ @Substitute public static void storeMetadataDescriptor(byte[] bytes) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().storeMetadataDescriptor(bytes); } @@ -300,19 +373,25 @@ public static boolean getAllowedToDoEventRetransforms() { /** See {@link JVM#createJFR}. */ @Substitute private static boolean createJFR(boolean simulateFailure) throws IllegalStateException { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().createJFR(simulateFailure); } /** See {@link JVM#destroyJFR}. */ @Substitute private static boolean destroyJFR() { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().destroyJFR(); } /** See {@link JVM#isAvailable}. */ @Substitute public static boolean isAvailable() { - return true; + return HasJfrSupport.get(); } /** See {@link JVM#getTimeConversionFactor}. */ @@ -324,58 +403,90 @@ public static double getTimeConversionFactor() { /** See {@link JVM#getTypeId(Class)}. */ @Substitute public static long getTypeId(Class clazz) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return JfrTraceId.getTraceId(clazz); } /** See {@link JVM#getEventWriter}. */ @Substitute public static Target_jdk_jfr_internal_event_EventWriter getEventWriter() { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().getEventWriter(); } /** See {@link JVM#newEventWriter}. */ @Substitute public static Target_jdk_jfr_internal_event_EventWriter newEventWriter() { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().newEventWriter(); } - /** See {@link JVM#flush}. */ + /** See {@link JVM#flush(EventWriter, int, int)}. */ @Substitute public static void flush(Target_jdk_jfr_internal_event_EventWriter writer, int uncommittedSize, int requestedSize) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().flush(writer, uncommittedSize, requestedSize); } + /** See {@link JVM#flush()}. */ @Substitute public static void flush() { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().flush(); } + /** See {@link JVM#commit}. */ @Substitute public static long commit(long nextPosition) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().commit(nextPosition); } /** See {@link JVM#setRepositoryLocation}. */ @Substitute public static void setRepositoryLocation(String dirText) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setRepositoryLocation(dirText); } /** See {@code JVM#setDumpPath(String)}. */ @Substitute public static void setDumpPath(String dumpPathText) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().setDumpPath(dumpPathText); } /** See {@code JVM#getDumpPath()}. */ @Substitute public static String getDumpPath() { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().getDumpPath(); } /** See {@link JVM#abort}. */ @Substitute public static void abort(String errorMsg) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().abort(errorMsg); } @@ -388,74 +499,116 @@ public static boolean addStringConstant(long id, String s) { /** See {@link JVM#uncaughtException}. */ @Substitute public static void uncaughtException(Thread thread, Throwable t) { - // Would be used to determine the emergency dump filename if an exception happens during - // shutdown. + /* + * Would be used to determine the emergency dump filename if an exception happens during + * shutdown. + */ } /** See {@link JVM#setCutoff}. */ @Substitute public static boolean setCutoff(long eventTypeId, long cutoffTicks) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().setCutoff(eventTypeId, cutoffTicks); } /** See {@link JVM#setThrottle}. */ @Substitute public static boolean setThrottle(long eventTypeId, long eventSampleSize, long periodMs) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().setThrottle(eventTypeId, eventSampleSize, periodMs); } /** See {@link JVM#emitOldObjectSamples}. */ @Substitute public static void emitOldObjectSamples(long cutoff, boolean emitAll, boolean skipBFS) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } SubstrateJVM.get().emitOldObjectSamples(cutoff, emitAll, skipBFS); } /** See {@link JVM#shouldRotateDisk}. */ @Substitute public static boolean shouldRotateDisk() { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().shouldRotateDisk(); } + /** See {@link JVM#include}. */ @Substitute public static void include(Thread thread) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } JfrThreadLocal.setExcluded(thread, false); } + /** See {@link JVM#exclude}. */ @Substitute public static void exclude(Thread thread) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } JfrThreadLocal.setExcluded(thread, true); } + /** See {@link JVM#isExcluded(Thread)}. */ @Substitute public static boolean isExcluded(Thread thread) { + if (!HasJfrSupport.get()) { + return true; + } return JfrThreadLocal.isThreadExcluded(thread); } + /** See {@link JVM#isExcluded(Class)}. */ @Substitute public static boolean isExcluded(Class eventClass) { - // Temporarily always include. - return false; + /* For now, assume that event classes are only excluded if JFR support is disabled. */ + return !HasJfrSupport.get(); } + /** See {@link JVM#isInstrumented}. */ @Substitute public static boolean isInstrumented(Class eventClass) { - // This should check for blessed commit methods in the event class [GR-41200] - return true; + /* + * Assume that event classes are instrumented if JFR support is present. This method should + * ideally check for blessed commit methods in the event class, see GR-41200. + */ + return HasJfrSupport.get(); } - /** See {@link SubstrateJVM#getChunkStartNanos}. */ + /** See {@link JVM#getChunkStartNanos}. */ @Substitute public static long getChunkStartNanos() { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().getChunkStartNanos(); } + /** See {@link JVM#setConfiguration}. */ @Substitute public static boolean setConfiguration(Class eventClass, Target_jdk_jfr_internal_event_EventConfiguration configuration) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().setConfiguration(eventClass, configuration); } + /** See {@link JVM#getConfiguration}. */ @Substitute public static Object getConfiguration(Class eventClass) { + if (!HasJfrSupport.get()) { + throw jfrNotSupportedException(); + } return SubstrateJVM.get().getConfiguration(eventClass); } @@ -466,28 +619,31 @@ public static long getTypeId(String name) { return -1; } + /** See {@link JVM#isContainerized}. */ @Substitute public static boolean isContainerized() { return Container.singleton().isContainerized(); } /** - * Return the total memory available on the host. - * - * This is unconditionally using {@link OperatingSystem#getPhysicalMemorySize} since we are - * interested in the host values (and not the containerized values). + * See {@link JVM#hostTotalMemory()}. + *

+ * This calls {@link OperatingSystem#getPhysicalMemorySize} since we are interested in the host + * values (and not the containerized values). */ @Substitute public static long hostTotalMemory() { return OperatingSystem.singleton().getPhysicalMemorySize().rawValue(); } + /** See {@link JVM#hostTotalSwapMemory}. */ @Substitute public static long hostTotalSwapMemory() { /* Not implemented at the moment. */ return -1; } + /** See {@link JVM#isProduct}. */ @Substitute public static boolean isProduct() { /* @@ -498,26 +654,8 @@ public static boolean isProduct() { } } -class HasChunkRotationMonitorField implements BooleanSupplier { - private static final boolean HAS_FIELD = ReflectionUtil.lookupField(true, JVM.class, "CHUNK_ROTATION_MONITOR") != null; - - @Override - public boolean getAsBoolean() { - return HAS_FIELD; - } - - @Fold - public static boolean get() { - return HAS_FIELD; - } -} - -@Platforms(Platform.HOSTED_ONLY.class) -class HasFileDeltaChangeField implements BooleanSupplier { - private static final boolean HAS_FIELD = ReflectionUtil.lookupField(true, JVM.class, "FILE_DELTA_CHANGE") != null; - - @Override - public boolean getAsBoolean() { - return HAS_FIELD; +class Target_jdk_jfr_internal_JVM_Util { + static UnsupportedOperationException jfrNotSupportedException() { + throw new UnsupportedOperationException(VMInspectionOptions.getJfrNotSupportedMessage()); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventConfiguration.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventConfiguration.java index e558119e9d22..2e7c590498f1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventConfiguration.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventConfiguration.java @@ -26,6 +26,6 @@ import com.oracle.svm.core.annotate.TargetClass; -@TargetClass(className = "jdk.jfr.internal.event.EventConfiguration", onlyWith = HasJfrSupport.class) +@TargetClass(className = "jdk.jfr.internal.event.EventConfiguration") public final class Target_jdk_jfr_internal_event_EventConfiguration { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java index a33fb810f7cf..5371e7e85390 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java @@ -27,7 +27,7 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.TargetClass; -@TargetClass(className = "jdk.jfr.internal.event.EventWriter", onlyWith = HasJfrSupport.class) +@TargetClass(className = "jdk.jfr.internal.event.EventWriter") public final class Target_jdk_jfr_internal_event_EventWriter { @Alias // boolean excluded;