Skip to content

Commit

Permalink
Fix jar-in-jar-loader multi-release support (#1058)
Browse files Browse the repository at this point in the history
In order to open a JAR file in multi-release mode the URL of the file
must be suffixed with `#runtime`.

Currently the `rsrc:` URL handler strips this fragment, which breaks
multi-release JARs retrieved through the `rsrc:` protocol.
  • Loading branch information
ppkarwasz committed Jan 23, 2024
1 parent 4a0adfa commit be9b97c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ final class JIJConstants {
static final String PATH_SEPARATOR = "/"; //$NON-NLS-1$
static final String CURRENT_DIR = "./"; //$NON-NLS-1$
static final String UTF8_ENCODING = "UTF-8"; //$NON-NLS-1$
static final String RUNTIME = "#runtime"; //$NON-NLS-1$
static final String RUNTIME_WITH_HASH = "#runtime"; //$NON-NLS-1$
static final String RUNTIME = "runtime"; //$NON-NLS-1$

private JIJConstants() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ protected java.net.URLConnection openConnection(URL u) throws IOException {
@Override
protected void parseURL(URL url, String spec, int start, int limit) {
String file;
String ref = null;
if (spec.startsWith(JIJConstants.INTERNAL_URL_PROTOCOL_WITH_COLON))
file = spec.substring(5);
else if (JIJConstants.CURRENT_DIR.equals(url.getFile()))
file = spec;
else if (url.getFile().endsWith(JIJConstants.PATH_SEPARATOR))
file = url.getFile() + spec;
else if (JIJConstants.RUNTIME.equals(spec))
else if (JIJConstants.RUNTIME_WITH_HASH.equals(spec)) {
file = url.getFile();
else
ref = JIJConstants.RUNTIME;
} else
file = spec;
setURL(url, JIJConstants.INTERNAL_URL_PROTOCOL, "", -1, null, null, file, null, null); //$NON-NLS-1$
setURL(url, JIJConstants.INTERNAL_URL_PROTOCOL, "", -1, null, null, file, null, ref); //$NON-NLS-1$
}

}

0 comments on commit be9b97c

Please sign in to comment.