Skip to content

Commit 94f5e80

Browse files
stsypanovdfuch
authored andcommittedSep 28, 2021
8274276: Cache normalizedBase URL in URLClassPath.FileLoader
Reviewed-by: dfuchs
1 parent b36881f commit 94f5e80

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ private static class Loader implements Closeable {
597597
/*
598598
* Returns the base URL for this Loader.
599599
*/
600-
URL getBaseURL() {
600+
final URL getBaseURL() {
601601
return base;
602602
}
603603

@@ -1199,7 +1199,8 @@ static boolean isRelative(String child) {
11991199
*/
12001200
private static class FileLoader extends Loader {
12011201
/* Canonicalized File */
1202-
private File dir;
1202+
private final File dir;
1203+
private final URL normalizedBase;
12031204

12041205
/*
12051206
* Creates a new FileLoader for the specified URL with a file protocol.
@@ -1209,6 +1210,7 @@ private FileLoader(URL url) throws IOException {
12091210
String path = url.getFile().replace('/', File.separatorChar);
12101211
path = ParseUtil.decode(path);
12111212
dir = (new File(path)).getCanonicalFile();
1213+
normalizedBase = new URL(getBaseURL(), ".");
12121214
}
12131215

12141216
/*
@@ -1227,7 +1229,6 @@ URL findResource(final String name, boolean check) {
12271229
Resource getResource(final String name, boolean check) {
12281230
final URL url;
12291231
try {
1230-
URL normalizedBase = new URL(getBaseURL(), ".");
12311232
url = new URL(getBaseURL(), ParseUtil.encodePath(name, false));
12321233

12331234
if (url.getFile().startsWith(normalizedBase.getFile()) == false) {

0 commit comments

Comments
 (0)
Please sign in to comment.