xml-doclet icon indicating copy to clipboard operation
xml-doclet copied to clipboard

Doclet is not compatible with Java 11

Open fidget83 opened this issue 6 years ago • 7 comments

If I try to run Doclet in JDK 11, it fails: Exit code: 1 - javadoc: warning - The old Doclet and Taglet APIs in the packages com.sun.javadoc, com.sun.tools.doclets and their implementations are planned to be removed in a future JDK release. These components have been superseded by the new APIs in jdk.javadoc.doclet. Users are strongly recommended to migrate to the new APIs. java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at java.base/java.lang.Class.getDeclaredMethods0(Native Method) at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3167) at java.base/java.lang.Class.getMethodsRecursive(Class.java:3308) at java.base/java.lang.Class.getMethod0(Class.java:3294) at java.base/java.lang.Class.getMethod(Class.java:2107) at jdk.javadoc/com.sun.tools.javadoc.main.DocletInvoker.invoke(DocletInvoker.java:309) at jdk.javadoc/com.sun.tools.javadoc.main.DocletInvoker.optionLength(DocletInvoker.java:236) at jdk.javadoc/com.sun.tools.javadoc.main.Start.parseAndExecute(Start.java:341) at jdk.javadoc/com.sun.tools.javadoc.main.Start.begin(Start.java:238) at jdk.javadoc/com.sun.tools.javadoc.main.Start.begin(Start.java:224) at jdk.javadoc/com.sun.tools.javadoc.Main.execute(Main.java:174) at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:419) at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:344) at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63) at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 15 more

According to the release-notes, Java 11 removed the Java EE modules: java.xml.bind (JAXB) - REMOVED See JEP 320 for more info.

fidget83 avatar Mar 22 '19 11:03 fidget83

I came here because my project does not compile on Java 11 because of transitive dependency to com.sun:tools through xml-doclet. Unfortunately the above commits do not fix the problem:

developer@ea6000021698:~/xml-doclet$ mvn clean install
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.github.markusbernhardt:xml-doclet:jar:1.0.6-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.sun:tools:jar refers to a non-existing file /usr/lib/jvm/java-11-openjdk-amd64/../lib/tools.jar. Please verify that you run Maven using a JDK and not just a JRE. @ line 61, column 16
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building XML Doclet 1.0.6-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.774 s
[INFO] Finished at: 2019-03-27T10:14:25+00:00
[INFO] Final Memory: 7M/34M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project xml-doclet: Could not resolve dependencies for project com.github.markusbernhardt:xml-doclet:jar:1.0.6-SNAPSHOT: Could not find artifact com.sun:tools:jar:1.7 at specified path /usr/lib/jvm/java-11-openjdk-amd64/../lib/tools.jar -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

magwas avatar Mar 27 '19 10:03 magwas

this makes it build:

diff --git a/pom.xml b/pom.xml
index 69498c9..88be892 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,13 +54,6 @@
 
        <dependencies>
                <dependency>
-                       <groupId>com.sun</groupId>
-                       <artifactId>tools</artifactId>
-                       <version>${java.version}</version>
-                       <scope>system</scope>
-                       <systemPath>${java.home}/../lib/tools.jar</systemPath>
-               </dependency>
-               <dependency>
                        <groupId>commons-cli</groupId>
                        <artifactId>commons-cli</artifactId>
                        <version>1.2</version>

magwas avatar Mar 27 '19 10:03 magwas

I have made a pull request out of it. Please make a new release, so I can fix my project.

magwas avatar Mar 27 '19 10:03 magwas

Incorporated here: https://github.com/manticore-projects/xml-doclet

<docletArtifact>
    <groupId>com.manticore-projects.tools</groupId>
    <artifactId>xml-doclet</artifactId>
    <version>1.1.3</version>
</docletArtifact>

manticore-projects avatar May 08 '23 11:05 manticore-projects

It seems JDK 13 dropped support entirely:

[INFO] >>> javadoc:3.4.1:javadoc (xml-doclet)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc (xml-doclet) on project motion-ui: An error has occurred in Javadoc report generation: 
[ERROR] Exit code: 1 - error: Class com.github.markusbernhardt.xmldoclet.XmlDoclet is not a valid doclet.
[ERROR]   Note: As of JDK 13, the com.sun.javadoc API is no longer supported.

ccschneidr avatar Oct 30 '23 13:10 ccschneidr

Greetings,

you still can use my fork https://manticore-projects.com/XMLDoclet/index.html with JDK 17/21 as long as you set the Target to Java 11. I am using this for various projects, e. g.

https://manticore-projects.com/JSQLFormatter/javadoc.html https://manticore-projects.com/H2MigrationTool/javadoc_snapshot.html https://manticore-projects.com/JSQLParser/javadoc_snapshot.html

manticore-projects avatar Oct 30 '23 22:10 manticore-projects

Thanks for your response. I've created an issue there, because I was not able to use it with JDK 17. Not sure which target needs to be set, but project dependencies and output class files are only compatible with JDK 17.

ccschneidr avatar Nov 01 '23 08:11 ccschneidr