158 this.acc = acc;
159 }
160
161 public URLClassPath(URL[] urls, AccessControlContext acc) {
162 this(urls, null, acc);
163 }
164
165 /**
166 * Constructs a URLClassPath from a class path string.
167 *
168 * @param cp the class path string
169 * @param skipEmptyElements indicates if empty elements are ignored or
170 * treated as the current working directory
171 *
172 * @apiNote Used to create the application class path.
173 */
174 URLClassPath(String cp, boolean skipEmptyElements) {
175 ArrayList<URL> path = new ArrayList<>();
176 if (cp != null) {
177 // map each element of class path to a file URL
178 int off = 0;
179 int next;
180 while ((next = cp.indexOf(File.pathSeparator, off)) != -1) {
181 String element = cp.substring(off, next);
182 if (element.length() > 0 || !skipEmptyElements) {
183 URL url = toFileURL(element);
184 if (url != null) path.add(url);
185 }
186 off = next + 1;
187 }
188
189 // remaining element
190 String element = cp.substring(off);
191 if (element.length() > 0 || !skipEmptyElements) {
192 URL url = toFileURL(element);
193 if (url != null) path.add(url);
194 }
195 }
196
197 // can't use ArrayDeque#addAll or new ArrayDeque(Collection);
198 // it's too early in the bootstrap to trigger use of lambdas
199 int size = path.size();
200 ArrayDeque<URL> unopenedUrls = new ArrayDeque<>(size);
201 for (int i = 0; i < size; i++)
202 unopenedUrls.add(path.get(i));
203
204 this.unopenedUrls = unopenedUrls;
205 this.path = path;
206 this.jarHandler = null;
207 this.acc = null;
208 }
209
210 public synchronized List<IOException> closeLoaders() {
211 if (closed) {
212 return Collections.emptyList();
213 }
214 List<IOException> result = new LinkedList<>();
|
158 this.acc = acc;
159 }
160
161 public URLClassPath(URL[] urls, AccessControlContext acc) {
162 this(urls, null, acc);
163 }
164
165 /**
166 * Constructs a URLClassPath from a class path string.
167 *
168 * @param cp the class path string
169 * @param skipEmptyElements indicates if empty elements are ignored or
170 * treated as the current working directory
171 *
172 * @apiNote Used to create the application class path.
173 */
174 URLClassPath(String cp, boolean skipEmptyElements) {
175 ArrayList<URL> path = new ArrayList<>();
176 if (cp != null) {
177 // map each element of class path to a file URL
178 int off = 0, next;
179 do {
180 next = cp.indexOf(File.pathSeparator, off);
181 String element = (next == -1)
182 ? cp.substring(off)
183 : cp.substring(off, next);
184 if (element.length() > 0 || !skipEmptyElements) {
185 URL url = toFileURL(element);
186 if (url != null) path.add(url);
187 }
188 off = next + 1;
189 } while (next != -1);
190 }
191
192 // can't use ArrayDeque#addAll or new ArrayDeque(Collection);
193 // it's too early in the bootstrap to trigger use of lambdas
194 int size = path.size();
195 ArrayDeque<URL> unopenedUrls = new ArrayDeque<>(size);
196 for (int i = 0; i < size; i++)
197 unopenedUrls.add(path.get(i));
198
199 this.unopenedUrls = unopenedUrls;
200 this.path = path;
201 this.jarHandler = null;
202 this.acc = null;
203 }
204
205 public synchronized List<IOException> closeLoaders() {
206 if (closed) {
207 return Collections.emptyList();
208 }
209 List<IOException> result = new LinkedList<>();
|