8267176: StandardDoclet should provide access to Reporter and Locale

Reviewed-by: hannesw
This commit is contained in:
Jonathan Gibbons 2021-06-02 16:56:45 +00:00
parent 56b65e4a8d
commit e1462e79df
3 changed files with 24 additions and 16 deletions

View File

@ -102,4 +102,26 @@ public class StandardDoclet implements Doclet {
public boolean run(DocletEnvironment docEnv) {
return htmlDoclet.run(docEnv);
}
/**
* {@return the locale for this doclet}
*
* @see #init(Locale, Reporter)
*
* @since 17
*/
public Locale getLocale() {
return htmlDoclet.getConfiguration().getLocale();
}
/**
* {@return the reporter for this doclet}
*
* @see #init(Locale, Reporter)
*
* @since 17
*/
public Reporter getReporter() {
return htmlDoclet.getConfiguration().getReporter();
}
}

View File

@ -55,21 +55,7 @@ public class MyTaglet implements Taglet {
Taglet.super.init(env, doclet);
docEnv = env;
// The following should be as simple as
// reporter = ((StandardDoclet) doclet).getReporter();
// JDK-8267176
try {
StandardDoclet sd = (StandardDoclet) doclet;
Field htmlDocletField = sd.getClass().getDeclaredField("htmlDoclet");
htmlDocletField.setAccessible(true);
Object htmlDoclet = htmlDocletField.get(sd);
Method getConfigurationMethod = htmlDoclet.getClass().getDeclaredMethod("getConfiguration");
Object config = getConfigurationMethod.invoke(htmlDoclet);
Method getReporterMethod = config.getClass().getMethod(("getReporter"));
reporter = (Reporter) getReporterMethod.invoke(config);
} catch (ReflectiveOperationException e) {
throw new IllegalStateException(e);
}
reporter = ((StandardDoclet) doclet).getReporter();
}
@Override

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 8267126
* @bug 8267126 8267176
* @summary javadoc should show "line and caret" for diagnostics
* @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool