The following issues were found
android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java
4 issues
Line: 48
* under JDK7
*/
public class OpenJdk6MapTests extends TestsForMapsInJavaUtil {
public static Test suite() {
return new OpenJdk6MapTests().allTests();
}
@Override
protected Collection<Method> suppressForTreeMapNatural() {
Reported by PMD.
Line: 85
@Override
protected Collection<Method> suppressForConcurrentSkipListMap() {
List<Method> methods = newArrayList();
methods.addAll(super.suppressForConcurrentSkipListMap());
methods.add(getContainsEntryWithIncomparableKeyMethod());
methods.add(getContainsEntryWithIncomparableValueMethod());
return methods;
}
}
Reported by PMD.
Line: 86
protected Collection<Method> suppressForConcurrentSkipListMap() {
List<Method> methods = newArrayList();
methods.addAll(super.suppressForConcurrentSkipListMap());
methods.add(getContainsEntryWithIncomparableKeyMethod());
methods.add(getContainsEntryWithIncomparableValueMethod());
return methods;
}
}
Reported by PMD.
Line: 87
List<Method> methods = newArrayList();
methods.addAll(super.suppressForConcurrentSkipListMap());
methods.add(getContainsEntryWithIncomparableKeyMethod());
methods.add(getContainsEntryWithIncomparableValueMethod());
return methods;
}
}
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/TestUnhashableCollectionGenerator.java
4 issues
Line: 51
* Creates a new collection containing the given elements; implement this method instead of {@link
* #create(Object...)}.
*/
protected abstract T create(UnhashableObject[] elements);
@Override
public UnhashableObject[] createArray(int length) {
return new UnhashableObject[length];
}
Reported by PMD.
Line: 39
@Override
public T create(Object... elements) {
UnhashableObject[] array = createArray(elements.length);
int i = 0;
for (Object e : elements) {
array[i++] = (UnhashableObject) e;
}
return create(array);
Reported by PMD.
Line: 40
@Override
public T create(Object... elements) {
UnhashableObject[] array = createArray(elements.length);
int i = 0;
for (Object e : elements) {
array[i++] = (UnhashableObject) e;
}
return create(array);
}
Reported by PMD.
Line: 42
UnhashableObject[] array = createArray(elements.length);
int i = 0;
for (Object e : elements) {
array[i++] = (UnhashableObject) e;
}
return create(array);
}
/**
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/TestStringSetGenerator.java
4 issues
Line: 46
return create(array);
}
protected abstract Set<String> create(String[] elements);
@Override
public String[] createArray(int length) {
return new String[length];
}
Reported by PMD.
Line: 38
@Override
public Set<String> create(Object... elements) {
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
Reported by PMD.
Line: 39
@Override
public Set<String> create(Object... elements) {
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
}
Reported by PMD.
Line: 41
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
}
protected abstract Set<String> create(String[] elements);
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/TestStringQueueGenerator.java
4 issues
Line: 46
return create(array);
}
protected abstract Queue<String> create(String[] elements);
@Override
public String[] createArray(int length) {
return new String[length];
}
Reported by PMD.
Line: 38
@Override
public Queue<String> create(Object... elements) {
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
Reported by PMD.
Line: 39
@Override
public Queue<String> create(Object... elements) {
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
}
Reported by PMD.
Line: 41
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
}
protected abstract Queue<String> create(String[] elements);
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/TestStringMapGenerator.java
4 issues
Line: 57
return create(array);
}
protected abstract Map<String, String> create(Entry<String, String>[] entries);
@Override
@SuppressWarnings("unchecked")
public final Entry<String, String>[] createArray(int length) {
return new Entry[length];
Reported by PMD.
Line: 47
@Override
public Map<String, String> create(Object... entries) {
@SuppressWarnings("unchecked")
Entry<String, String>[] array = new Entry[entries.length];
int i = 0;
for (Object o : entries) {
@SuppressWarnings("unchecked")
Entry<String, String> e = (Entry<String, String>) o;
array[i++] = e;
Reported by PMD.
Line: 48
public Map<String, String> create(Object... entries) {
@SuppressWarnings("unchecked")
Entry<String, String>[] array = new Entry[entries.length];
int i = 0;
for (Object o : entries) {
@SuppressWarnings("unchecked")
Entry<String, String> e = (Entry<String, String>) o;
array[i++] = e;
}
Reported by PMD.
Line: 52
for (Object o : entries) {
@SuppressWarnings("unchecked")
Entry<String, String> e = (Entry<String, String>) o;
array[i++] = e;
}
return create(array);
}
protected abstract Map<String, String> create(Entry<String, String>[] entries);
Reported by PMD.
android/guava/src/com/google/common/collect/AbstractIterator.java
4 issues
Line: 68
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractIterator<T extends @Nullable Object> extends UnmodifiableIterator<T> {
private State state = State.NOT_READY;
/** Constructor for use by subclasses. */
protected AbstractIterator() {}
private enum State {
Reported by PMD.
Line: 87
FAILED,
}
@CheckForNull private T next;
/**
* Returns the next element. <b>Note:</b> the implementation must call {@link #endOfData()} when
* there are no elements left in the iteration. Failure to do so could result in an infinite loop.
*
Reported by PMD.
Line: 87
FAILED,
}
@CheckForNull private T next;
/**
* Returns the next element. <b>Note:</b> the implementation must call {@link #endOfData()} when
* there are no elements left in the iteration. Failure to do so could result in an infinite loop.
*
Reported by PMD.
Line: 164
state = State.NOT_READY;
// Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
T result = uncheckedCastNullableTToT(next);
next = null;
return result;
}
/**
* Returns the next element in the iteration without advancing the iteration, according to the
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTesterTest.java
4 issues
Line: 29
*/
public class ForwardingObjectTesterTest extends TestCase {
public void testFailsToForward() {
try {
ForwardingObjectTester.testForwardingObject(FailToForward.class);
} catch (AssertionError | UnsupportedOperationException expected) {
// UnsupportedOperationException is what we see on Android.
return;
Reported by PMD.
Line: 39
fail("Should have thrown");
}
@AndroidIncompatible // TODO(cpovirk): java.lang.IllegalAccessError: superclass not accessible
public void testSuccessfulForwarding() {
ForwardingObjectTester.testForwardingObject(ForwardToDelegate.class);
}
private abstract static class FailToForward extends ForwardingObject implements Runnable {
Reported by PMD.
Line: 40
}
@AndroidIncompatible // TODO(cpovirk): java.lang.IllegalAccessError: superclass not accessible
public void testSuccessfulForwarding() {
ForwardingObjectTester.testForwardingObject(ForwardToDelegate.class);
}
private abstract static class FailToForward extends ForwardingObject implements Runnable {
@Override
Reported by PMD.
Line: 52
private abstract static class ForwardToDelegate extends ForwardingObject implements Runnable {
@Override
public void run() {
delegate().run();
}
@Override
protected abstract Runnable delegate();
}
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/UncaughtExceptionHandlersTest.java
4 issues
Line: 29
public class UncaughtExceptionHandlersTest extends TestCase {
private Runtime runtimeMock;
@Override
protected void setUp() {
runtimeMock = mock(Runtime.class);
}
Reported by PMD.
Line: 31
private Runtime runtimeMock;
@Override
protected void setUp() {
runtimeMock = mock(Runtime.class);
}
public void testExiter() {
Reported by PMD.
Line: 36
runtimeMock = mock(Runtime.class);
}
public void testExiter() {
new Exiter(runtimeMock).uncaughtException(new Thread(), new Exception());
verify(runtimeMock).exit(1);
}
}
Reported by PMD.
Line: 38
public void testExiter() {
new Exiter(runtimeMock).uncaughtException(new Thread(), new Exception());
verify(runtimeMock).exit(1);
}
}
Reported by PMD.
android/guava/src/com/google/common/base/AbstractIterator.java
4 issues
Line: 34
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractIterator<T extends @Nullable Object> implements Iterator<T> {
private State state = State.NOT_READY;
protected AbstractIterator() {}
private enum State {
READY,
Reported by PMD.
Line: 45
FAILED,
}
@CheckForNull private T next;
@CheckForNull
protected abstract T computeNext();
@CanIgnoreReturnValue
Reported by PMD.
Line: 45
FAILED,
}
@CheckForNull private T next;
@CheckForNull
protected abstract T computeNext();
@CanIgnoreReturnValue
Reported by PMD.
Line: 89
state = State.NOT_READY;
// Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
T result = uncheckedCastNullableTToT(next);
next = null;
return result;
}
@Override
public final void remove() {
Reported by PMD.
android/guava/src/com/google/common/base/Platform.java
4 issues
Line: 33
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class Platform {
private static final Logger logger = Logger.getLogger(Platform.class.getName());
private static final PatternCompiler patternCompiler = loadPatternCompiler();
private Platform() {}
Reported by PMD.
Line: 50
}
static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
WeakReference<? extends Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
return ref == null ? Optional.<T>absent() : Optional.of(enumClass.cast(ref.get()));
}
static String formatCompact4Digits(double value) {
return String.format(Locale.ROOT, "%.4g", value);
Reported by PMD.
Line: 51
static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
WeakReference<? extends Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
return ref == null ? Optional.<T>absent() : Optional.of(enumClass.cast(ref.get()));
}
static String formatCompact4Digits(double value) {
return String.format(Locale.ROOT, "%.4g", value);
}
Reported by PMD.
Line: 101
return new JdkPatternCompiler();
}
private static void logPatternCompilerError(ServiceConfigurationError e) {
logger.log(Level.WARNING, "Error loading regex compiler, falling back to next option", e);
}
private static final class JdkPatternCompiler implements PatternCompiler {
@Override
Reported by PMD.