Skip to content

Commit

Permalink
Add reflection metadata for jfrTracing field.
Browse files Browse the repository at this point in the history
(cherry picked from commit e816ad6)
  • Loading branch information
jovanstevanovic authored and zakkak committed Jul 23, 2024
1 parent 31964af commit c087a0f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@
"jdk.internal.module",
"sun.text.spi",
"jdk.internal.reflect",
"sun.nio.ch",
"sun.util.cldr",
"sun.util.locale",
"sun.invoke.util",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@
*/
package com.oracle.svm.hosted.jfr;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.RandomAccessFile;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization;
import org.graalvm.nativeimage.hosted.RuntimeReflection;

import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
import com.oracle.svm.core.feature.InternalFeature;
Expand All @@ -45,10 +48,12 @@
import com.oracle.svm.core.meta.SharedType;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.hosted.FeatureImpl;
import com.oracle.svm.hosted.reflect.ReflectionFeature;

import jdk.internal.event.Event;
import jdk.jfr.internal.JVM;
import jdk.vm.ci.meta.MetaAccessProvider;
import sun.nio.ch.FileChannelImpl;

/**
* Support for Java-level JFR events. This feature is only present if the {@link JfrFeature} is used
Expand All @@ -63,7 +68,16 @@ public boolean isInConfiguration(IsInConfigurationAccess access) {

@Override
public List<Class<? extends Feature>> getRequiredFeatures() {
return Collections.singletonList(JfrFeature.class);
return List.of(JfrFeature.class, ReflectionFeature.class);
}

@Override
public void afterRegistration(AfterRegistrationAccess access) {
RuntimeReflection.registerFieldLookup(Throwable.class, "jfrTracing");
RuntimeReflection.registerFieldLookup(FileInputStream.class, "jfrTracing");
RuntimeReflection.registerFieldLookup(FileOutputStream.class, "jfrTracing");
RuntimeReflection.registerFieldLookup(FileChannelImpl.class, "jfrTracing");
RuntimeReflection.registerFieldLookup(RandomAccessFile.class, "jfrTracing");
}

@Override
Expand Down

0 comments on commit c087a0f

Please sign in to comment.