asciidoctor / asciidoctor-gradle-plugin

A Gradle plugin that uses Asciidoctor via JRuby to process AsciiDoc source files within the project.
https://asciidoctor.github.io/asciidoctor-gradle-plugin/
Apache License 2.0
286 stars 122 forks source link

[Java 16] FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem #597

Closed juergenzimmermann closed 1 year ago

juergenzimmermann commented 3 years ago

When I invoke gradle asciidoctor with Java 16 then I get the output WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem.

Using gradle asciidoctor --info shows the following detail:

[...]
> Task :asciidoctor
Custom actions are attached to task ':asciidoctor'.
Build cache key for task ':asciidoctor' is 2c54f1ebd95b48c40d5bbcde5de0bc39
Copy resources for 'html5' to C:\Users\[...]\IdeaProjects\kunde\build\docs\asciidoc
Running AsciidoctorJ instance with classpath [...]
Starting process 'command 'C:\Zimmermann\jdk\bin\java.exe''. Working directory: C:\Users\[...]\IdeaProjects\kunde Command: C:\Zimmermann\jdk\bin\java.exe -Dfile.encoding=UTF-8 -Duser.country=DE -Duser.language=de -Duser.variant -cp [...] org.asciidoctor.gradle.remote.AsciidoctorJavaExec C:\Users\[...]\IdeaProjects\kunde\build\tmp\asciidoctor.javaexec-data
Successfully started process 'command 'C:\Zimmermann\jdk\bin\java.exe''
2021-04-05T05:09:47.261+02:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable.
[...]
alwyn commented 3 years ago

Can confirm this happening. Trying to find a way to specify jvmargs for the asciidoctor subprocess, but nothing so far.

ysb33r commented 3 years ago

Try this approach

asciidoctor {
  inProcess = JAVA_EXEC // or "JAVA_EXEC"
  forkOptions {
     jvmArgs '-Dfoo-base', '-XX:something=more'
  }
}

forkOptions configures a org.ysb33r.grolifant.api.JavaForkOptions which has a similar interface to org.gradle.process.JavaForkOptions

No idea if this will solve the case, but if it does it give you a workaround until we can get to JDK16 testing.

alwyn commented 3 years ago

@ysb33r Looks promising although it doesn't seem to take the --add-opens argument.

Trying:

    asciidoctor {
        inProcess = JAVA_EXEC
        forkOptions {
            jvmArgs("--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED")
        }
        dependsOn(asciidoctorPdf)
    }

with asciidoctorPdf having the same configuration.

I am using some --add-opens on the main gradle process to get kapt to work, but for some reason the asciidoctor process complains with: Unrecognized option: --add-opens java.base/sun.nio.ch=ALL-UNNAMED

UPDATE: Got it working with --add-opens: jvmArgs("--add-opens","java.base/sun.nio.ch=ALL-UNNAMED","--add-opens","java.base/java.io=ALL-UNNAMED")

juergenzimmermann commented 3 years ago

The following code fragment works for my build.gradle.kts file:

inProcess = org.asciidoctor.gradle.base.process.ProcessMode.JAVA_EXEC
forkOptions {
     jvmArgs("--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED")
}
ysb33r commented 3 years ago

@alwyn You need to pass a list, not a single concatenated string.

ysb33r commented 3 years ago

@juergenzimmermann Unless Gradle specifically dopes somethign in future releases, it look likes the plugin might have to add those options automatically if it detects JDK16.