RFR: 8201274: Launch Single-File Source-Code Programs
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Apr 25 00:53:11 UTC 2018
On 04/12/2018 10:20 PM, mandy chung wrote:
>
>
> On 4/13/18 4:15 AM, Jonathan Gibbons wrote:
>> Please review an initial implementation for the feature described in
>> JEP 330: Launch Single-File Source-Code Programs.
>>
>> The work is described in the JEP and CSR, and falls into various parts:
>>
>> * The part to handle the new command-line options is in the native
>> Java launcher code.
>> * The part to invoke the compiler and subsequently execute the code
>> found in the source file is in a new class in the jdk.compiler
>> module.
>> * There are some minor Makefile changes, to add support for a new
>> resource file.
>>
>> There are no changes to javac itself.
>>
>> JEP: http://openjdk.java.net/jeps/330
>> JBS: https://bugs.openjdk.java.net/browse/JDK-8201274
>> CSR: https://bugs.openjdk.java.net/browse/JDK-8201275
>> Webrev: http://cr.openjdk.java.net/~jjg/8201274/webrev.00/
>
> This looks quite good to me. One small comment on the source launcher
> Main class:
>
> 122 } catch (InvocationTargetException e) {
> 123 // leave VM to handle the stacktrace, in the standard manner
> 124 throw e.getTargetException();
> 125 }
> 387 } catch (InvocationTargetException e) {
> 388 // remove stack frames for source launcher
> 389 int invocationFrames = e.getStackTrace().length;
> 390 Throwable target = e.getTargetException();
> 391 StackTraceElement[] targetTrace = target.getStackTrace();
> 392 target.setStackTrace(Arrays.copyOfRange(targetTrace, 0, targetTrace.length - invocationFrames));
> 393 throw e;
> 394 }
>
> This could simply throw target instead of the InvocationTargetException
> and then the main method can propagate the target, if thrown.
>
> Mandy
Mandy,
Yes, but that would require the execute method and its callers to
declare that they throw Throwable,
or at least Exception. Since the exception is already wrapped, it seems
better to propagate the
wrapped exception, and to only unwrap it at the last moment.
-- Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180424/9456cf6f/attachment.html>
More information about the compiler-dev
mailing list