JDK-8176089 : isSupportedOption("--allow-script-in-comments") returns wrong value
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 8,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2017-03-02
  • Updated: 2017-03-02
  • Resolved: 2017-03-02
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux artemis 4.9.10-100.fc24.x86_64 #1 SMP Wed Feb 15 18:35:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
ToolProvider.getSystemDocumentationTool().isSupportedOption("--allow-script-in-comments")
returns -1, should be 0 for this java version.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
		System.out.println(System.getProperty("java.version"));
		System.out.println(ToolProvider.getSystemDocumentationTool()
		        .isSupportedOption("--allow-script-in-comments"));


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1.8.0_121
0
ACTUAL -
1.8.0_121
-1


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/**
 * 
 */
package test;

import javax.tools.ToolProvider;

/**
 * @author mnl
 *
 */
public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println(System.getProperty("java.version"));
		System.out.println(ToolProvider.getSystemDocumentationTool()
		        .isSupportedOption("--allow-script-in-comments"));

	}

}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Class.forName('com.sun.tools.doclets.formats.html.ConfigurationImpl')
                     .newInstance().optionLength('--allow-script-in-comments') seems to work


Comments
This is a tricky one. The issue is that --allow-script-in-comments is /not/ a supported option for the javadoc tool itself. It is an option provided by the standard doclet. That is evident if you do "javadoc -help" in any version of that supports the option. And, the DocumentationTool.isSupportedOption method is not flexible enough to understand arbitrary doclets, and it would be wrong to have it understand the supported options for the standard doclet, when the standard doclet might not be in use. So, this is probably "will not fix". The workaround for JDK 8 is to use the information given on this page: https://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/index.html Look for the links "Running the standard doclet" to get the name of the class for the standard doclet, and use this method to test for supported options: https://docs.oracle.com/javase/8/docs/jdk/api/javadoc/doclet/com/sun/javadoc/Doclet.html#optionLength-java.lang.String- In JDK 9, there is a new improved Doclet API. For now, the API is visible here: http://download.java.net/java/jdk9/docs/jdk/api/javadoc/doclet/jdk.javadoc-summary.html although this may change in time. With that API, you can get access to the standard doclet, and use the new method: http://download.java.net/java/jdk9/docs/jdk/api/javadoc/doclet/jdk/javadoc/doclet/Doclet.html#getSupportedOptions-- We should probably file an RFE to enhance the documentation for DocumentationTool to explain the limitations of isSupportedOption. JDK-8176106
02-03-2017

This issue is reproducible in both 8 and 9, it looks like this issue exist for a long. == 8uxx - Fail (Including 8u121) 9 ea b157 - Fail ==
02-03-2017