< prev index next >
src/java.base/share/classes/java/net/URI.java
Print this page
rev 15833 : 8168073: Speed up URI creation during module bootstrap
Reviewed-by: alanb
*** 35,44 ****
--- 35,47 ----
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.CharacterCodingException;
import java.text.Normalizer;
+ import jdk.internal.loader.URLClassPath;
+ import jdk.internal.misc.JavaNetAccess;
+ import jdk.internal.misc.SharedSecrets;
import sun.nio.cs.ThreadLocalCoders;
import java.lang.Character; // for javadoc
import java.lang.NullPointerException; // for javadoc
*** 818,827 ****
--- 821,839 ----
null, null, fragment))
.parse(false);
}
/**
+ * Constructs a simple URI consisting of only a scheme and a pre-validated
+ * path. Provides a fast-path for some internal cases.
+ */
+ URI(String scheme, String path) {
+ this.scheme = scheme;
+ this.path = path;
+ }
+
+ /**
* Creates a URI by parsing the given string.
*
* <p> This convenience factory method works as if by invoking the {@link
* #URI(String)} constructor; any {@link URISyntaxException} thrown by the
* constructor is caught and wrapped in a new {@link
*** 3569,3575 ****
return p;
}
}
!
}
--- 3581,3595 ----
return p;
}
}
! static {
! SharedSecrets.setJavaNetAccess(
! new JavaNetAccess() {
! public URI createURI(String scheme, String path) {
! return new URI(scheme, path);
! }
! }
! );
! }
}
< prev index next >