< prev index next >

src/java.base/share/classes/java/lang/ClassLoader.java

Print this page
rev 51675 : 8207690: Parsing API for classpath and similar path strings

*** 66,75 **** --- 66,76 ---- import jdk.internal.misc.Unsafe; import jdk.internal.misc.VM; import jdk.internal.ref.CleanerFactory; import jdk.internal.reflect.CallerSensitive; import jdk.internal.reflect.Reflection; + import jdk.internal.util.PathParser; import sun.reflect.misc.ReflectUtil; import sun.security.util.SecurityConstants; /** * A class loader is an object that is responsible for loading classes. The
*** 2553,2609 **** private static String usr_paths[]; private static String sys_paths[]; private static String[] initializePath(String propName) { String ldPath = System.getProperty(propName, ""); - int ldLen = ldPath.length(); - char ps = File.pathSeparatorChar; - int psCount = 0; - - if (ClassLoaderHelper.allowsQuotedPathElements && - ldPath.indexOf('\"') >= 0) { - // First, remove quotes put around quoted parts of paths. - // Second, use a quotation mark as a new path separator. - // This will preserve any quoted old path separators. - char[] buf = new char[ldLen]; - int bufLen = 0; - for (int i = 0; i < ldLen; ++i) { - char ch = ldPath.charAt(i); - if (ch == '\"') { - while (++i < ldLen && - (ch = ldPath.charAt(i)) != '\"') { - buf[bufLen++] = ch; - } - } else { - if (ch == ps) { - psCount++; - ch = '\"'; - } - buf[bufLen++] = ch; - } - } - ldPath = new String(buf, 0, bufLen); - ldLen = bufLen; - ps = '\"'; - } else { - for (int i = ldPath.indexOf(ps); i >= 0; - i = ldPath.indexOf(ps, i + 1)) { - psCount++; - } - } ! String[] paths = new String[psCount + 1]; ! int pathStart = 0; ! for (int j = 0; j < psCount; ++j) { ! int pathEnd = ldPath.indexOf(ps, pathStart); ! paths[j] = (pathStart < pathEnd) ? ! ldPath.substring(pathStart, pathEnd) : "."; ! pathStart = pathEnd + 1; ! } ! paths[psCount] = (pathStart < ldLen) ? ! ldPath.substring(pathStart, ldLen) : "."; ! return paths; } // Invoked in the java.lang.Runtime class to implement load and loadLibrary. static void loadLibrary(Class<?> fromClass, String name, boolean isAbsolute) { --- 2554,2565 ---- private static String usr_paths[]; private static String sys_paths[]; private static String[] initializePath(String propName) { String ldPath = System.getProperty(propName, ""); ! return PathParser.parsePath(ldPath, "."); } // Invoked in the java.lang.Runtime class to implement load and loadLibrary. static void loadLibrary(Class<?> fromClass, String name, boolean isAbsolute) {
< prev index next >