3131import java .io .InputStreamReader ;
3232import java .lang .management .ManagementFactory ;
3333import java .lang .management .OperatingSystemMXBean ;
34+ import java .lang .reflect .Method ;
3435import java .nio .charset .StandardCharsets ;
3536import java .nio .file .Files ;
3637import java .nio .file .InvalidPathException ;
8990import com .oracle .svm .hosted .NativeImageGeneratorRunner ;
9091import com .oracle .svm .hosted .NativeImageSystemClassLoader ;
9192import com .oracle .svm .util .ModuleSupport ;
93+ import com .oracle .svm .util .ReflectionUtil ;
9294
9395public class NativeImage {
9496
@@ -260,6 +262,12 @@ private static <T> String oR(OptionKey<T> option) {
260262
261263 protected static class BuildConfiguration {
262264
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+
263271 boolean modulePathBuild ;
264272 String imageBuilderModeEnforcer ;
265273
@@ -281,7 +289,11 @@ protected BuildConfiguration(List<String> args) {
281289
282290 @ SuppressWarnings ("deprecation" )
283291 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+ }
285297 imageBuilderModeEnforcer = null ;
286298 this .args = args ;
287299 this .workDir = workDir != null ? workDir : Paths .get ("." ).toAbsolutePath ().normalize ();
0 commit comments