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

NoClassDefFoundError on using Error-Prone on Command-Line #1292

Closed
the1derer opened this issue Jun 7, 2019 · 1 comment
Closed

NoClassDefFoundError on using Error-Prone on Command-Line #1292

the1derer opened this issue Jun 7, 2019 · 1 comment

Comments

@the1derer
Copy link

Description of the problem / feature request:

Using Error-Prone according to instruction on Command-Line using JDK 8, 9, 10, 11 terminated with Exception. The complete stack-trace is included in error.log.

Some-lines:

ShortSet.java:7: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
      s.add(i);
           ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.3.3
     BugPattern: CollectionIncompatibleType
     Stack Trace:
     java.lang.NoClassDefFoundError: com/google/common/util/concurrent/internal/InternalFutureFailureAccess
  	at java.lang.ClassLoader.defineClass1(Native Method)
  	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
  	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
  	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
  	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
  	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
  	at java.security.AccessController.doPrivileged(Native Method)
  	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
  	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  	at java.lang.ClassLoader.defineClass1(Native Method)
  	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
  	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
  	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
  	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
  	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
  	at java.security.AccessController.doPrivileged(Native Method)
  	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
  	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  	at java.lang.ClassLoader.defineClass1(Native Method)
  	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
  	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
  	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
  	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
  	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
  	at java.security.AccessController.doPrivileged(Native Method)
  	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
  	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  	at com.google.common.cache.LocalCache$LoadingValueReference.<init>(LocalCache.java:3471)
  	at com.google.common.cache.LocalCache$LoadingValueReference.<init>(LocalCache.java:3475)
  	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2133)
  	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2044)
  	at com.google.common.cache.LocalCache.get(LocalCache.java:3952)
  	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3974)
  	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4958)
  	at com.google.errorprone.VisitorState.getTypeFromString(VisitorState.java:335)
  	at com.google.errorprone.suppliers.Suppliers$5.get(Suppliers.java:121)
  	at com.google.errorprone.suppliers.Suppliers$5.get(Suppliers.java:118)
  	at com.google.errorprone.predicates.type.DescendantOf.apply(DescendantOf.java:36)
  	at com.google.errorprone.matchers.method.MethodClassMatcherImpl.matchResult(MethodClassMatcherImpl.java:44)
  	at com.google.errorprone.matchers.method.MethodClassMatcherImpl.matchResult(MethodClassMatcherImpl.java:31)
  	at com.google.errorprone.matchers.method.AbstractChainedMatcher.matchResult(AbstractChainedMatcher.java:39)
  	at com.google.errorprone.matchers.method.AbstractChainedMatcher.matchResult(AbstractChainedMatcher.java:37)
  	at com.google.errorprone.matchers.method.AbstractSimpleMatcher.matches(AbstractSimpleMatcher.java:30)
  	at com.google.errorprone.matchers.method.AbstractSimpleMatcher.matches(AbstractSimpleMatcher.java:25)
  	at com.google.errorprone.bugpatterns.collectionincompatibletype.AbstractCollectionIncompatibleTypeMatcher.matches(AbstractCollectionIncompatibleTypeMatcher.java:113)
  	at com.google.errorprone.bugpatterns.collectionincompatibletype.CollectionIncompatibleType.firstNonNullMatchResult(CollectionIncompatibleType.java:229)
  	at com.google.errorprone.bugpatterns.collectionincompatibletype.CollectionIncompatibleType.matchMethodInvocation(CollectionIncompatibleType.java:139)

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

ShortSet.java

import java.util.*;

public class ShortSet {
  public static void main (String[] args) {
    Set<Short> s = new HashSet<>();
    for (short i = 0; i < 100; i++) {
      s.add(i);
      s.remove(i - 1);
    }
    System.out.println(s.size());
  }
}

Expected Result

ShortSet.java:8: error: [CollectionIncompatibleType] Argument 'i - 1' should not be passed to this method; its type int is not compatible with its collection's type argument Short
      s.remove(i - 1);
              ^
    (see http://errorprone.info/bugpattern/CollectionIncompatibleType)
1 error

Commands Used

JDK 8
wget https://repo1.maven.org/maven2/com/google/errorprone/error_prone_core/2.3.3/error_prone_core-2.3.3-with-dependencies.jar
wget https://repo1.maven.org/maven2/org/checkerframework/dataflow/2.5.7/dataflow-2.5.7.jar
wget https://repo1.maven.org/maven2/org/checkerframework/javacutil/2.5.7/javacutil-2.5.7.jar
wget https://repo1.maven.org/maven2/com/google/code/findbugs/jFormatString/3.0.0/jFormatString-3.0.0.jar
wget https://repo1.maven.org/maven2/com/google/errorprone/javac/9+181-r4173-1/javac-9+181-r4173-1.jar
javac \
  -J-Xbootclasspath/p:javac-9+181-r4173-1.jar \
  -XDcompilePolicy=simple \
  -processorpath error_prone_core-2.3.3-with-dependencies.jar:dataflow-2.5.7.jar:javacutil-2.5.7.jar:jFormatString-3.0.0.jar \
  '-Xplugin:ErrorProne -XepDisableAllChecks -Xep:CollectionIncompatibleType:ERROR' \
  ShortSet.java
JDK 9, 10, 11
wget https://repo1.maven.org/maven2/com/google/errorprone/error_prone_core/2.3.3/error_prone_core-2.3.3-with-dependencies.jar
wget https://repo1.maven.org/maven2/org/checkerframework/dataflow/2.5.7/dataflow-2.5.7.jar
wget https://repo1.maven.org/maven2/org/checkerframework/javacutil/2.5.7/javacutil-2.5.7.jar
wget https://repo1.maven.org/maven2/com/google/code/findbugs/jFormatString/3.0.0/jFormatString-3.0.0.jar
javac \
  -XDcompilePolicy=simple \
  -processorpath error_prone_core-2.3.3-with-dependencies.jar:dataflow-2.5.7.jar:javacutil-2.5.7.jar:jFormatString-3.0.0.jar \
  '-Xplugin:ErrorProne -XepDisableAllChecks -Xep:CollectionIncompatibleType:ERROR' \
  ShortSet.java

What version of Error-Prone are you using?

error_prone_core_2.3.3-with_dependencies

Have you found anything relevant by searching the web?

Is similar/same as #1238 which is due to the absence of some dependencies.

@the1derer
Copy link
Author

Solved in error-prone_with_core-2.3.4-SNAPSHOT.jar

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

No branches or pull requests

1 participant