Skip to content

[GR-38674] Fix JFR-related UnsatisfiedLinkErrors. #11203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getEnabledMonitoringFeatures() {
return new HashSet<>(EnableMonitoringFeatures.getValue().values());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,13 @@
*/
public class JfrJavaEvents {
private static final List<Class<? extends jdk.internal.event.Event>> EVENT_CLASSES = new ArrayList<>();
private static final List<Class<? extends jdk.jfr.Event>> JFR_EVENT_CLASSES = new ArrayList<>();

@Platforms(Platform.HOSTED_ONLY.class)
@SuppressWarnings("unchecked")
public static synchronized void registerEventClass(Class<? extends jdk.internal.event.Event> eventClass) {
EVENT_CLASSES.add(eventClass);
if (jdk.jfr.Event.class.isAssignableFrom(eventClass)) {
JFR_EVENT_CLASSES.add((Class<? extends jdk.jfr.Event>) eventClass);
}
}

public static List<Class<? extends jdk.internal.event.Event>> getAllEventClasses() {
return EVENT_CLASSES;
}

public static List<Class<? extends jdk.jfr.Event>> getJfrEventClasses() {
return JFR_EVENT_CLASSES;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Loading