Hi Jay,
instead of

Callable<? extends Terminal> sup = FLAVORS.get(flavor);
if (sup != null) {
return sup.call();
  }
  throw new InternalError();

you can write it as a one liner with getOrDefault:

FLAVORS.getOrDefault(flavor, () -> { throw new InternalEror(); }).call();

cheers,
RĂ©mi

On 06/30/2015 03:54 PM, Jan Lahoda wrote:
On 30.6.2015 14:10, Alan Bateman wrote:
On 29/06/2015 12:25, Jan Lahoda wrote:

The library is Windows-only, but the WindowsTerminal (or its
subclasses) are registered on all platforms using
"WindowsTerminal.class". While this does not cause initialization, it
seemed safer to ensure the library is only loaded when needed.

This seems odd, I wonder why TerminalFactory does not check os.name
before registering the platform specific implementation.

Is this were fixed to register WindowsTerminal or UnixTerminal rather
than both then would it fix this?

I've changed the registration to use a Callable to produce the Terminal instances instead of registering the Terminal classes:
http://cr.openjdk.java.net/~jlahoda/8080679/webrev.05/full/
delta:
http://cr.openjdk.java.net/~jlahoda/8080679/webrev.05/delta/

(I used Callable rather than Supplier, as Callable allows to throw an exception from the call method.)

How does this look?

Thanks,
   Jan


-Alan.

Reply via email to