diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2023-03-29 12:49:22 +0200 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2023-06-24 13:10:46 +0700 |
commit | a45705fdb8dda6cb76ba15e7b4adfb81ebff70cc (patch) | |
tree | 5b634364e61803c22a231eee53dfe55b6cb8ab38 | |
parent | ba520d6cfab3b968bd020d1e965e18aa72819813 (diff) | |
download | aspectj-a45705fdb8dda6cb76ba15e7b4adfb81ebff70cc.tar.gz aspectj-a45705fdb8dda6cb76ba15e7b4adfb81ebff70cc.zip |
Fix javadoc generation broken on JDK 20
Firstly, Javadoc 20 cannot handle source level 1.7 anymore, so I bumped
it to 11, which hopefully will be around for another while. It also
matches the ajc minimum of Java 11, i.e. ajdoc and ajc are synchronised
in this regard now.
Secondly, as of JDK 20, the javadoc tool renders HTML pages with section
headers specific to the JVM default locale. The workaround is to set the
locale to English before calling javadoc.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
3 files changed, 22 insertions, 7 deletions
diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java index 313c1af3b..9d8b61140 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java @@ -28,6 +28,7 @@ import java.util.Collections; import java.util.Hashtable; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.StringTokenizer; import java.util.Vector; @@ -280,10 +281,22 @@ public class Main implements Config { files.add(StructureUtil.translateAjPathName(signatureFile.getCanonicalPath())); } } - if (LangUtil.is9VMOrGreater()) { - JavadocRunner.callJavadocViaToolProvider(options, files); - } else { - JavadocRunner.callJavadoc(javadocargs); + // Since JDK 20, the javadoc tool renders the surrounding HTML according to the JVM default locale. Section headers + // such as "Class", "Method Summary" will e.g. in German be named "Klasse", "Methodenübersicht". That would derail + // ajdoc, because it matches on English headers hard-codedly. + // + // The remedy is to temporarily change the JVM default locale while generating javadocs. + Locale defaultLocale = Locale.getDefault(); + try { + Locale.setDefault(Locale.ENGLISH); + if (LangUtil.is9VMOrGreater()) { + JavadocRunner.callJavadocViaToolProvider(options, files); + } else { + JavadocRunner.callJavadoc(javadocargs); + } + } + finally { + Locale.setDefault(defaultLocale); } } diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AJDocConstants.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AJDocConstants.java index 8bf87bb73..342435b4d 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AJDocConstants.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AJDocConstants.java @@ -13,6 +13,6 @@ package org.aspectj.tools.ajdoc; */ public class AJDocConstants { - public final static String VERSION = "1.7"; + public final static String VERSION = "11"; } diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java index 35916f030..e9ce22822 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java @@ -167,7 +167,8 @@ public abstract class AjdocTestCase extends TestCase { !sourceLevel.equals("1.7") && !sourceLevel.equals("1.8") && !sourceLevel.equals("1.9") && - !sourceLevel.equals("10")) { + !sourceLevel.startsWith("10") && + !sourceLevel.startsWith("11")) { fail("need to pass ajdoc '1.3' > '1.9' as the source level"); } String[] args = new String[6 + inputFiles.length + ajOptions.length]; @@ -199,7 +200,8 @@ public abstract class AjdocTestCase extends TestCase { !sourceLevel.equals("1.8") && !sourceLevel.equals("1.9") && !sourceLevel.startsWith("9") && - !sourceLevel.startsWith("10")) { + !sourceLevel.startsWith("10") && + !sourceLevel.startsWith("11")) { fail("need to pass suitable version to ajdoc as the source level"); } if (inputFiles.length == 0) { |