src/share/classes/sun/misc/Launcher.java

Print this page
rev 9051 : 6760902: inconsistent behavior in system class loader for classes and resources
Reviewed-by: duke

*** 1,7 **** /* ! * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 264,274 **** public static ClassLoader getAppClassLoader(final ClassLoader extcl) throws IOException { final String s = System.getProperty("java.class.path"); ! final File[] path = (s == null) ? new File[0] : getClassPath(s); // Note: on bugid 4256530 // Prior implementations of this doPrivileged() block supplied // a rather restrictive ACC via a call to the private method // AppClassLoader.getContext(). This proved overly restrictive --- 264,274 ---- public static ClassLoader getAppClassLoader(final ClassLoader extcl) throws IOException { final String s = System.getProperty("java.class.path"); ! final File[] path = (s == null) ? new File[0] : getClassPath(s, true); // Note: on bugid 4256530 // Prior implementations of this doPrivileged() block supplied // a rather restrictive ACC via a call to the private method // AppClassLoader.getContext(). This proved overly restrictive
*** 362,372 **** URL[] urls; if (bootClassPath != null) { urls = AccessController.doPrivileged( new PrivilegedAction<URL[]>() { public URL[] run() { ! File[] classPath = getClassPath(bootClassPath); int len = classPath.length; Set<File> seenDirs = new HashSet<File>(); for (int i = 0; i < len; i++) { File curEntry = classPath[i]; // Negative test used to properly handle --- 362,373 ---- URL[] urls; if (bootClassPath != null) { urls = AccessController.doPrivileged( new PrivilegedAction<URL[]>() { public URL[] run() { ! // Skip empty path in boot class path i.e. not default to use CWD ! File[] classPath = getClassPath(bootClassPath, false); int len = classPath.length; Set<File> seenDirs = new HashSet<File>(); for (int i = 0; i < len; i++) { File curEntry = classPath[i]; // Negative test used to properly handle
*** 403,413 **** // System.out.println("urls[" + i + "] = " + '"' + urls[i] + '"'); //} return urls; } ! private static File[] getClassPath(String cp) { File[] path; if (cp != null) { int count = 0, maxCount = 1; int pos = 0, lastPos = 0; // Count the number of separators first --- 404,414 ---- // System.out.println("urls[" + i + "] = " + '"' + urls[i] + '"'); //} return urls; } ! private static File[] getClassPath(String cp, boolean defaultToCwd) { File[] path; if (cp != null) { int count = 0, maxCount = 1; int pos = 0, lastPos = 0; // Count the number of separators first
*** 419,438 **** lastPos = pos = 0; // Now scan for each path component while ((pos = cp.indexOf(File.pathSeparator, lastPos)) != -1) { if (pos - lastPos > 0) { path[count++] = new File(cp.substring(lastPos, pos)); ! } else { // empty path component translates to "." path[count++] = new File("."); } lastPos = pos + 1; } // Make sure we include the last path component if (lastPos < cp.length()) { path[count++] = new File(cp.substring(lastPos)); ! } else { path[count++] = new File("."); } // Trim array to correct size if (count != maxCount) { File[] tmp = new File[count]; --- 420,439 ---- lastPos = pos = 0; // Now scan for each path component while ((pos = cp.indexOf(File.pathSeparator, lastPos)) != -1) { if (pos - lastPos > 0) { path[count++] = new File(cp.substring(lastPos, pos)); ! } else if (defaultToCwd) { // empty path component translates to "." path[count++] = new File("."); } lastPos = pos + 1; } // Make sure we include the last path component if (lastPos < cp.length()) { path[count++] = new File(cp.substring(lastPos)); ! } else if (defaultToCwd) { path[count++] = new File("."); } // Trim array to correct size if (count != maxCount) { File[] tmp = new File[count];