The following issues were found
android/guava/src/com/google/common/hash/AbstractStreamingHasher.java
7 issues
Line: 33
// TODO(kevinb): this class still needs some design-and-document-for-inheritance love
@CanIgnoreReturnValue
@ElementTypesAreNonnullByDefault
abstract class AbstractStreamingHasher extends AbstractHasher {
/** Buffer via which we pass data to the hash algorithm (the implementor) */
private final ByteBuffer buffer;
/** Number of bytes to be filled before process() invocation(s). */
private final int bufferSize;
Reported by PMD.
Line: 35
@ElementTypesAreNonnullByDefault
abstract class AbstractStreamingHasher extends AbstractHasher {
/** Buffer via which we pass data to the hash algorithm (the implementor) */
private final ByteBuffer buffer;
/** Number of bytes to be filled before process() invocation(s). */
private final int bufferSize;
/** Number of bytes processed per process() invocation. */
Reported by PMD.
Line: 38
private final ByteBuffer buffer;
/** Number of bytes to be filled before process() invocation(s). */
private final int bufferSize;
/** Number of bytes processed per process() invocation. */
private final int chunkSize;
/**
Reported by PMD.
Line: 41
private final int bufferSize;
/** Number of bytes processed per process() invocation. */
private final int chunkSize;
/**
* Constructor for use by subclasses. This hasher instance will process chunks of the specified
* size.
*
Reported by PMD.
Line: 96
@Override
public final Hasher putBytes(byte[] bytes, int off, int len) {
return putBytesInternal(ByteBuffer.wrap(bytes, off, len).order(ByteOrder.LITTLE_ENDIAN));
}
@Override
public final Hasher putBytes(ByteBuffer readBuffer) {
ByteOrder order = readBuffer.order();
Reported by PMD.
Line: 200
// Process pent-up data in chunks
private void munchIfFull() {
if (buffer.remaining() < 8) {
// buffer is full; not enough room for a primitive. We have at least one full chunk.
munch();
}
}
Reported by PMD.
Line: 101
@Override
public final Hasher putBytes(ByteBuffer readBuffer) {
ByteOrder order = readBuffer.order();
try {
readBuffer.order(ByteOrder.LITTLE_ENDIAN);
return putBytesInternal(readBuffer);
} finally {
readBuffer.order(order);
Reported by PMD.
android/guava/src/com/google/common/hash/ChecksumHashFunction.java
7 issues
Line: 32
@Immutable
@ElementTypesAreNonnullByDefault
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
private final String toString;
ChecksumHashFunction(
ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) {
Reported by PMD.
Line: 33
@ElementTypesAreNonnullByDefault
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
private final String toString;
ChecksumHashFunction(
ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) {
this.checksumSupplier = checkNotNull(checksumSupplier);
Reported by PMD.
Line: 33
@ElementTypesAreNonnullByDefault
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
private final String toString;
ChecksumHashFunction(
ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) {
this.checksumSupplier = checkNotNull(checksumSupplier);
Reported by PMD.
Line: 34
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
private final String toString;
ChecksumHashFunction(
ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) {
this.checksumSupplier = checkNotNull(checksumSupplier);
checkArgument(bits == 32 || bits == 64, "bits (%s) must be either 32 or 64", bits);
Reported by PMD.
Line: 34
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
private final String toString;
ChecksumHashFunction(
ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) {
this.checksumSupplier = checkNotNull(checksumSupplier);
checkArgument(bits == 32 || bits == 64, "bits (%s) must be either 32 or 64", bits);
Reported by PMD.
Line: 61
/** Hasher that updates a checksum. */
private final class ChecksumHasher extends AbstractByteHasher {
private final Checksum checksum;
private ChecksumHasher(Checksum checksum) {
this.checksum = checkNotNull(checksum);
}
Reported by PMD.
Line: 80
@Override
public HashCode hash() {
long value = checksum.getValue();
if (bits == 32) {
/*
* The long returned from a 32-bit Checksum will have all 0s for its second word, so the
* cast won't lose any information and is necessary to return a HashCode of the correct
* size.
*/
Reported by PMD.
android/guava/src/com/google/common/base/Stopwatch.java
7 issues
Line: 91
@GwtCompatible(emulated = true)
@SuppressWarnings("GoodTime") // lots of violations
@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
Reported by PMD.
Line: 92
@SuppressWarnings("GoodTime") // lots of violations
@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
Reported by PMD.
Line: 93
@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
* Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source.
Reported by PMD.
Line: 93
@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
* Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source.
Reported by PMD.
Line: 94
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
* Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source.
*
Reported by PMD.
Line: 94
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
* Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source.
*
Reported by PMD.
Line: 95
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
* Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source.
*
* @since 15.0
Reported by PMD.
android/guava/src/com/google/common/util/concurrent/ForwardingBlockingQueue.java
7 issues
Line: 53
@Override
public int drainTo(Collection<? super E> c, int maxElements) {
return delegate().drainTo(c, maxElements);
}
@Override
public int drainTo(Collection<? super E> c) {
return delegate().drainTo(c);
Reported by PMD.
Line: 58
@Override
public int drainTo(Collection<? super E> c) {
return delegate().drainTo(c);
}
@Override
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offer(e, timeout, unit);
Reported by PMD.
Line: 63
@Override
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offer(e, timeout, unit);
}
@Override
@CheckForNull
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
Reported by PMD.
Line: 69
@Override
@CheckForNull
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().poll(timeout, unit);
}
@Override
public void put(E e) throws InterruptedException {
delegate().put(e);
Reported by PMD.
Line: 74
@Override
public void put(E e) throws InterruptedException {
delegate().put(e);
}
@Override
public int remainingCapacity() {
return delegate().remainingCapacity();
Reported by PMD.
Line: 79
@Override
public int remainingCapacity() {
return delegate().remainingCapacity();
}
@Override
public E take() throws InterruptedException {
return delegate().take();
Reported by PMD.
Line: 84
@Override
public E take() throws InterruptedException {
return delegate().take();
}
}
Reported by PMD.
android/guava/src/com/google/common/graph/ElementOrder.java
7 issues
Line: 50
@Beta
@Immutable
@ElementTypesAreNonnullByDefault
public final class ElementOrder<T> {
private final Type type;
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
@CheckForNull
private final Comparator<T> comparator;
Reported by PMD.
Line: 51
@Immutable
@ElementTypesAreNonnullByDefault
public final class ElementOrder<T> {
private final Type type;
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
@CheckForNull
private final Comparator<T> comparator;
Reported by PMD.
Line: 51
@Immutable
@ElementTypesAreNonnullByDefault
public final class ElementOrder<T> {
private final Type type;
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
@CheckForNull
private final Comparator<T> comparator;
Reported by PMD.
Line: 55
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
@CheckForNull
private final Comparator<T> comparator;
/**
* The type of ordering that this object specifies.
*
* <ul>
Reported by PMD.
Line: 55
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
@CheckForNull
private final Comparator<T> comparator;
/**
* The type of ordering that this object specifies.
*
* <ul>
Reported by PMD.
Line: 183
@Override
public String toString() {
ToStringHelper helper = MoreObjects.toStringHelper(this).add("type", type);
if (comparator != null) {
helper.add("comparator", comparator);
}
return helper.toString();
}
Reported by PMD.
Line: 187
if (comparator != null) {
helper.add("comparator", comparator);
}
return helper.toString();
}
/** Returns an empty mutable map whose keys will respect this {@link ElementOrder}. */
<K extends T, V> Map<K, V> createMap(int expectedSize) {
switch (type) {
Reported by PMD.
guava/src/com/google/common/util/concurrent/ForwardingCondition.java
7 issues
Line: 28
@Override
public void await() throws InterruptedException {
delegate().await();
}
@Override
public boolean await(long time, TimeUnit unit) throws InterruptedException {
return delegate().await(time, unit);
Reported by PMD.
Line: 33
@Override
public boolean await(long time, TimeUnit unit) throws InterruptedException {
return delegate().await(time, unit);
}
@Override
public void awaitUninterruptibly() {
delegate().awaitUninterruptibly();
Reported by PMD.
Line: 38
@Override
public void awaitUninterruptibly() {
delegate().awaitUninterruptibly();
}
@Override
public long awaitNanos(long nanosTimeout) throws InterruptedException {
return delegate().awaitNanos(nanosTimeout);
Reported by PMD.
Line: 43
@Override
public long awaitNanos(long nanosTimeout) throws InterruptedException {
return delegate().awaitNanos(nanosTimeout);
}
@Override
public boolean awaitUntil(Date deadline) throws InterruptedException {
return delegate().awaitUntil(deadline);
Reported by PMD.
Line: 48
@Override
public boolean awaitUntil(Date deadline) throws InterruptedException {
return delegate().awaitUntil(deadline);
}
@Override
public void signal() {
delegate().signal();
Reported by PMD.
Line: 53
@Override
public void signal() {
delegate().signal();
}
@Override
public void signalAll() {
delegate().signalAll();
Reported by PMD.
Line: 58
@Override
public void signalAll() {
delegate().signalAll();
}
}
Reported by PMD.
guava-tests/test/com/google/common/reflect/ParameterTest.java
7 issues
Line: 31
*/
public class ParameterTest extends TestCase {
public void testNulls() {
for (Method method : ParameterTest.class.getDeclaredMethods()) {
for (Parameter param : Invokable.from(method).getParameters()) {
new NullPointerTester().testAllPublicInstanceMethods(param);
}
}
Reported by PMD.
Line: 31
*/
public class ParameterTest extends TestCase {
public void testNulls() {
for (Method method : ParameterTest.class.getDeclaredMethods()) {
for (Parameter param : Invokable.from(method).getParameters()) {
new NullPointerTester().testAllPublicInstanceMethods(param);
}
}
Reported by PMD.
Line: 33
public void testNulls() {
for (Method method : ParameterTest.class.getDeclaredMethods()) {
for (Parameter param : Invokable.from(method).getParameters()) {
new NullPointerTester().testAllPublicInstanceMethods(param);
}
}
}
Reported by PMD.
Line: 34
public void testNulls() {
for (Method method : ParameterTest.class.getDeclaredMethods()) {
for (Parameter param : Invokable.from(method).getParameters()) {
new NullPointerTester().testAllPublicInstanceMethods(param);
}
}
}
public void testEquals() {
Reported by PMD.
Line: 39
}
}
public void testEquals() {
EqualsTester tester = new EqualsTester();
for (Method method : ParameterTest.class.getDeclaredMethods()) {
for (Parameter param : Invokable.from(method).getParameters()) {
tester.addEqualityGroup(param);
}
Reported by PMD.
Line: 39
}
}
public void testEquals() {
EqualsTester tester = new EqualsTester();
for (Method method : ParameterTest.class.getDeclaredMethods()) {
for (Parameter param : Invokable.from(method).getParameters()) {
tester.addEqualityGroup(param);
}
Reported by PMD.
Line: 42
public void testEquals() {
EqualsTester tester = new EqualsTester();
for (Method method : ParameterTest.class.getDeclaredMethods()) {
for (Parameter param : Invokable.from(method).getParameters()) {
tester.addEqualityGroup(param);
}
}
tester.testEquals();
}
Reported by PMD.
guava/src/com/google/common/hash/ChecksumHashFunction.java
7 issues
Line: 32
@Immutable
@ElementTypesAreNonnullByDefault
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
private final String toString;
ChecksumHashFunction(
ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) {
Reported by PMD.
Line: 33
@ElementTypesAreNonnullByDefault
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
private final String toString;
ChecksumHashFunction(
ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) {
this.checksumSupplier = checkNotNull(checksumSupplier);
Reported by PMD.
Line: 33
@ElementTypesAreNonnullByDefault
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
private final String toString;
ChecksumHashFunction(
ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) {
this.checksumSupplier = checkNotNull(checksumSupplier);
Reported by PMD.
Line: 34
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
private final String toString;
ChecksumHashFunction(
ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) {
this.checksumSupplier = checkNotNull(checksumSupplier);
checkArgument(bits == 32 || bits == 64, "bits (%s) must be either 32 or 64", bits);
Reported by PMD.
Line: 34
final class ChecksumHashFunction extends AbstractHashFunction implements Serializable {
private final ImmutableSupplier<? extends Checksum> checksumSupplier;
private final int bits;
private final String toString;
ChecksumHashFunction(
ImmutableSupplier<? extends Checksum> checksumSupplier, int bits, String toString) {
this.checksumSupplier = checkNotNull(checksumSupplier);
checkArgument(bits == 32 || bits == 64, "bits (%s) must be either 32 or 64", bits);
Reported by PMD.
Line: 61
/** Hasher that updates a checksum. */
private final class ChecksumHasher extends AbstractByteHasher {
private final Checksum checksum;
private ChecksumHasher(Checksum checksum) {
this.checksum = checkNotNull(checksum);
}
Reported by PMD.
Line: 80
@Override
public HashCode hash() {
long value = checksum.getValue();
if (bits == 32) {
/*
* The long returned from a 32-bit Checksum will have all 0s for its second word, so the
* cast won't lose any information and is necessary to return a HashCode of the correct
* size.
*/
Reported by PMD.
guava/src/com/google/common/util/concurrent/ForwardingBlockingQueue.java
7 issues
Line: 53
@Override
public int drainTo(Collection<? super E> c, int maxElements) {
return delegate().drainTo(c, maxElements);
}
@Override
public int drainTo(Collection<? super E> c) {
return delegate().drainTo(c);
Reported by PMD.
Line: 58
@Override
public int drainTo(Collection<? super E> c) {
return delegate().drainTo(c);
}
@Override
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offer(e, timeout, unit);
Reported by PMD.
Line: 63
@Override
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offer(e, timeout, unit);
}
@Override
@CheckForNull
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
Reported by PMD.
Line: 69
@Override
@CheckForNull
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().poll(timeout, unit);
}
@Override
public void put(E e) throws InterruptedException {
delegate().put(e);
Reported by PMD.
Line: 74
@Override
public void put(E e) throws InterruptedException {
delegate().put(e);
}
@Override
public int remainingCapacity() {
return delegate().remainingCapacity();
Reported by PMD.
Line: 79
@Override
public int remainingCapacity() {
return delegate().remainingCapacity();
}
@Override
public E take() throws InterruptedException {
return delegate().take();
Reported by PMD.
Line: 84
@Override
public E take() throws InterruptedException {
return delegate().take();
}
}
Reported by PMD.
guava/src/com/google/common/util/concurrent/AggregateFutureState.java
7 issues
Line: 48
extends AbstractFuture.TrustedFuture<OutputT> {
// Lazily initialized the first time we see an exception; not released until all the input futures
// have completed and we have processed them all.
@CheckForNull private volatile Set<Throwable> seenExceptions = null;
private volatile int remaining;
private static final AtomicHelper ATOMIC_HELPER;
Reported by PMD.
Line: 48
extends AbstractFuture.TrustedFuture<OutputT> {
// Lazily initialized the first time we see an exception; not released until all the input futures
// have completed and we have processed them all.
@CheckForNull private volatile Set<Throwable> seenExceptions = null;
private volatile int remaining;
private static final AtomicHelper ATOMIC_HELPER;
Reported by PMD.
Line: 50
// have completed and we have processed them all.
@CheckForNull private volatile Set<Throwable> seenExceptions = null;
private volatile int remaining;
private static final AtomicHelper ATOMIC_HELPER;
private static final Logger log = Logger.getLogger(AggregateFutureState.class.getName());
Reported by PMD.
Line: 64
new SafeAtomicHelper(
newUpdater(AggregateFutureState.class, Set.class, "seenExceptions"),
newUpdater(AggregateFutureState.class, "remaining"));
} catch (Throwable reflectionFailure) {
// Some Android 5.0.x Samsung devices have bugs in JDK reflection APIs that cause
// getDeclaredField to throw a NoSuchFieldException when the field is definitely there.
// For these users fallback to a suboptimal implementation, based on synchronized. This will
// be a definite performance hit to those users.
thrownReflectionFailure = reflectionFailure;
Reported by PMD.
Line: 149
}
final void clearSeenExceptions() {
seenExceptions = null;
}
private abstract static class AtomicHelper {
/** Atomic compare-and-set of the {@link AggregateFutureState#seenExceptions} field. */
abstract void compareAndSetSeenExceptions(
Reported by PMD.
Line: 163
private static final class SafeAtomicHelper extends AtomicHelper {
final AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>
seenExceptionsUpdater;
final AtomicIntegerFieldUpdater<AggregateFutureState<?>> remainingCountUpdater;
@SuppressWarnings({"rawtypes", "unchecked"}) // Unavoidable with reflection API
SafeAtomicHelper(
Reported by PMD.
Line: 165
final AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>
seenExceptionsUpdater;
final AtomicIntegerFieldUpdater<AggregateFutureState<?>> remainingCountUpdater;
@SuppressWarnings({"rawtypes", "unchecked"}) // Unavoidable with reflection API
SafeAtomicHelper(
AtomicReferenceFieldUpdater seenExceptionsUpdater,
AtomicIntegerFieldUpdater remainingCountUpdater) {
Reported by PMD.