JDK-8186841 : Javadoc error: com.sun.tools.javac.code.ClassFinder$BadClassFile
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2017-08-25
  • Updated: 2018-01-02
  • Resolved: 2017-09-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10
10Resolved
Related Reports
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux opal 4.10.0-32-generic #36-Ubuntu SMP Tue Aug 8 12:10:06 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
Running the Javadoc tool produces an error that seems to be related to the javac compiler, although the code compiles fine.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Install JDK 9+181
Install Maven 3.5.0

$ git clone https://github.com/eclipse/jetty.project.git
$ cd jetty.project
$ git checkout 3c96cf200b201d26c416df86bafa835a09857a59
$ mvn clean install -DskipTests
$ mvn javadoc:javadoc


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Javadoc generation completes successfully.
ACTUAL -
Javadoc generation aborted with an error

ERROR MESSAGES/STACK TRACES THAT OCCUR :
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.0.0-M1:javadoc (default-cli) on project fcgi-server: An error has occurred in Javadoc report generation: 
[ERROR] Exit code: 1 - javadoc: error - An exception occurred while building a component: TagInfo
[ERROR] 	(com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: /home/simon/.m2/repository/org/eclipse/jetty/jetty-proxy/9.4.7-SNAPSHOT/jetty-proxy-9.4.7-SNAPSHOT.jar(/org/eclipse/jetty/proxy/AsyncMiddleManServlet$1.class)
[ERROR]   class file contains malformed variable arity method: (org.eclipse.jetty.proxy.AsyncMiddleManServlet,java.nio.ByteBuffer[],javax.servlet.http.HttpServletRequest)
[ERROR]   Please remove or make sure it appears in the correct subdirectory of the classpath.)
[ERROR] Please file a bug against the javadoc tool via the Java bug reporting page
[ERROR] (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
[ERROR] for duplicates. Include error messages and the following diagnostic in your report. Thank you.
[ERROR] com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: /home/simon/.m2/repository/org/eclipse/jetty/jetty-proxy/9.4.7-SNAPSHOT/jetty-proxy-9.4.7-SNAPSHOT.jar(/org/eclipse/jetty/proxy/AsyncMiddleManServlet$1.class)
[ERROR]   class file contains malformed variable arity method: (org.eclipse.jetty.proxy.AsyncMiddleManServlet,java.nio.ByteBuffer[],javax.servlet.http.HttpServletRequest)
[ERROR]   Please remove or make sure it appears in the correct subdirectory of the classpath.
[ERROR] 	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:278)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:2402)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:2641)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassBuffer(ClassReader.java:2706)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2719)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:348)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:285)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:633)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1314)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:1248)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements(Symbol.java:800)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems0(Utils.java:2468)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems0(Utils.java:2463)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.recursiveGetItems(Utils.java:2451)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils$16.visitPackage(Utils.java:2436)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils$16.visitPackage(Utils.java:2432)
[ERROR] 	at jdk.compiler/com.sun.tools.javac.code.Symbol$PackageSymbol.accept(Symbol.java:1166)
[ERROR] 	at java.compiler@9/javax.lang.model.util.AbstractElementVisitor6.visit(AbstractElementVisitor6.java:106)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems(Utils.java:2445)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getClasses(Utils.java:2182)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getAllClasses(Utils.java:2355)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.findClassInPackageElement(Utils.java:1047)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.WorkArounds.searchClass(WorkArounds.java:231)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.findClass(Utils.java:1065)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.taglets.ThrowsTaglet.inherit(ThrowsTaglet.java:76)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.DocFinder.search(DocFinder.java:257)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.DocFinder.search(DocFinder.java:270)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.taglets.ThrowsTaglet.inheritThrowsDocumentation(ThrowsTaglet.java:133)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.taglets.ThrowsTaglet.getTagletOutput(ThrowsTaglet.java:164)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter.genTagOutput(TagletWriter.java:238)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlDocletWriter.addTagsInfo(HtmlDocletWriter.java:319)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.MethodWriterImpl.addTags(MethodWriterImpl.java:206)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.MethodBuilder.buildTagInfo(MethodBuilder.java:207)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractMemberBuilder.build(AbstractMemberBuilder.java:87)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.buildChildren(AbstractBuilder.java:200)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.MethodBuilder.buildMethodDoc(MethodBuilder.java:151)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractMemberBuilder.build(AbstractMemberBuilder.java:87)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.buildChildren(AbstractBuilder.java:200)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ClassBuilder.buildMethodDetails(ClassBuilder.java:412)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.buildChildren(AbstractBuilder.java:200)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ClassBuilder.buildMemberDetails(ClassBuilder.java:346)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.buildChildren(AbstractBuilder.java:200)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ClassBuilder.buildClassDoc(ClassBuilder.java:155)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ClassBuilder.build(ClassBuilder.java:125)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:263)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:273)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:207)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.run(AbstractDoclet.java:117)
[ERROR] 	at jdk.javadoc/jdk.javadoc.doclet.StandardDoclet.run(StandardDoclet.java:72)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:574)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:423)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:340)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
[ERROR] 	at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
[ERROR] 
[ERROR] Command line was: /home/simon/programs/jdk9/bin/javadoc @options @packages


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Make the anonymous inner class a named inner class, see https://github.com/eclipse/jetty.project/issues/1741.


Comments
Duplicate of JDK-8187422
25-09-2017

The duplicity is that javadoc should fail gracefully if javac takes an error. The javac error is "class file contains malformed variable arity method", so converting from anon to InnerClass is fixing it, not sure why. That should be reproducible without javadoc ie. compile some file and put all those classes on the classpath and javac should report it.
13-09-2017

This bug is really a duplicate of JDK-8187422, please see the evaluation in that issue. Also see JDK-8176535, javadoc will reject bad source and class files.
11-09-2017

There are (implicitly) two bugs here. The first bug is that a bad class file was encountered. The responsibility for that lies with the author providing the class. The second bug is that the bad class file was not reported in a satisfactory manner ... i.e. an exception was reported. javadoc should improve the handling of BadClassFile in this sort of situation.
29-08-2017

Elastic Search also faced same issue :https://github.com/elastic/elasticsearch/issues/24733
29-08-2017

This issue has started from JDK9 build 118 on wards.
29-08-2017

Issue is reproducible only on 9, 8u144 - Pass 9 ea b181 - Fail
28-08-2017