@@ -150,7 +150,6 @@ public static void registerPreservedClasses(NativeImageClassLoaderSupport classL
150
150
.toList ();
151
151
152
152
final RuntimeReflectionSupport reflection = ImageSingletons .lookup (RuntimeReflectionSupport .class );
153
- final RuntimeJNIAccessSupport jni = ImageSingletons .lookup (RuntimeJNIAccessSupport .class );
154
153
final RuntimeProxyCreationSupport proxy = ImageSingletons .lookup (RuntimeProxyCreationSupport .class );
155
154
final ConfigurationCondition always = ConfigurationCondition .alwaysTrue ();
156
155
@@ -178,20 +177,29 @@ public static void registerPreservedClasses(NativeImageClassLoaderSupport classL
178
177
proxy .addProxyClass (always , c );
179
178
}
180
179
181
- jni .register (ConfigurationCondition .alwaysTrue (), c );
182
180
try {
183
- for (Method declaredMethod : c .getDeclaredMethods ()) {
184
- jni .register (always , false , declaredMethod );
185
- }
186
- for (Constructor <?> declaredConstructor : c .getDeclaredConstructors ()) {
187
- jni .register (always , false , declaredConstructor );
188
- }
189
181
for (Field declaredField : c .getDeclaredFields ()) {
190
- jni .register (always , false , declaredField );
191
182
reflection .register (always , false , declaredField );
192
183
}
193
184
} catch (LinkageError e ) {
194
- /* If we can't link we can not register for JNI and reflection */
185
+ /* If we can't link we can not register for reflection */
186
+ }
187
+ if (SubstrateOptions .JNI .getValue ()) {
188
+ final RuntimeJNIAccessSupport jni = ImageSingletons .lookup (RuntimeJNIAccessSupport .class );
189
+ jni .register (always , c );
190
+ try {
191
+ for (Method declaredMethod : c .getDeclaredMethods ()) {
192
+ jni .register (always , false , declaredMethod );
193
+ }
194
+ for (Constructor <?> declaredConstructor : c .getDeclaredConstructors ()) {
195
+ jni .register (always , false , declaredConstructor );
196
+ }
197
+ for (Field declaredField : c .getDeclaredFields ()) {
198
+ jni .register (always , false , declaredField );
199
+ }
200
+ } catch (LinkageError e ) {
201
+ /* If we can't link we can not register for JNI and reflection */
202
+ }
195
203
}
196
204
197
205
// if we register as unsafe allocated earlier there are build-time
0 commit comments