# HG changeset patch
# User martin
# Date 1518139557 28800
# Node ID 43bf8cca0ecc77c5dfac824e0eb44ee3a2ac970f
# Parent  12c61ec06d2a8cf5be551fcbb4728c200bd99b61
8198485: Simplify a URLClassPath constructor
Reviewed-by: alanb, mchung

diff -r 12c61ec06d2a -r 43bf8cca0ecc src/java.base/share/classes/jdk/internal/loader/URLClassPath.java
--- a/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java	Thu Feb 08 17:25:57 2018 -0800
+++ b/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java	Thu Feb 08 17:25:57 2018 -0800
@@ -175,23 +175,18 @@
         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);
+            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;
-            }
-
-            // remaining element
-            String element = cp.substring(off);
-            if (element.length() > 0 || !skipEmptyElements) {
-                URL url = toFileURL(element);
-                if (url != null) path.add(url);
-            }
+            } while (next != -1);
         }
 
         // can't use ArrayDeque#addAll or new ArrayDeque(Collection);