Draft JEP: Launch Single-File Source-Code Programs

Andrew Haley aph at redhat.com
Tue Feb 13 09:04:06 UTC 2018

On 13/02/18 00:29, David Holmes wrote:
> On 13/02/2018 2:47 AM, Brian Goetz wrote:
>> I don’t think that’s a concern worth worrying about.  Think about why people use shebang in the first place; they want to launch the file from the shell without saying “java” (or “python” or “bash” or …)  At this point, the file has likely entered the terminal phase of its life — it is installed as a script.  The use case of “I might want to run it standalone as a script, or compile it as part of a larger source base” seems somewhat contrived.  And for those cases, fine — run it with “java —source”, rather than shebang.  I don’t think its a bump that anyone who actually uses will be surprised at.
> Ironically(?) I find that most of the files I have to execute that 
> contain shebangs do not have the execute bit set (all scripts in our 
> repos!) and so I have to  say "bash ...".

That's a bug, though: I remember asking about getting this fixed (by
setting the x bits on the files in the repo) but apparently it's
"because security."  Every other project I know sets the x bits in
shell scripts.

>> The alternative — intruding this convention on the Java language syntax — is certainly a worse tradeoff.  Think of this as “launcher 90% full” rather than “language 10% empty” :)
> IMHO it's a wart to have javac barf on what appears to be a regular Java 
> source file because of a shebang line. Even if this is outside the scope 
> of JLS, any tools in OpenJDK that can process "Java source files" should 
> be specified to skip the shebang line.

There is, I admit, some sense to that.

Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671

More information about the jdk-dev mailing list