31
31
import java .io .InputStreamReader ;
32
32
import java .lang .management .ManagementFactory ;
33
33
import java .lang .management .OperatingSystemMXBean ;
34
+ import java .lang .reflect .Method ;
34
35
import java .nio .charset .StandardCharsets ;
35
36
import java .nio .file .Files ;
36
37
import java .nio .file .InvalidPathException ;
89
90
import com .oracle .svm .hosted .NativeImageGeneratorRunner ;
90
91
import com .oracle .svm .hosted .NativeImageSystemClassLoader ;
91
92
import com .oracle .svm .util .ModuleSupport ;
93
+ import com .oracle .svm .util .ReflectionUtil ;
92
94
93
95
public class NativeImage {
94
96
@@ -260,6 +262,12 @@ private static <T> String oR(OptionKey<T> option) {
260
262
261
263
protected static class BuildConfiguration {
262
264
265
+ /*
266
+ * Reuse com.oracle.svm.util.ModuleSupport.isModulePathBuild() to ensure same interpretation
267
+ * of com.oracle.svm.util.ModuleSupport.ENV_VAR_USE_MODULE_SYSTEM environment variable use.
268
+ */
269
+ private static final Method isModulePathBuild = ReflectionUtil .lookupMethod (ModuleSupport .class , "isModulePathBuild" );
270
+
263
271
boolean modulePathBuild ;
264
272
String imageBuilderModeEnforcer ;
265
273
@@ -281,7 +289,11 @@ protected BuildConfiguration(List<String> args) {
281
289
282
290
@ SuppressWarnings ("deprecation" )
283
291
BuildConfiguration (Path rootDir , Path workDir , List <String > args ) {
284
- modulePathBuild = ModuleSupport .isModulePathBuild ();
292
+ try {
293
+ modulePathBuild = (boolean ) isModulePathBuild .invoke (null );
294
+ } catch (ReflectiveOperationException | ClassCastException e ) {
295
+ VMError .shouldNotReachHere (e );
296
+ }
285
297
imageBuilderModeEnforcer = null ;
286
298
this .args = args ;
287
299
this .workDir = workDir != null ? workDir : Paths .get ("." ).toAbsolutePath ().normalize ();
0 commit comments