[Investigation] No API to add limited modules

Guoxiong Li lgxbslgx at gmail.com
Sat Jun 5 09:46:34 UTC 2021


Hi all,

Currently, the class `Modules` has four fields about additional or limited
modules, which are `addModsOpt`, `extraAddMods`, `limitModsOpt` and
`extraLimitMods`.

The field `addModsOpt` can be set by using the option `--add-modules`.
The field `extraAddMods` can be set by using the api
`BasicJavacTask#addModules`.
The field `limitModsOpt` can be set by using the option `--limit-modules`.

But the field `*extraLimitMods*` seems different and has no way to be set
by the user.
>From the current code, we can know that it is only created by the following
statement
but not added any data.

```
private final Set<String> extraLimitMods = new HashSet<>();
```

Then, `extraLimitMods` will be used in the following situation.

1.
```
          if (limitModsOpt == null && extraLimitMods.isEmpty())
```

2.
```
            for (String limit : extraLimitMods) {
                limitMods.add(syms.enterModule(names.fromString(limit)));
            }
```

Actually, these two places are not useful because the `extraLimitMods` is
always empty.

Is it good to add an api, `addLimitMudules`, to the class `BasicJavacTask`,
which is like the api `addModules`?
If not, or we can remove the field `addLimitMudules` of the class
`Modules`. Because it is useless now.

Any ideas are appreciated. Thanks.

Best Regards,
-- Guoxiong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210605/2eb252b5/attachment.htm>


More information about the compiler-dev mailing list