Skip to content

Conversation

@zhtttylz
Copy link
Owner

@zhtttylz zhtttylz commented Oct 14, 2025

Overview
This change ports JDiff’s doclet to the modern jdk.javadoc.doclet.Doclet API so it compiles and runs on JDK 17 while preserving the legacy command‑line surface and the XML output contract. (The new Doclet API has been the supported path since JDK 9/JEP 221.)

Implementation details

  • Doclet lifecycle: JDiff now implements Doclet and provides init, getSupportedOptions, getSupportedSourceVersion, and run. The DocletEnvironment collected by javadoc is forwarded into the existing generation pipeline.
  • Options: Legacy flags are registered as Doclet.Option so existing invocations continue to work. Arguments are captured during option parsing and applied after initialization, preserving prior validation/state flow.
  • RootDocToXML rewrite: RootDocToXML is refactored around DocletEnvironment, DocTrees, and the javax.lang.model APIs. Package/type discovery, visibility filtering, and metadata emission produce the same XML schema/shape as before.
  • Source locations (-addsrcinfo): Source reporting is implemented via DocTrees path and LineMap lookups to match the legacy feature on newer compiler APIs
  • Type/signature rendering: Normalizes erasures, escapes XML‑sensitive chars, and preserves varargs handling to avoid diff churn in generated XML.

Compatibility & output parity

  • XML contract: Unchanged. Downstream tools consuming JDiff XML should see no structural diffs.
  • Docs extraction: Behavior matches legacy JDiff—by default the full doc block is emitted; with -firstsentence only the first sentence is written. Package‑level fallbacks are still supported.

After generating the API XML for hadoop-hdfs with the new JDiff doclet, the output is as follows:
Apache_Hadoop_HDFS_3.5.0-SNAPSHOT.xml

@zhtttylz zhtttylz changed the title Port doclet to JDK 17 APIs Migrate JDiff doclet to JDK 17 Doclet API Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants