equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
119 h += entry.hashCode(); |
119 h += entry.hashCode(); |
120 |
120 |
121 return h; |
121 return h; |
122 } |
122 } |
123 |
123 |
|
124 public String checkNestedProtocol(String spec) { |
|
125 if (spec.regionMatches(true, 0, "jar:", 0, 4)) { |
|
126 return "Nested JAR URLs are not supported"; |
|
127 } else { |
|
128 return null; |
|
129 } |
|
130 } |
124 |
131 |
125 @Override |
132 @Override |
126 @SuppressWarnings("deprecation") |
133 @SuppressWarnings("deprecation") |
127 protected void parseURL(URL url, String spec, |
134 protected void parseURL(URL url, String spec, |
128 int start, int limit) { |
135 int start, int limit) { |
144 boolean absoluteSpec = spec.length() >= 4 |
151 boolean absoluteSpec = spec.length() >= 4 |
145 ? spec.regionMatches(true, 0, "jar:", 0, 4) |
152 ? spec.regionMatches(true, 0, "jar:", 0, 4) |
146 : false; |
153 : false; |
147 spec = spec.substring(start, limit); |
154 spec = spec.substring(start, limit); |
148 |
155 |
|
156 String exceptionMessage = checkNestedProtocol(spec); |
|
157 if (exceptionMessage != null) { |
|
158 // NPE will be transformed into MalformedURLException by the caller |
|
159 throw new NullPointerException(exceptionMessage); |
|
160 } |
|
161 |
149 if (absoluteSpec) { |
162 if (absoluteSpec) { |
150 file = parseAbsoluteSpec(spec); |
163 file = parseAbsoluteSpec(spec); |
151 } else if (!refOnly) { |
164 } else if (!refOnly) { |
152 file = parseContextSpec(url, spec); |
165 file = parseContextSpec(url, spec); |
153 |
166 |