-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support running via Single-File Java Launcher (JEP 330) ? #1792
Comments
Not sure it will make that big diff. Are you saying jbang/java X.jar is noticably slower than java X.java? |
No, not running the jar. But the jar build process is what's slower. So, |
Yes I get that - but most will run not build. Not having jar also means can't store which main methods to use or run any integration code (IE. Quarkus or jbang) I'm not sure we can automatic detect if it's feasible - probably need an explicit flag. //NOJAR ? |
Too me this seems pretty fragile, we'd suddenly get possibly different behaviours depending on what code you're running (does it have dependencies or not?) and which JDK you're using (<11? compile to jar. 11? no jar, but only single file, 22? multiple files). I think that up to now we've tried hard to get the same behaviour everywhere across the board, so my first reaction at least would be -1. BUt I'm open to being convinced :-) |
I thought it was possible to just create a list of tags – those for which a jar is required and not. At least that was my idea when I glanced at the code.
Yes, that's also occured to me. Currently everything goes through the build jar -> run pipeline (except for jsh). Not sure how cleanly this branching could be implemented. I'll see what I can do myself |
Is your feature request related to a problem? Please describe.
JBang is great because it allows you to specify dependencies right in your script file.
However for cases where dependencies are not needed it will still build a jar from the source.
Since Java 11 the java launcher has the ability to launch such java source files directly: JEP 330: Launch Single-File Source-Code Programs
Describe the solution you'd like
When having access to a Java 11+ jvm, make the distinction for scripts which doesn't require any jbang-exclusive features and launch these directly with the
java
launcher, skipping the build step.Some tags obviously require the jar to be built (anything involving dependencies or other sources), but others can be directly mapped to
java
options, like//JAVA
,//RUNTIME_OPTIONS
, some//COMPILE_OPTIONS
Describe alternatives you've considered
It's actually possible to run jbang scripts via the java launcher directly, but of course none of the jbang tags will be picked up
Additional context
Launching compatible source files directly has numerous advantages: We're saving one JVM launch and reduce first-time run times considerably. We also don't have to create a jar so we're skipping unnecessary disk writes & File I/O.
The text was updated successfully, but these errors were encountered: