Enable native access doesn't work with the source launcher if launching in a named module.
```
run:
java \
--enable-native-access=dev.mccue.sdl \
-Djava.library.path=SDL/build \
-XstartOnFirstThread \
src/example/Main.java
WARNING: Unknown module: dev.mccue.sdl specified to --enable-native-access
Exception in thread "main" java.lang.ExceptionInInitializerError
at dev.mccue.sdl/example.Main.main(Main.java:15)
Caused by: java.lang.IllegalCallerException: Illegal native access from: module dev.mccue.sdl
java --enable-native-access=ALL-UNNAMED -Djava.library.path=SDL/build -XstartOnFirstThread src/example/Main.java
Exception in thread "main" java.lang.ExceptionInInitializerError
at dev.mccue.sdl/example.Main.main(Main.java:15)
Caused by: java.lang.IllegalCallerException: Illegal native access from: module dev.mccue.sdl
```
File tree looks like:
```
src/
example/
Main.java
dev/
mccue/
sdl/
...
module-info.java (dev.mccue.sdl)
```
Work-around: remove the `module-info.java` file to make the source launcher load the classes in the unnamend module and pass `--enable-native-access=ALL-UNNAMED` to the launcher as can be seen in the second example.
```
run:
java \
--enable-native-access=dev.mccue.sdl \
-Djava.library.path=SDL/build \
-XstartOnFirstThread \
src/example/Main.java
WARNING: Unknown module: dev.mccue.sdl specified to --enable-native-access
Exception in thread "main" java.lang.ExceptionInInitializerError
at dev.mccue.sdl/example.Main.main(Main.java:15)
Caused by: java.lang.IllegalCallerException: Illegal native access from: module dev.mccue.sdl
java --enable-native-access=ALL-UNNAMED -Djava.library.path=SDL/build -XstartOnFirstThread src/example/Main.java
Exception in thread "main" java.lang.ExceptionInInitializerError
at dev.mccue.sdl/example.Main.main(Main.java:15)
Caused by: java.lang.IllegalCallerException: Illegal native access from: module dev.mccue.sdl
```
File tree looks like:
```
src/
example/
Main.java
dev/
mccue/
sdl/
...
module-info.java (dev.mccue.sdl)
```
Work-around: remove the `module-info.java` file to make the source launcher load the classes in the unnamend module and pass `--enable-native-access=ALL-UNNAMED` to the launcher as can be seen in the second example.
- links to
-
Commit(master) openjdk/jdk/fec769b0
-
Review(master) openjdk/jdk/22930