google / google-java-format

Reformats Java source code to comply with Google Java Style.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NoSuchMethodError when running 1.11.0

ratcashdev opened this issue · comments

formatting a class containing classic javadoc

/**
 * 
 *  This is my javadoc
 */
public class MyShinyClass {
  public void myMethod() {
    for (int i = 0; i < 10; i++) {}
  }
}

results in an exception

java.lang.NoSuchMethodError: 'java.lang.Comparable com.google.common.collect.Comparators.max(java.lang.Comparable, java.lang.Comparable)'
	at com.google.googlejavaformat.java.javadoc.JavadocWriter.requestWhitespace(JavadocWriter.java:273)
	at com.google.googlejavaformat.java.javadoc.JavadocWriter.requestWhitespace(JavadocWriter.java:72)
	at com.google.googlejavaformat.java.javadoc.JavadocFormatter.render(JavadocFormatter.java:122)
	at com.google.googlejavaformat.java.javadoc.JavadocFormatter.formatJavadoc(JavadocFormatter.java:52)
	at com.google.googlejavaformat.java.JavaCommentsHelper.rewrite(JavaCommentsHelper.java:47)
	at com.google.googlejavaformat.Doc$Tok.computeBreaks(Doc.java:756)
	at com.google.googlejavaformat.Doc$Level.computeSplit(Doc.java:331)
	at com.google.googlejavaformat.Doc$Level.computeBreakAndSplit(Doc.java:321)
	at com.google.googlejavaformat.Doc$Level.computeBroken(Doc.java:297)
	at com.google.googlejavaformat.Doc$Level.computeBreaks(Doc.java:267)
	at com.google.googlejavaformat.java.Formatter.format(Formatter.java:174)
	at com.google.googlejavaformat.java.Formatter.getFormatReplacements(Formatter.java:291)
	at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:267)

this is caused by guava v30 from commit dfb7a23, it seems.

Related ticket: #611

I agree it looks similar to the other bug. The issue is probably that you're running the formatter with an older version of guava on the classpath. Upgrading to a new version of guava should fix the crash.

Just realized this as well, thanks.