RFR: 8306914: Implement JEP 458: Launch Multi-File Source-Code Programs [v7]
Jim Laskey
jlaskey at openjdk.org
Fri Dec 1 13:02:38 UTC 2023
On Fri, 1 Dec 2023 12:41:16 GMT, Christian Stein <cstein at openjdk.org> wrote:
>> Please review this change set implementing [JEP 458](https://openjdk.org/jeps/458) "Launch Multi-File Source-Code Programs" by introducing a new entry-point `SourceLauncher` in package `com.sun.tools.javac.launcher` of module `jdk.compiler`. The former `Main` entry-point is kept as-is in order to preserve (and possibly fall back to) existing behaviour of launching single-file source-code programs.
>>
>> The code of the new entry-point and other new classes introduced by this pull request is based on the original implementation. It extends it to dynamically resolve required types "on-the-fly" using an in-memory class loader capable to compile Java source files - applying a strict name-based pattern as described in the JEP.
>>
>> To support modular programs with user-provided additional modules (launched for example via `java -p . pkg/Prog1.java`) `ALL-MODULE-PATH` is now also part of the implicit list of modules name in source launch mode.
>>
>> ### Open Ends
>>
>> - [ ] Tests with [JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview))](https://bugs.openjdk.org/browse/JDK-8315398)
>>
>> ### OpenJDK's Demo Programs
>>
>> OpenJDK's demo programs can be found in the [src/demo/share/jfc](https://github.com/openjdk/jdk/tree/master/src/demo/share/jfc) directory. These multi-file source-code programs can be launched via `java ${PROGRAM}` once this implementation is integrated; with `${PROGRAM}` being one of the following files:
>>
>> - [x] `src/demo/share/jfc/CodePointIM/CodePointIM.java`
>> - [x] `src/demo/share/jfc/FileChooserDemo/FileChooserDemo.java`
>> - [x] `src/demo/share/jfc/Font2DTest/Font2DTest.java`
>> - [x] `src/demo/share/jfc/J2Ddemo/java2d/J2Ddemo.java`
>> - [x] `src/demo/share/jfc/Metalworks/Metalworks.java`
>> - [x] `src/demo/share/jfc/Notepad/Notepad.java`
>> - [x] `src/demo/share/jfc/SampleTree/SampleTree.java`
>> - [ ] `src/demo/share/jfc/Stylepad/Stylepad.java` — requires `src/demo/share/jfc/Notepad/Notepad.java`
>> - [x] `src/demo/share/jfc/SwingSet2/SwingSet2.java`
>> - [ ] `src/demo/share/jfc/TableExample/TableExample.java` — requires a database driver on the class path
>> - [ ] `src/demo/share/jfc/TableExample/TableExample2.java` — requires a database driver on the class path
>> - [x] `src/demo/share/jfc/TableExample/TableExample3.java`
>> - [x] `src/demo/share/jfc/TableExample/TableExample4.java`
>> - [x] `src/demo/share/jfc/TransparentRuler/transparentruler/Ruler.java`
>
> Christian Stein has updated the pull request incrementally with one additional commit since the last revision:
>
> Update test for implicit classes
>
> Preview notes normally emitted by `javac` are
> suppressed now, as they contain hints that
> does not apply to the source launcher and will
> lead to errors. For example: `-Xlint:preview`
Just nits. Nice work.
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/MemoryClassLoader.java line 59:
> 57: * as any like-named classes that might be found on the application class path.)
> 58: *
> 59: * <p><b>This is NOT part of any supported API.
< strong > instead of < b >
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/MemoryContext.java line 68:
> 66: * If you write code that depends on this, you do so at your own
> 67: * risk. This code and its internal interfaces are subject to change
> 68: * or deletion without notice.</b></p>
< strong > instead of < b >
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/MemoryFileManager.java line 50:
> 48: * If you write code that depends on this, you do so at your own
> 49: * risk. This code and its internal interfaces are subject to change
> 50: * or deletion without notice.</b></p>
< strong >
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/MemoryModuleFinder.java line 49:
> 47:
> 48: import jdk.internal.module.Resources;
> 49:
This is NOT part of any supported API. ...
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/ProgramDescriptor.java line 48:
> 46: * risk. This code and its internal interfaces are subject to change
> 47: * or deletion without notice.</b></p>
> 48: */
< strong >
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Result.java line 36:
> 34: * @param classNames the names of classes compiled into memory.
> 35: */
> 36: public record Result(Class<?> programClass, Set<String> classNames) {}
This is NOT part of any supported API. ...
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/SourceLauncher.java line 54:
> 52: * risk. This code and its internal interfaces are subject to change
> 53: * or deletion without notice.</b></p>
> 54: */
< strong >
-------------
Marked as reviewed by jlaskey (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/13712#pullrequestreview-1759748762
PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1412065454
PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1412066706
PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1412067763
PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1412069097
PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1412070654
PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1412072074
PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1412072305
More information about the compiler-dev
mailing list