JDK-8223552 : change in implicit header nesting breaks backwards compatibility
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 13
  • Priority: P2
  • Status: Resolved
  • Resolution: Won't Fix
  • OS: generic
  • CPU: x86_64
  • Submitted: 2019-05-07
  • Updated: 2023-09-04
  • Resolved: 2019-06-03
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
With the change for <https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8219801>, header nesting in generated Javadoc has changed. This is likely well-intended, but makes it impossible to write Javadoc that works both with jdk-13 and previous releases.



REGRESSION : Last worked in version 12.0.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
sample file:
---
public class JavaDocHtmlHeaderTest {

  /**
    * One sentence.
    * <p>Another sentence
    * <h3>H3</h3>
    * <p>Yet another sentence.
    */
  public void foo() {
  }
}
---

Then run javadoc, such as with:
---
 /usr/local/jdk-13/bin/javadoc JavaDocHtmlHeaderTest.java
---

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Javadoc generation should pass.
ACTUAL -
Fails with:
---
JavaDocHtmlHeaderTest.java:6: error: unexpected heading used: <H3>, compared to implicit preceding heading: <H3>
    * <h3>H3</h3>
      ^
---


---------- BEGIN SOURCE ----------
public class JavaDocHtmlHeaderTest {

  /**
    * One sentence.
    * <p>Another sentence
    * <h3>H3</h3>
    * <p>Yet another sentence.
    */
  public void foo() {
  }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
I understand that the "fix" is to change the "<h3>" to "<h4>". This fixes the issue for jdk-13, but now jdk-12's javadoc generation will break.

This is a severe issue for projects that wish to support a range of JDK versions, such as Java 8, the latest LTS, and the latest & greatest.

Please consider one of these approaches:

- allow to turn off the change in behavior
- add an option that will instruct javadoc to rewrite the <h*> elements (if it can detect the issue, it can theoretically fix it as well)
- backport the change to earlier JDKs

FREQUENCY : always



Comments
My bad ... and my apologies. I gave bad advice. The heading checks count as accessibility checks, so use `-Xdoclint:-accessibility`
12-12-2022

-Xdoclint:-html does NOT suppress the "heading used out of sequence" or "unexpected heading used" errors. (At least not in JDK 17). It does suppress other HTML issues, like "tag not supported in HTML5: tt"
12-12-2022

I'm closing this as "Won't Fix" because one of the suggested alternatives is already available. The submitter suggests: - allow to turn off the change in behavior Use -Xdoclint:-html to disable HTML checking. The option is available in JDK 8 and subsequent releases.
03-06-2019

This is a regression from 13 ea b13 onwards. 13 ea b12 - Pass 13 ea b13 - Fail 13 ea b19 - Fail Looks like the issue is caused by JDK-8220379
08-05-2019