< prev index next >
src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java
Print this page
*** 23,32 ****
--- 23,33 ----
* questions.
*/
package jdk.internal.jrtfs;
import java.io.File;
+ import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
*** 168,178 ****
}
@Override
public final URI toUri() {
try {
! return new URI("jrt", toAbsolutePath().path, null);
} catch (URISyntaxException ex) {
throw new AssertionError(ex);
}
}
--- 169,188 ----
}
@Override
public final URI toUri() {
try {
! String p = toAbsolutePath().path;
! if (!p.startsWith("/modules") || p.contains("..")) {
! throw new IOError(new RuntimeException(p + " cannot be represented as URI"));
! }
!
! p = p.substring("/modules".length());
! if (p.isEmpty()) {
! p = "/";
! }
! return new URI("jrt", p, null);
} catch (URISyntaxException ex) {
throw new AssertionError(ex);
}
}
< prev index next >