On 28/01/2020 13:13, Seán Coffey wrote:
Looks like we can improve performance in this area. I've put together a testcase which exercises the ServiceLoader and keeps track of whether we're able to cache or not.

https://bugs.openjdk.java.net/browse/JDK-8223260
http://cr.openjdk.java.net/~coffeys/webrev.8223260.v1/webrev/
A WeakHashKey with the TCCL as the key should be okay here. It might be cleaner to move the adding to the map to after the two lookups so that it's one place rather than two.  ServiceLoader has a stream method so the while could be replaced to improve the readability but that is probably beyond what you want to do on this issue.

In the test it will spin calling System.gc. Can you put the System.gc() before the while lookup and just Thread.sleep(100) instead. There may be something in the test infrastructure libs that could use if you want.

-Alan.

Reply via email to