# HG changeset patch # User redestad # Date 1466170737 -7200 # Fri Jun 17 15:38:57 2016 +0200 # Node ID e9e14d68ea6771982c28a484b166c31b8dd84d1b # Parent cc6fcc165e5da19c927d1f1309753b3bd1847522 8159745: Remove java.net.Parts Reviewed-by: chegar diff --git a/src/java.base/share/classes/java/net/URL.java b/src/java.base/share/classes/java/net/URL.java --- a/src/java.base/share/classes/java/net/URL.java +++ b/src/java.base/share/classes/java/net/URL.java @@ -428,16 +428,18 @@ authority = (port == -1) ? host : host + ":" + port; } - Parts parts = new Parts(file); - path = parts.getPath(); - query = parts.getQuery(); - - if (query != null) { + int ind = file.indexOf('#'); + this.ref = ind < 0 ? null : file.substring(ind + 1); + file = ind < 0 ? file : file.substring(0, ind); + int q = file.lastIndexOf('?'); + if (q != -1) { + this.query = file.substring(q + 1); + this.path = file.substring(0, q); this.file = path + "?" + query; } else { + this.path = file; this.file = path; } - ref = parts.getRef(); // Note: we don't do validation of the URL here. Too risky to change // right now, but worth considering for future reference. -br @@ -1617,35 +1619,6 @@ } } -class Parts { - String path, query, ref; - - Parts(String file) { - int ind = file.indexOf('#'); - ref = ind < 0 ? null: file.substring(ind + 1); - file = ind < 0 ? file: file.substring(0, ind); - int q = file.lastIndexOf('?'); - if (q != -1) { - query = file.substring(q+1); - path = file.substring(0, q); - } else { - path = file; - } - } - - String getPath() { - return path; - } - - String getQuery() { - return query; - } - - String getRef() { - return ref; - } -} - final class UrlDeserializedState { private final String protocol; private final String host;