sormuras / command-line-interface

Arguments Splitter for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MethodHandles.publicLookup() is the wrong default

forax opened this issue · comments

There is a variant of ArgumentsSplitter.of() that does not take a Lookup but uses Lookup.publicLookup instead.

I believe using publicLookup is a poor default choice. publicLookup is a very artificial Lookup, it does not exist in real life, it only works for public method of public class of exported package, which means that it will only works if the record is a public record inside an exported package. It's the wrong default because most of the time, you do not want the record to be public, it's either confined to a methd, a class or a package.

I think the variant of ArgumentsSplitter.of() that only takes a Class should be removed, because for beginners trying to use the ArgumentsSplitter the first time, the current behavior is not what beginners will want by default.

Let's remove it - and with it also the published tests.

We can keep the published test and send a public Lookup explicitly if you want