--- a/langtools/src/share/classes/com/sun/tools/javac/file/BaseFileObject.java Thu Sep 03 18:34:17 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/BaseFileObject.java Tue Sep 08 11:12:13 2009 -0700
@@ -29,6 +29,8 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.charset.CharsetDecoder;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
@@ -93,7 +95,26 @@
return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
}
+ protected static URI createJarUri(File jarFile, String entryName) {
+ URI jarURI = jarFile.toURI().normalize();
+ String separator = entryName.startsWith("/") ? "!" : "!/";
+ try {
+ // The jar URI convention appears to be not to re-encode the jarURI
+ return new URI("jar:" + jarURI + separator + entryName);
+ } catch (URISyntaxException e) {
+ throw new CannotCreateUriError(jarURI + separator + entryName, e);
+ }
+ }
+
+ /** Used when URLSyntaxException is thrown unexpectedly during
+ * implementations of (Base)FileObject.toURI(). */
+ protected static class CannotCreateUriError extends Error {
+ private static final long serialVersionUID = 9101708840997613546L;
+ public CannotCreateUriError(String value, Throwable cause) {
+ super(value, cause);
+ }
+ }
+
/** The file manager that created this JavaFileObject. */
protected final JavacFileManager fileManager;
-
}