farkhalit commented on PR #432:
URL: https://github.com/apache/commons-cli/pull/432#issuecomment-5113695936

   Added `testClassValidatedBeforeInitialization`, which walks the 
isAssignableFrom use case end to end: resolve the class through 
`Converter.CLASS`, run the `Plugin.class.isAssignableFrom(cls)` gate, and 
assert the static initializer has not run at that point. It only runs after 
`newInstance()`. Uses its own marker type and flag so it does not couple to the 
ordering of the existing test.
   
   @raboof you are right that it is not obviously better, it is a tradeoff. 
Your "fail fast on startup" points are real and I would not argue lazy wins 
across the board. The one thing that tips it for me is that eager init takes 
the choice away from the caller: on master the initializer of whatever name is 
in argv has already run inside `getParsedOptionValue`, so an app that wants to 
validate first cannot. Lazy leaves both doors open, since the app can still 
force init immediately by instantiating or touching a static if it prefers the 
fail-fast behavior. It does not force the reverse. `Converter.OBJECT` keeps 
eager init, so the fail-fast path is still one line away.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to