src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java
changeset 49285 4d2e3f5abb48
parent 47216 71c04702a3d5
child 50817 fa1e04811ff6
equal deleted inserted replaced
49284:a51ca91c2cde 49285:4d2e3f5abb48
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    36 import java.net.URI;
    36 import java.net.URI;
    37 import java.net.URLConnection;
    37 import java.net.URLConnection;
    38 import java.nio.ByteBuffer;
    38 import java.nio.ByteBuffer;
    39 import java.nio.file.Files;
    39 import java.nio.file.Files;
    40 import java.nio.file.Path;
    40 import java.nio.file.Path;
    41 import java.nio.file.Paths;
       
    42 import java.security.AccessController;
    41 import java.security.AccessController;
    43 import java.security.PrivilegedAction;
    42 import java.security.PrivilegedAction;
    44 import java.util.ArrayDeque;
    43 import java.util.ArrayDeque;
    45 import java.util.Collections;
    44 import java.util.Collections;
    46 import java.util.Deque;
    45 import java.util.Deque;
   183             return finder;
   182             return finder;
   184         }
   183         }
   185 
   184 
   186         // probe to see if this is an images build
   185         // probe to see if this is an images build
   187         String home = System.getProperty("java.home");
   186         String home = System.getProperty("java.home");
   188         Path modules = Paths.get(home, "lib", "modules");
   187         Path modules = Path.of(home, "lib", "modules");
   189         if (Files.isRegularFile(modules)) {
   188         if (Files.isRegularFile(modules)) {
   190             if (USE_FAST_PATH) {
   189             if (USE_FAST_PATH) {
   191                 SystemModules systemModules = allSystemModules();
   190                 SystemModules systemModules = allSystemModules();
   192                 if (systemModules != null) {
   191                 if (systemModules != null) {
   193                     finder = of(systemModules);
   192                     finder = of(systemModules);
   203             return finder;
   202             return finder;
   204 
   203 
   205         }
   204         }
   206 
   205 
   207         // exploded build (do not cache module finder)
   206         // exploded build (do not cache module finder)
   208         Path dir = Paths.get(home, "modules");
   207         Path dir = Path.of(home, "modules");
   209         if (!Files.isDirectory(dir))
   208         if (!Files.isDirectory(dir))
   210             throw new InternalError("Unable to detect the run-time image");
   209             throw new InternalError("Unable to detect the run-time image");
   211         ModuleFinder f = ModulePath.of(ModuleBootstrap.patcher(), dir);
   210         ModuleFinder f = ModulePath.of(ModuleBootstrap.patcher(), dir);
   212         return new ModuleFinder() {
   211         return new ModuleFinder() {
   213             @Override
   212             @Override