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

StringIndexOutOfBoundsException on javadoc having method name as Property

    Details

      Description

      FULL PRODUCT VERSION :
      openjdk version "1.8.0_121"
      OpenJDK Runtime Environment (build 1.8.0_121-b13)
      OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux zeta 4.2.5-1-ARCH #1 SMP PREEMPT Tue Oct 27 08:13:28 CET 2015 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Having a static method named "Property" inside a static inner class causes javadoc to throw StringIndexOutOfBoundsException. Naming the offender method to "property", "Property_" and almost anything else solves the problem. See the attached code for a minimal example.

      In the context where this issue was originally met, renaming the method is not a desirable solution.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Save the source code provided into RDF.java and run:

      $ javadoc -d /tmp/doc org.example RDF.java




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Loading source file src/main/java/org/example/RDF.java...
      Loading source files for package org.example...
      javadoc: warning - No source files for package org.example
      Constructing Javadoc information...
      Standard Doclet version 1.8.0_121
      Building tree for all the packages and classes...
      Generating /tmp/doc/org/example/RDF.html...
      Generating /tmp/doc/org/example/RDF.Init.html...
      Generating /tmp/doc/org/example/package-frame.html...
      Generating /tmp/doc/org/example/package-summary.html...
      Generating /tmp/doc/org/example/package-tree.html...
      Generating /tmp/doc/constant-values.html...
      Building index for all the packages and classes...
      Generating /tmp/doc/overview-tree.html...
      Generating /tmp/doc/index-all.html...
      Generating /tmp/doc/deprecated-list.html...
      Building index for all classes...
      Generating /tmp/doc/allclasses-frame.html...
      Generating /tmp/doc/allclasses-noframe.html...
      Generating /tmp/doc/index.html...
      Generating /tmp/doc/help-doc.html...
      1 warning

      ACTUAL -
      java.lang.StringIndexOutOfBoundsException is thrown when acessing the first char of an empty string at com.sun.tools.doclets.internal.toolkit.util.VisibleMemberMap (line 607 according to the trace). See the provided trace.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Loading source file src/main/java/org/example/RDF.java...
      Loading source files for package org.example...
      javadoc: warning - No source files for package org.example
      Constructing Javadoc information...
      Standard Doclet version 1.8.0_121
      Building tree for all the packages and classes...
      Generating /tmp/doc/org/example/RDF.html...
      Generating /tmp/doc/org/example/RDF.Init.html...
      java.lang.StringIndexOutOfBoundsException: String index out of range: 0
      at java.lang.String.charAt(String.java:658)
      at com.sun.tools.doclets.internal.toolkit.util.VisibleMemberMap$ClassMembers.getterForField(VisibleMemberMap.java:607)
      at com.sun.tools.doclets.internal.toolkit.util.VisibleMemberMap$ClassMembers.properties(VisibleMemberMap.java:552)
      at com.sun.tools.doclets.internal.toolkit.util.VisibleMemberMap$ClassMembers.getClassMembers(VisibleMemberMap.java:467)
      at com.sun.tools.doclets.internal.toolkit.util.VisibleMemberMap$ClassMembers.addMembers(VisibleMemberMap.java:372)
      at com.sun.tools.doclets.internal.toolkit.util.VisibleMemberMap$ClassMembers.mapClass(VisibleMemberMap.java:346)
      at com.sun.tools.doclets.internal.toolkit.util.VisibleMemberMap$ClassMembers.build(VisibleMemberMap.java:341)
      at com.sun.tools.doclets.internal.toolkit.util.VisibleMemberMap$ClassMembers.access$100(VisibleMemberMap.java:291)
      at com.sun.tools.doclets.internal.toolkit.util.VisibleMemberMap.<init>(VisibleMemberMap.java:127)
      at com.sun.tools.doclets.internal.toolkit.builders.MemberSummaryBuilder.<init>(MemberSummaryBuilder.java:82)
      at com.sun.tools.doclets.internal.toolkit.builders.MemberSummaryBuilder.getInstance(MemberSummaryBuilder.java:101)
      at com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory.getMemberSummaryBuilder(BuilderFactory.java:278)
      at com.sun.tools.doclets.formats.html.ClassWriterImpl.getNavSummaryLinks(ClassWriterImpl.java:641)
      at com.sun.tools.doclets.formats.html.ClassWriterImpl.addSummaryDetailLinks(ClassWriterImpl.java:622)
      at com.sun.tools.doclets.formats.html.HtmlDocletWriter.addNavLinks(HtmlDocletWriter.java:560)
      at com.sun.tools.doclets.formats.html.ClassWriterImpl.getHeader(ClassWriterImpl.java:165)
      at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.buildClassDoc(ClassBuilder.java:145)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.invokeMethod(AbstractBuilder.java:187)
      at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:135)
      at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.build(ClassBuilder.java:120)
      at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:189)
      at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:194)
      at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:139)
      at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:82)
      at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:80)
      at com.sun.tools.doclets.standard.Standard.start(Standard.java:39)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:310)
      at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:189)
      at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:366)
      at com.sun.tools.javadoc.Start.begin(Start.java:219)
      at com.sun.tools.javadoc.Start.begin(Start.java:205)
      at com.sun.tools.javadoc.Main.execute(Main.java:64)
      at com.sun.tools.javadoc.Main.main(Main.java:54)
      javadoc: error - String index out of range: 0
      1 error
      1 warning


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package org.example;

      public class RDF {
          public static final String Property = Init.Property();
      // public static final String Property = "Property";
          public static final String List = Init.List();

          public static class Init {
              //this field breaks javadoc
              //comment it and replace the Property field of the outer class
              public static String Property() { return "Property"; }

              //"List" and several other names used in the Apache Jena RDF and RDFS class are OK
              public static String List() { return "List"; }
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Changing the static method name from Property to Property_ or anything else fixes the issue (note that "List" does cause the isse.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                fmatte Fairoz Matte
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: