RFR: JDK-8189778: Jshell crash on tab for StringBuilder.append(

Jan Lahoda jan.lahoda at oracle.com
Thu Oct 26 09:35:46 UTC 2017


Hi,

Typing:
jshell> StringBuilder sb = new StringBuilder();
jshell> sb.append(<tab><tab>

Will lead to an exception:
jshell> sb.append(Exception in thread "main" 
java.lang.StringIndexOutOfBoundsException: start -59, end -59, length 238
[snip]
jdk.compiler/jdk.internal.shellsupport.doc.JavadocHelper$OnDemandJavadocHelper.getResolvedDocComment(JavadocHelper.java:481)

The reason is that the javadoc for StringBuilder.append(CharSequence, 
int, int) is:
     /**
      * @throws     IndexOutOfBoundsException {@inheritDoc}
      */

The JavadocHelper tries to fill in the missing javadoc entries, but that 
fails because it tries to insert the preceding entries at an 
uninitialized place.

The proposed patch:
-fixes the above
-adds a test that runs the JavadocHelper on all 
methods/fields/constructors of top-level types in all exported packages 
(this runs for a considerable time, and we may need to disable this test 
if it proves to be too heavyweight)
-adds a few more test cases for problems found by the above test
-fixes the javadoc resolution to treat missing javadoc body as 
{@inheritDoc} (so that the overridden method's javadoc text is used if 
missing in this method)

Bug: https://bugs.openjdk.java.net/browse/JDK-8189778
Webrev: http://cr.openjdk.java.net/~jlahoda/8189778/webrev.00/

Feedback is welcome.

Thanks,
     Jan


More information about the compiler-dev mailing list