RFR: updated draft API for JEP 269 Convenience Collection Factories

Stuart Marks stuart.marks at oracle.com
Mon Nov 9 20:44:33 UTC 2015


Hi Michael, Peter,

I admit to not having followed all the benchmarking discussion (travel, Devoxx) 
but I did want to respond to this:

Peter wrote:
> So it looks like that there's no need to burden the public API with explicit argument overloads.

These are JMH benchmarks, which take care to warm up the JIT, so that everything 
is nicely optimized, inlined, escape-analyzed, etc., right?

If so, I don't see this at all being representative of how these APIs will be 
used. They won't be called in tight loops that give the JVM a chance to optimize 
them. Instead, they'll be used for initializing fields, including static fields:

     class MyClass {
         static final Set<String> set = Set.of("a", "b", "c");
         ...
     }

This call to Set.of() will (probably) be called exactly once when MyClass is 
loaded. It'll probably be run in interpretive mode. If the API becomes popular, 
there will be lots of calls like this in static initializers and instance 
initializers. Most of these will be called once or relatively few times, but 
there may be a lot of such calls. I think most of these would be run by the 
interpreter.

How do we assess the impact of fixed-args vs varargs overloads for cases like this?

s'marks




More information about the core-libs-dev mailing list