Enable native access should work with the source launcher

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 25
    • Affects Version/s: 22, 23, 24
    • Component/s: tools
    • None
    • b06

      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.

            Assignee:
            Christian Stein
            Reporter:
            Christian Stein
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: