JEP 330
Jonathan Gibbons
jonathan.gibbons at oracle.com
Sun Jun 3 19:45:32 UTC 2018
On 6/1/18 7:01 PM, John Rose wrote:
> On Jun 1, 2018, at 1:26 PM, forax at univ-mlv.fr
> <mailto:forax at univ-mlv.fr> wrote:
>>
>> *De:*"John Rose" <john.r.rose at oracle.com
>> <mailto:john.r.rose at oracle.com>>
>> *À:*"Remi Forax" <forax at univ-mlv.fr <mailto:forax at univ-mlv.fr>>
>> *Cc:*"cay horstmann" <cay.horstmann at gmail.com
>> <mailto:cay.horstmann at gmail.com>>, "compiler-dev"
>> <compiler-dev at openjdk.java.net
>> <mailto:compiler-dev at openjdk.java.net>>
>> *Envoyé:*Jeudi 31 Mai 2018 22:55:14
>> *Objet:*Re: JEP 330
>>
>> On May 31, 2018, at 1:36 PM, Remi Forax <forax at univ-mlv.fr
>> <mailto:forax at univ-mlv.fr>> wrote:
>>
>>
>> or just put the jar near the shebang file :)
>>
>>
>> That raises an interesting question: How does the shebang script
>> refer to a side file
>> in the same directory? In /bin/sh we would say something like
>> "${0%/*}/side.jar".
>> I suppose there is a JVM property which exposes that command line
>> argument already;
>> if not there should be. Then an API like java.nio.file.Path can
>> help find the side file.
>>
>>
>> Amusingly, it's easier to get a jar from a server somewhere on the
>> planet than to get a jar from the same directory of a script :)
>
> This might work:
>
> System.getProperty("sun.java.command")
>
> At least, it works today to get the class name. Who knows whether
> it will also give you the script file name. And note the ominous "sun."
> prefix.
>
> Seems like this use case could use some love. Scripts locating
> themselves require a little work from the launcher, well repaid
> by portability (relocatability) of the script.
The property is there, but is currently for internal use, as evidenced
by the
presence of "internal" in the name. If we so choose, we could rename and
include the property in the specification.
>
> As an idealist, I might want Class.getResourceAsStream to return
> the contents of a side file to the script file. But it's more likely to
> return null, given the strategy of compiling the script into a temporary
> artifact in an undisclosed location.
Class.getResourceAsStream will find items on the classpath used by the VM.
>
> — John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180603/5e608f9c/attachment.html>
More information about the compiler-dev
mailing list