< prev index next >

src/java.base/share/classes/jdk/internal/loader/URLClassPath.java

Print this page
8198485: Simplify a URLClassPath constructor
Reviewed-by: alanb, mchung

*** 173,199 **** */ URLClassPath(String cp, boolean skipEmptyElements) { ArrayList<URL> path = new ArrayList<>(); if (cp != null) { // map each element of class path to a file URL ! int off = 0; ! int next; ! while ((next = cp.indexOf(File.pathSeparator, off)) != -1) { ! String element = cp.substring(off, next); if (element.length() > 0 || !skipEmptyElements) { URL url = toFileURL(element); if (url != null) path.add(url); } off = next + 1; ! } ! ! // remaining element ! String element = cp.substring(off); ! if (element.length() > 0 || !skipEmptyElements) { ! URL url = toFileURL(element); ! if (url != null) path.add(url); ! } } // can't use ArrayDeque#addAll or new ArrayDeque(Collection); // it's too early in the bootstrap to trigger use of lambdas int size = path.size(); --- 173,194 ---- */ URLClassPath(String cp, boolean skipEmptyElements) { ArrayList<URL> path = new ArrayList<>(); if (cp != null) { // map each element of class path to a file URL ! int off = 0, next; ! do { ! next = cp.indexOf(File.pathSeparator, off); ! String element = (next == -1) ! ? cp.substring(off) ! : cp.substring(off, next); if (element.length() > 0 || !skipEmptyElements) { URL url = toFileURL(element); if (url != null) path.add(url); } off = next + 1; ! } while (next != -1); } // can't use ArrayDeque#addAll or new ArrayDeque(Collection); // it's too early in the bootstrap to trigger use of lambdas int size = path.size();
< prev index next >