RFR: 8335989: Implement Module Import Declarations (Second Preview)
Jan Lahoda
jlahoda at openjdk.org
Thu Oct 10 11:52:09 UTC 2024
On Wed, 9 Oct 2024 19:22:01 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> This is a current patch for module imports declarations, second preview. At least the JEP number and preview revision will need to be updated in `jdk.internal.javac.PreviewFeature.Feature`, but otherwise I believe this is ready to receive feedback.
>
> The main changes are:
> - `requires transitive java.base;` is permitted, under the preview flag. Both javac and the runtime module system are updated to accept this directive when preview is enabled.
> - the `java.se` module is using `requires transitive java.base;`, and is deemed to be participating in preview, so its classfile version is not tainted. Runtime is updated to access `requires transitive java.base;` in any `java.*`, considering all of them to be participating in preview. Can be tighten up to only `java.se` is desired.
> - the types imported through module imports can be shadowed using on-demand imports. So, for example, having:
>
> import module java.base;
> import module java.desktop;
> ...
> List l;//ambigous
>
> but:
>
> import module java.base;
> import module java.desktop;
> import java.util.*;
> ...
> List l;//not ambigous, reference to java.util.List
Thanks for the comments so far! Here I tried to reflect them:
https://github.com/openjdk/jdk/pull/21431/commits/b7c871dab8357864b532a1f217ed26c3b40d50f4
(For `ClassFileVersionsTest.java`, it seemed unnecessarily complex to position the test cases into specific array positions, so I re-wrote that to use `ArrayList`. My goal was take the focus of the data preparation from how to place the test cases into the correct buckets, and more to the data. I kept pre-sizing of the `ArrayList` to avoid resizing it, although I could see an argument to remove that as well.)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21431#issuecomment-2404877409
More information about the build-dev
mailing list