jbang
jbang copied to clipboard
jbang --main overrides future calls
Run: Jbang -m blah x.java
Then without changing any code run
jbang x.java
It will now use blah as main method when it should not.
MAin method should be part of the key used for caching lookup.
Or we don't set the main class in the JAR file when we use -m?
That way running the JAR would use the default main while using any other would require you to specify it.
Depends. For export it would be Nice to burn it in.
But we could do that at export Time i reckon if specified There.
I just encountered this issue again and thought we had already fixed this, but the behaviour is still there.
But then I started thinking about what it means to have this option set or not.
These are some of my observations:
- if no -m is passed we determine the main class ourselves and set that in the MANIFEST
- but what does it mean if the user specifies -m? How do we know its a temporary override or a permanent one?
- options passed on the command line are normally considered temporary, but given the fact that there isn't a
//MAIN-CLASStag it would mean the developer has no way to permanently specify the main class.
I think we should just assume that JARs in the cache are always run by Jbang and let it handle what main to use (So maybe we shouldn't even set the Main-Class in the MANIFEST). And then the user should use export if they want a runnable JAR with a specific main class.
It could actually be nice if //MAIN-CLASS was option.
Then -m could be seen as temporary or only for this specific run.