Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingSummary triggers IllegalArgumentException #1444

Closed
Stephan202 opened this issue Dec 8, 2019 · 2 comments
Closed

MissingSummary triggers IllegalArgumentException #1444

Stephan202 opened this issue Dec 8, 2019 · 2 comments

Comments

@Stephan202
Copy link
Contributor

Consider the following code:

interface Dummy {
  /**
   * @return an integer
   * @see <a href="https://example.com">Example</a>
   */
  int myMethod();
}

Compile the code as follows (Caffeine must be added to the classpath explicitly due to #1398):

javac \
  -XDcompilePolicy=simple \
  -processorpath error_prone_core-2.3.4-with-dependencies.jar:caffeine-2.8.0.jar \
  '-Xplugin:ErrorProne -XepDisableAllChecks -Xep:MissingSummary:WARN' \
  Dummy.java

This causes the following failure:

Dummy.java:6: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
  int myMethod();
      ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.3.4
     BugPattern: MissingSummary
     Stack Trace:
     java.lang.IllegalArgumentException: Start [53] should not be after end [-1]
  	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:300)
  	at com.google.errorprone.fixes.IndexedPosition.<init>(IndexedPosition.java:33)
  	at com.google.errorprone.fixes.SuggestedFix$Builder.replace(SuggestedFix.java:204)
  	at com.google.errorprone.fixes.SuggestedFix.replace(SuggestedFix.java:110)
  	at com.google.errorprone.bugpatterns.javadoc.Utils.replace(Utils.java:68)
  	at com.google.errorprone.bugpatterns.javadoc.MissingSummary.generateSeeFix(MissingSummary.java:154)
  	at com.google.errorprone.bugpatterns.javadoc.MissingSummary.handle(MissingSummary.java:117)
  	at com.google.errorprone.bugpatterns.javadoc.MissingSummary.matchMethod(MissingSummary.java:84)
  	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:451)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:741)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:152)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:72)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:46)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:550)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:152)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:72)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:46)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:144)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:562)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:152)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:56)
  	at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
  	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
  	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1418)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1365)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
  	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
  	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
1 error

If the @see contains a "regular" reference instead of an HTML link then the exception is not thrown.

@graememorgan
Copy link
Member

Thanks for the report. I've sent out a fix internally.

There seems to be some issue with javac's parsing of Javadocs. It doesn't output an end position for @see in this case.

netdpb pushed a commit that referenced this issue Jan 8, 2020
… endpos for @see.

Fixes external #1444

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=288656035
netdpb pushed a commit that referenced this issue Jan 9, 2020
… endpos for @see.

Fixes #1444

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=288656035
netdpb pushed a commit that referenced this issue Jan 9, 2020
… endpos for @see.

Fixes external #1444

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=288656035
@Stephan202
Copy link
Contributor Author

This issue was resolved by 39d2506; verified fixed against master (65e5dff).

kmclarnon pushed a commit to HubSpot/error-prone that referenced this issue Feb 19, 2020
… endpos for @see.

Fixes external google#1444

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=288656035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants