Skip to content

Commit d054444

Browse files
committed
Avoid emitting rmi library.
It is not needed as it only provides an implementation for `maxObjectInspectionAge()`, which is substituted in SVM.
1 parent efcb517 commit d054444

File tree

4 files changed

+18
-22
lines changed

4 files changed

+18
-22
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_sun_rmi_transport_GC.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2022, 2022, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -26,12 +26,22 @@
2626

2727
package com.oracle.svm.core.jdk;
2828

29+
import com.oracle.svm.core.annotate.Alias;
30+
import com.oracle.svm.core.annotate.RecomputeFieldValue;
2931
import com.oracle.svm.core.annotate.Substitute;
3032
import com.oracle.svm.core.annotate.TargetClass;
3133
import com.oracle.svm.core.heap.Heap;
3234

35+
/**
36+
* Note that sun.rmi.transport.GC is initialized at build-time to avoid including the rmi library,
37+
* which is not needed as it only implements the native maxObjectInspectionAge() method, which in
38+
* turn is {@link Target_sun_rmi_transport_GC#maxObjectInspectionAge substituted in here}.
39+
*/
3340
@TargetClass(className = "sun.rmi.transport.GC")
3441
final class Target_sun_rmi_transport_GC {
42+
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)//
43+
private static Thread daemon = null;
44+
3545
@Substitute
3646
public static long maxObjectInspectionAge() {
3747
return Heap.getHeap().getMillisSinceLastWholeHeapExamined();

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JDKInitializationFeature.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ public void afterRegistration(AfterRegistrationAccess access) {
159159
rci.initializeAtBuildTime("apple.security", JDK_CLASS_REASON);
160160
}
161161

162+
rci.initializeAtBuildTime("sun.rmi.transport.GC", "Loaded an unneeded library (rmi) in static initializer.");
163+
162164
rci.rerunInitialization("com.sun.jndi.dns.DnsClient", "Contains Random references, therefore can't be included in the image heap.");
163165
rci.rerunInitialization("sun.net.www.protocol.http.DigestAuthentication$Parameters", "Contains Random references, therefore can't be included in the image heap.");
164166
rci.rerunInitialization("sun.security.krb5.KrbServiceLocator", "Contains Random references, therefore can't be included in the image heap.");

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JmxClientFeature.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2022, 2022, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -25,18 +25,14 @@
2525
*/
2626
package com.oracle.svm.hosted.jdk;
2727

28-
import com.oracle.svm.core.feature.InternalFeature;
2928
import org.graalvm.nativeimage.hosted.RuntimeReflection;
3029

30+
import com.oracle.svm.core.VMInspectionOptions;
31+
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
32+
import com.oracle.svm.core.feature.InternalFeature;
3133
import com.oracle.svm.core.jdk.JNIRegistrationUtil;
32-
import com.oracle.svm.core.util.VMError;
33-
34-
import com.oracle.svm.core.jdk.NativeLibrarySupport;
35-
import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl;
36-
import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport;
3734
import com.oracle.svm.core.jni.JNIRuntimeAccess;
38-
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
39-
import com.oracle.svm.core.VMInspectionOptions;
35+
import com.oracle.svm.core.util.VMError;
4036
import com.oracle.svm.util.ReflectionUtil;
4137

4238
@AutomaticallyRegisteredFeature
@@ -46,22 +42,11 @@ public boolean isInConfiguration(IsInConfigurationAccess access) {
4642
return VMInspectionOptions.hasJmxClientSupport();
4743
}
4844

49-
private static void handleNativeLibraries(BeforeAnalysisAccess access) {
50-
BeforeAnalysisAccessImpl a = (BeforeAnalysisAccessImpl) access;
51-
NativeLibrarySupport.singleton().preregisterUninitializedBuiltinLibrary("rmi");
52-
a.getNativeLibraries().addStaticJniLibrary("rmi");
53-
54-
// Resolve calls to sun_rmi_transport* as builtIn. For calls to native method
55-
// maxObjectInspectionAge()
56-
PlatformNativeLibrarySupport.singleton().addBuiltinPkgNativePrefix("sun_rmi_transport");
57-
}
58-
5945
@Override
6046
public void beforeAnalysis(BeforeAnalysisAccess access) {
6147
try {
6248
configureJNI();
6349
configureReflection(access);
64-
handleNativeLibraries(access);
6550
} catch (Exception e) {
6651
throw VMError.shouldNotReachHere("ManagementClientFeature configuration failed: " + e);
6752
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JmxCommonFeature.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public void afterRegistration(AfterRegistrationAccess access) {
9494
rci.initializeAtRunTime("com.sun.jmx.remote.security.JMXPluggableAuthenticator$FileLoginConfig", "JMX support");
9595
rci.initializeAtRunTime("sun.rmi.transport.DGCImpl", "JMX support");
9696
rci.initializeAtRunTime("sun.rmi.transport.DGCAckHandler", "JMX support");
97-
rci.initializeAtRunTime("sun.rmi.transport.GC", "JMX support");
9897
rci.initializeAtRunTime("sun.rmi.transport.DGCClient", "JMX support");
9998
rci.initializeAtRunTime("sun.rmi.transport.ObjectTable", "JMX support");
10099
rci.initializeAtRunTime("sun.rmi.transport.tcp.TCPEndpoint", "JMX support");

0 commit comments

Comments
 (0)