remkop / picocli

Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
https://picocli.info
Apache License 2.0
4.89k stars 421 forks source link

Support Class Data Sharing #1623

Open quintesse opened 2 years ago

quintesse commented 2 years ago

Right now if you enable Class Data Sharing (using -XX:ArchiveClassesAtExit) for an application that uses Picocli you get a long list of warnings like this:

[0.518s][warning][cds] Pre JDK 6 class not supported by CDS: 49.0 picocli/CommandLine$Model$ArgGroupSpec$Builder
[0.518s][warning][cds] Pre JDK 6 class not supported by CDS: 49.0 picocli/CommandLine$Model$CaseAwareLinkedMap
[0.518s][warning][cds] Pre JDK 6 class not supported by CDS: 49.0 picocli/CommandLine$DefaultFactory
[0.518s][warning][cds] Pre JDK 6 class not supported by CDS: 49.0 picocli/CommandLine$Help$IParamLabelRenderer
[0.518s][warning][cds] Pre JDK 6 class not supported by CDS: 49.0 picocli/CommandLine$IExitCodeExceptionMapper
...

It's probably not a very important issue but I'm creating it to at least know what the official view on this is. Because a fix means that Picocli would have to start using Java 6 as its minimal JVM version.

remkop commented 2 years ago

Thanks for raising this!

My position has always been to support Java 5 as long as possible. This is a new argument against that, that is good to know.

It would be good to know what the actual concrete impact would be on startup time if picocli was using Java 6 byte codes. (If you want to test, you can create picocli jar files that have Java 6 byte codes by building the project with Java 9 or later.)

I am mostly focused on functional improvements at the moment, but after that (don't know when that will be) I will take a look at performance considerations. This proposal may be more attractive if it results in a significant reduction in startup time.

electr1cBugaloo commented 2 weeks ago

+1 on this. I am running pdfbox cli app (which uses picocli) on a lot of pdfs. This involves many, many startups of the pdfbox app jar. My usecase is not worth optimizing by coding a better optimized custom solution.

CDS seems to improve startup performance by at least around 30%. Which adds up quite a bit when you start pdfbox many times. And this improvement is basically for free. So isn't Java 5 quite old by now 😉 to make this worth it?

If it matters, latest pdfbox also requires at least java 8.