Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8194281

Javadoc complains about bad class file, while compile and execution work fine

    Details

    • Subcomponent:
    • Introduced In Build:
      b104
    • Introduced In Version:
      9
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      java version "9.0.1"
      Java(TM) SE Runtime Environment (build 9.0.1+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux 4.10.0-42-generic #46-Ubuntu SMP Mon Dec 4 14:38:01 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Compiling the example, then running javadoc throws an error:

      Loading source file example/Foo.java...
      Constructing Javadoc information...
      Standard Doclet version 9.0.1
      Building tree for all the packages and classes...
      Generating ./example/Foo.html...
      Generating ./example/package-frame.html...
      Generating ./example/package-summary.html...
      Generating ./example/package-tree.html...
      Generating ./constant-values.html...
      javadoc: error - An exception occurred while building a component: Contents
      (com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: ./example/Foo$1.class
        class file contains malformed variable arity method: (java.lang.Object[],example.Foo)
        Please remove or make sure it appears in the correct subdirectory of the classpath.)
      Please file a bug against the javadoc tool via the Java bug reporting page
      (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
      for duplicates. Include error messages and the following diagnostic in your report. Thank you.
      com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: ./example/Foo$1.class
        class file contains malformed variable arity method: (java.lang.Object[],example.Foo)
        Please remove or make sure it appears in the correct subdirectory of the classpath.
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:278)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:2402)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:2641)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassBuffer(ClassReader.java:2706)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2719)
      at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:348)
      at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:285)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:633)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1314)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:1248)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements(Symbol.java:800)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems0(Utils.java:2468)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems0(Utils.java:2463)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.recursiveGetItems(Utils.java:2451)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils$16.visitPackage(Utils.java:2436)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils$16.visitPackage(Utils.java:2432)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$PackageSymbol.accept(Symbol.java:1166)
      at java.compiler@9.0.1/javax.lang.model.util.AbstractElementVisitor6.visit(AbstractElementVisitor6.java:106)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems(Utils.java:2445)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getClasses(Utils.java:2182)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getAllClasses(Utils.java:2355)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.hasConstantField(ConstantsSummaryBuilder.java:258)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.buildContents(ConstantsSummaryBuilder.java:171)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.buildChildren(AbstractBuilder.java:200)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.buildConstantSummary(ConstantsSummaryBuilder.java:156)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.build(ConstantsSummaryBuilder.java:136)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.generateOtherFiles(AbstractDoclet.java:228)
      at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlDoclet.generateOtherFiles(HtmlDoclet.java:116)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:213)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.run(AbstractDoclet.java:117)
      at jdk.javadoc/jdk.javadoc.doclet.StandardDoclet.run(StandardDoclet.java:72)
      at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:574)
      at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:423)
      at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:340)
      at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
      at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
      1 error


      REGRESSION. Last worked in version 8u152

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_152"
      Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create example/Foo.java:

      --------
      package example;

      public abstract class Foo {
          abstract boolean apply(Object input);

          Foo(Object... params) {
          }

          static Foo from(final Foo other) {
              return new Foo() {
                  @Override
                  public boolean apply(Object input) {
                      return other.apply(input);
                  }
              };
          }
      }
      --------

      Compile:
      > javac example/Foo.java
      Javadoc:
      > javadoc example/Foo.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Successful creation of the Javadoc
      ACTUAL -
      Error:

      Loading source file example/Foo.java...
      Constructing Javadoc information...
      Standard Doclet version 9.0.1
      Building tree for all the packages and classes...
      Generating ./example/Foo.html...
      Generating ./example/package-frame.html...
      Generating ./example/package-summary.html...
      Generating ./example/package-tree.html...
      Generating ./constant-values.html...
      javadoc: error - An exception occurred while building a component: Contents
      (com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: ./example/Foo$1.class
        class file contains malformed variable arity method: (java.lang.Object[],example.Foo)
        Please remove or make sure it appears in the correct subdirectory of the classpath.)
      Please file a bug against the javadoc tool via the Java bug reporting page
      (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
      for duplicates. Include error messages and the following diagnostic in your report. Thank you.
      com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: ./example/Foo$1.class
        class file contains malformed variable arity method: (java.lang.Object[],example.Foo)
        Please remove or make sure it appears in the correct subdirectory of the classpath.
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:278)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:2402)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:2641)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassBuffer(ClassReader.java:2706)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2719)
      at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:348)
      at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:285)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:633)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1314)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:1248)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements(Symbol.java:800)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems0(Utils.java:2468)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems0(Utils.java:2463)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.recursiveGetItems(Utils.java:2451)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils$16.visitPackage(Utils.java:2436)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils$16.visitPackage(Utils.java:2432)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$PackageSymbol.accept(Symbol.java:1166)
      at java.compiler@9.0.1/javax.lang.model.util.AbstractElementVisitor6.visit(AbstractElementVisitor6.java:106)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems(Utils.java:2445)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getClasses(Utils.java:2182)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getAllClasses(Utils.java:2355)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.hasConstantField(ConstantsSummaryBuilder.java:258)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.buildContents(ConstantsSummaryBuilder.java:171)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.buildChildren(AbstractBuilder.java:200)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.buildConstantSummary(ConstantsSummaryBuilder.java:156)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.build(ConstantsSummaryBuilder.java:136)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.generateOtherFiles(AbstractDoclet.java:228)
      at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlDoclet.generateOtherFiles(HtmlDoclet.java:116)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:213)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.run(AbstractDoclet.java:117)
      at jdk.javadoc/jdk.javadoc.doclet.StandardDoclet.run(StandardDoclet.java:72)
      at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:574)
      at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:423)
      at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:340)
      at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
      at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
      1 error


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Loading source file example/Foo.java...
      Constructing Javadoc information...
      Standard Doclet version 9.0.1
      Building tree for all the packages and classes...
      Generating ./example/Foo.html...
      Generating ./example/package-frame.html...
      Generating ./example/package-summary.html...
      Generating ./example/package-tree.html...
      Generating ./constant-values.html...
      javadoc: error - An exception occurred while building a component: Contents
      (com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: ./example/Foo$1.class
        class file contains malformed variable arity method: (java.lang.Object[],example.Foo)
        Please remove or make sure it appears in the correct subdirectory of the classpath.)
      Please file a bug against the javadoc tool via the Java bug reporting page
      (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
      for duplicates. Include error messages and the following diagnostic in your report. Thank you.
      com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: ./example/Foo$1.class
        class file contains malformed variable arity method: (java.lang.Object[],example.Foo)
        Please remove or make sure it appears in the correct subdirectory of the classpath.
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:278)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:2402)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:2641)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassBuffer(ClassReader.java:2706)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2719)
      at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:348)
      at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:285)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:633)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1314)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:1248)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements(Symbol.java:800)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems0(Utils.java:2468)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems0(Utils.java:2463)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.recursiveGetItems(Utils.java:2451)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils$16.visitPackage(Utils.java:2436)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils$16.visitPackage(Utils.java:2432)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$PackageSymbol.accept(Symbol.java:1166)
      at java.compiler@9.0.1/javax.lang.model.util.AbstractElementVisitor6.visit(AbstractElementVisitor6.java:106)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getItems(Utils.java:2445)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getClasses(Utils.java:2182)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getAllClasses(Utils.java:2355)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.hasConstantField(ConstantsSummaryBuilder.java:258)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.buildContents(ConstantsSummaryBuilder.java:171)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.buildChildren(AbstractBuilder.java:200)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.buildConstantSummary(ConstantsSummaryBuilder.java:156)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:157)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.build(ConstantsSummaryBuilder.java:136)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.generateOtherFiles(AbstractDoclet.java:228)
      at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlDoclet.generateOtherFiles(HtmlDoclet.java:116)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:213)
      at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.run(AbstractDoclet.java:117)
      at jdk.javadoc/jdk.javadoc.doclet.StandardDoclet.run(StandardDoclet.java:72)
      at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:574)
      at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:423)
      at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:340)
      at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
      at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      example/Foo.java
      --------
      package example;

      public abstract class Foo {
          abstract boolean apply(Object input);

          Foo(Object... params) {
          }

          static Foo from(final Foo other) {
              return new Foo() {
                  @Override
                  public boolean apply(Object input) {
                      return other.apply(input);
                  }
              };
          }
      }
      --------
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Create an inner class

      --------
      package example;

      public abstract class Foo {
          abstract boolean apply(Object input);

          Foo(Object... params) {
          }

          static Foo from(final Foo other) {
              return new MyFoo(other);
          }

          private static class MyFoo extends Foo {
              private final Foo other;

              public MyFoo(Foo other) {
                  this.other = other;
              }

              @Override
              public boolean apply(Object input) {
                  return other.apply(input);
              }
          }
      }
      --------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ksrini Kumar Srinivasan
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: