RFR: 8245309: Re-examine use of ThreadLocalCoders in sun.net.www.ParseUtil
Alan Bateman
alanb at openjdk.java.net
Tue Sep 15 09:43:02 UTC 2020
On Tue, 15 Sep 2020 09:33:40 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> Replaced the use of ThreadLocalCoders with regular non-caching CharsetEncoder and added a benchmark to confirm that
>> there is no performance impact.
>
> test/micro/org/openjdk/bench/java/net/ThreadLocalParseUtil.java line 61:
>
>> 59: Class<?> c = Class.forName("sun.net.www.ParseUtil");
>> 60: MH_DECODE = LOOKUP.findStatic(c, "decode", methodType(String.class, String.class));
>> 61: MH_TO_URI = LOOKUP.findStatic(c, "toURI", methodType(URI.class, URL.class));
>
> Not sure why `MethodHandles` are used here. Is this to avoid the compile-time dependency on these classes? I believe
> for better benchmarking `MH_DECODE` and `MH_TO_URI` need to be `static final` to be folded. This would require
> initializing them in `<clinit>`.
The micros are being awkward to run right now because they are compiled with --enable-preview --release N so this
precludes using options such as --add-exports that would otherwise be used to compile/run micros for JDK internal
classes. I could imagine this area being re-visited as there are conflicting needs.
-------------
PR: https://git.openjdk.java.net/jdk/pull/170
More information about the net-dev
mailing list