The following issues were found
guava-tests/test/com/google/common/cache/CacheTesting.java
68 issues
Line: 15
* the License.
*/
package com.google.common.cache;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 72
Preconditions.checkState(valueRef instanceof Reference);
Reference<V> ref = (Reference<V>) valueRef;
if (ref != null) {
ref.clear();
}
}
}
/**
Reported by PMD.
Line: 97
checkNotNull(cache);
checkNotNull(key);
LocalCache<K, V> map = toLocalCache(cache);
return map.getEntry(key);
}
/**
* Forces the segment containing the given {@code key} to expand (see {@link Segment#expand()}.
*/
Reported by PMD.
Line: 107
checkNotNull(cache);
checkNotNull(key);
LocalCache<K, V> map = toLocalCache(cache);
int hash = map.hash(key);
Segment<K, V> segment = map.segmentFor(hash);
segment.expand();
}
/**
Reported by PMD.
Line: 108
checkNotNull(key);
LocalCache<K, V> map = toLocalCache(cache);
int hash = map.hash(key);
Segment<K, V> segment = map.segmentFor(hash);
segment.expand();
}
/**
* Gets the {@link LocalCache} used by the given {@link Cache}, if any, or throws an
Reported by PMD.
guava/src/com/google/common/collect/ImmutableRangeSet.java
68 issues
Line: 52
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
Reported by PMD.
Line: 52
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
Reported by PMD.
Line: 52
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
Reported by PMD.
Line: 52
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
Reported by PMD.
Line: 53
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
private static final ImmutableRangeSet<Comparable<?>> ALL =
Reported by PMD.
Line: 58
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
private static final ImmutableRangeSet<Comparable<?>> ALL =
new ImmutableRangeSet<>(ImmutableList.of(Range.<Comparable<?>>all()));
/**
* Returns a {@code Collector} that accumulates the input elements into a new {@code
* ImmutableRangeSet}. As in {@link Builder}, overlapping ranges are not permitted and adjacent
Reported by PMD.
Line: 78
*
* <p><b>Performance note:</b> the instance returned is a singleton.
*/
@SuppressWarnings("unchecked")
public static <C extends Comparable> ImmutableRangeSet<C> of() {
return (ImmutableRangeSet<C>) EMPTY;
}
/**
Reported by PMD.
Line: 115
if (rangeSet instanceof ImmutableRangeSet) {
ImmutableRangeSet<C> immutableRangeSet = (ImmutableRangeSet<C>) rangeSet;
if (!immutableRangeSet.isPartialView()) {
return immutableRangeSet;
}
}
return new ImmutableRangeSet<C>(ImmutableList.copyOf(rangeSet.asRanges()));
}
Reported by PMD.
Line: 168
ANY_PRESENT,
NEXT_HIGHER);
if (ceilingIndex < ranges.size()
&& ranges.get(ceilingIndex).isConnected(otherRange)
&& !ranges.get(ceilingIndex).intersection(otherRange).isEmpty()) {
return true;
}
return ceilingIndex > 0
&& ranges.get(ceilingIndex - 1).isConnected(otherRange)
Reported by PMD.
Line: 169
NEXT_HIGHER);
if (ceilingIndex < ranges.size()
&& ranges.get(ceilingIndex).isConnected(otherRange)
&& !ranges.get(ceilingIndex).intersection(otherRange).isEmpty()) {
return true;
}
return ceilingIndex > 0
&& ranges.get(ceilingIndex - 1).isConnected(otherRange)
&& !ranges.get(ceilingIndex - 1).intersection(otherRange).isEmpty();
Reported by PMD.
android/guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java
68 issues
Line: 31
*/
public class SubscriberRegistryTest extends TestCase {
private final SubscriberRegistry registry = new SubscriberRegistry(new EventBus());
public void testRegister() {
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
Reported by PMD.
Line: 33
private final SubscriberRegistry registry = new SubscriberRegistry(new EventBus());
public void testRegister() {
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
Reported by PMD.
Line: 33
private final SubscriberRegistry registry = new SubscriberRegistry(new EventBus());
public void testRegister() {
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
Reported by PMD.
Line: 34
private final SubscriberRegistry registry = new SubscriberRegistry(new EventBus());
public void testRegister() {
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
Reported by PMD.
Line: 34
private final SubscriberRegistry registry = new SubscriberRegistry(new EventBus());
public void testRegister() {
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
Reported by PMD.
Line: 37
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
registry.register(new ObjectSubscriber());
Reported by PMD.
Line: 37
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
registry.register(new ObjectSubscriber());
Reported by PMD.
Line: 40
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
registry.register(new ObjectSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
assertEquals(1, registry.getSubscribersForTesting(Object.class).size());
}
Reported by PMD.
Line: 40
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
registry.register(new ObjectSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
assertEquals(1, registry.getSubscribersForTesting(Object.class).size());
}
Reported by PMD.
Line: 43
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
registry.register(new ObjectSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
assertEquals(1, registry.getSubscribersForTesting(Object.class).size());
}
public void testUnregister() {
StringSubscriber s1 = new StringSubscriber();
Reported by PMD.
guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java
68 issues
Line: 31
*/
public class SubscriberRegistryTest extends TestCase {
private final SubscriberRegistry registry = new SubscriberRegistry(new EventBus());
public void testRegister() {
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
Reported by PMD.
Line: 33
private final SubscriberRegistry registry = new SubscriberRegistry(new EventBus());
public void testRegister() {
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
Reported by PMD.
Line: 33
private final SubscriberRegistry registry = new SubscriberRegistry(new EventBus());
public void testRegister() {
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
Reported by PMD.
Line: 34
private final SubscriberRegistry registry = new SubscriberRegistry(new EventBus());
public void testRegister() {
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
Reported by PMD.
Line: 34
private final SubscriberRegistry registry = new SubscriberRegistry(new EventBus());
public void testRegister() {
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
Reported by PMD.
Line: 37
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
registry.register(new ObjectSubscriber());
Reported by PMD.
Line: 37
assertEquals(0, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
registry.register(new ObjectSubscriber());
Reported by PMD.
Line: 40
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
registry.register(new ObjectSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
assertEquals(1, registry.getSubscribersForTesting(Object.class).size());
}
Reported by PMD.
Line: 40
assertEquals(1, registry.getSubscribersForTesting(String.class).size());
registry.register(new StringSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
registry.register(new ObjectSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
assertEquals(1, registry.getSubscribersForTesting(Object.class).size());
}
Reported by PMD.
Line: 43
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
registry.register(new ObjectSubscriber());
assertEquals(2, registry.getSubscribersForTesting(String.class).size());
assertEquals(1, registry.getSubscribersForTesting(Object.class).size());
}
public void testUnregister() {
StringSubscriber s1 = new StringSubscriber();
Reported by PMD.
guava-tests/test/com/google/common/collect/ForwardingMapTest.java
68 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static java.lang.reflect.Modifier.STATIC;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
Reported by PMD.
Line: 58
* @author Louis Wasserman
*/
public class ForwardingMapTest extends TestCase {
static class StandardImplForwardingMap<K, V> extends ForwardingMap<K, V> {
private final Map<K, V> backingMap;
StandardImplForwardingMap(Map<K, V> backingMap) {
this.backingMap = backingMap;
}
Reported by PMD.
Line: 59
*/
public class ForwardingMapTest extends TestCase {
static class StandardImplForwardingMap<K, V> extends ForwardingMap<K, V> {
private final Map<K, V> backingMap;
StandardImplForwardingMap(Map<K, V> backingMap) {
this.backingMap = backingMap;
}
Reported by PMD.
Line: 120
return new StandardEntrySet() {
@Override
public Iterator<Entry<K, V>> iterator() {
return delegate().entrySet().iterator();
}
};
}
@Override
Reported by PMD.
Line: 120
return new StandardEntrySet() {
@Override
public Iterator<Entry<K, V>> iterator() {
return delegate().entrySet().iterator();
}
};
}
@Override
Reported by PMD.
Line: 136
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
Reported by PMD.
Line: 187
return suite;
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
Map.class,
new Function<Map, Map>() {
Reported by PMD.
Line: 187
return suite;
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
Map.class,
new Function<Map, Map>() {
Reported by PMD.
Line: 188
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
Map.class,
new Function<Map, Map>() {
@Override
Reported by PMD.
Line: 200
});
}
public void testEquals() {
Map<Integer, String> map1 = ImmutableMap.of(1, "one");
Map<Integer, String> map2 = ImmutableMap.of(2, "two");
new EqualsTester()
.addEqualityGroup(map1, wrap(map1), wrap(map1))
.addEqualityGroup(map2, wrap(map2))
Reported by PMD.
android/guava-tests/test/com/google/common/io/CharSourceTest.java
67 issues
Line: 44
*
* @author Colin Decker
*/
public class CharSourceTest extends IoTestCase {
@AndroidIncompatible // Android doesn't understand suites whose tests lack default constructors.
public static TestSuite suite() {
TestSuite suite = new TestSuite();
for (boolean asByteSource : new boolean[] {false, true}) {
Reported by PMD.
Line: 44
*
* @author Colin Decker
*/
public class CharSourceTest extends IoTestCase {
@AndroidIncompatible // Android doesn't understand suites whose tests lack default constructors.
public static TestSuite suite() {
TestSuite suite = new TestSuite();
for (boolean asByteSource : new boolean[] {false, true}) {
Reported by PMD.
Line: 44
*
* @author Colin Decker
*/
public class CharSourceTest extends IoTestCase {
@AndroidIncompatible // Android doesn't understand suites whose tests lack default constructors.
public static TestSuite suite() {
TestSuite suite = new TestSuite();
for (boolean asByteSource : new boolean[] {false, true}) {
Reported by PMD.
Line: 66
private static final String STRING = ASCII + I18N;
private static final String LINES = "foo\nbar\r\nbaz\rsomething";
private TestCharSource source;
@Override
public void setUp() {
source = new TestCharSource(STRING);
}
Reported by PMD.
Line: 68
private TestCharSource source;
@Override
public void setUp() {
source = new TestCharSource(STRING);
}
public void testOpenBufferedStream() throws IOException {
Reported by PMD.
Line: 73
source = new TestCharSource(STRING);
}
public void testOpenBufferedStream() throws IOException {
BufferedReader reader = source.openBufferedStream();
assertTrue(source.wasStreamOpened());
assertFalse(source.wasStreamClosed());
StringWriter writer = new StringWriter();
Reported by PMD.
Line: 73
source = new TestCharSource(STRING);
}
public void testOpenBufferedStream() throws IOException {
BufferedReader reader = source.openBufferedStream();
assertTrue(source.wasStreamOpened());
assertFalse(source.wasStreamClosed());
StringWriter writer = new StringWriter();
Reported by PMD.
Line: 74
}
public void testOpenBufferedStream() throws IOException {
BufferedReader reader = source.openBufferedStream();
assertTrue(source.wasStreamOpened());
assertFalse(source.wasStreamClosed());
StringWriter writer = new StringWriter();
char[] buf = new char[64];
Reported by PMD.
Line: 81
StringWriter writer = new StringWriter();
char[] buf = new char[64];
int read;
while ((read = reader.read(buf)) != -1) {
writer.write(buf, 0, read);
}
reader.close();
writer.close();
Reported by PMD.
Line: 81
StringWriter writer = new StringWriter();
char[] buf = new char[64];
int read;
while ((read = reader.read(buf)) != -1) {
writer.write(buf, 0, read);
}
reader.close();
writer.close();
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/MultimapPutIterableTester.java
67 issues
Line: 44
*/
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapPutIterableTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnPresentKey() {
assertTrue(
multimap()
Reported by PMD.
Line: 45
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapPutIterableTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnPresentKey() {
assertTrue(
multimap()
.putAll(
Reported by PMD.
Line: 47
public class MultimapPutIterableTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnPresentKey() {
assertTrue(
multimap()
.putAll(
k0(),
new Iterable<V>() {
Reported by PMD.
Line: 55
new Iterable<V>() {
@Override
public Iterator<V> iterator() {
return Lists.newArrayList(v3(), v4()).iterator();
}
}));
assertGet(k0(), v0(), v3(), v4());
}
Reported by PMD.
Line: 61
assertGet(k0(), v0(), v3(), v4());
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyCollectionOnPresentKey() {
assertTrue(multimap().putAll(k0(), Lists.newArrayList(v3(), v4())));
assertGet(k0(), v0(), v3(), v4());
}
Reported by PMD.
Line: 63
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyCollectionOnPresentKey() {
assertTrue(multimap().putAll(k0(), Lists.newArrayList(v3(), v4())));
assertGet(k0(), v0(), v3(), v4());
}
@MapFeature.Require(SUPPORTS_PUT)
Reported by PMD.
Line: 64
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyCollectionOnPresentKey() {
assertTrue(multimap().putAll(k0(), Lists.newArrayList(v3(), v4())));
assertGet(k0(), v0(), v3(), v4());
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnAbsentKey() {
Reported by PMD.
Line: 68
assertGet(k0(), v0(), v3(), v4());
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnAbsentKey() {
assertTrue(
multimap()
.putAll(
k3(),
Reported by PMD.
Line: 69
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnAbsentKey() {
assertTrue(
multimap()
.putAll(
k3(),
new Iterable<V>() {
Reported by PMD.
Line: 77
new Iterable<V>() {
@Override
public Iterator<V> iterator() {
return Lists.newArrayList(v3(), v4()).iterator();
}
}));
assertGet(k3(), v3(), v4());
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultimapPutIterableTester.java
67 issues
Line: 44
*/
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapPutIterableTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnPresentKey() {
assertTrue(
multimap()
Reported by PMD.
Line: 45
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapPutIterableTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnPresentKey() {
assertTrue(
multimap()
.putAll(
Reported by PMD.
Line: 47
public class MultimapPutIterableTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnPresentKey() {
assertTrue(
multimap()
.putAll(
k0(),
new Iterable<V>() {
Reported by PMD.
Line: 55
new Iterable<V>() {
@Override
public Iterator<V> iterator() {
return Lists.newArrayList(v3(), v4()).iterator();
}
}));
assertGet(k0(), v0(), v3(), v4());
}
Reported by PMD.
Line: 61
assertGet(k0(), v0(), v3(), v4());
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyCollectionOnPresentKey() {
assertTrue(multimap().putAll(k0(), Lists.newArrayList(v3(), v4())));
assertGet(k0(), v0(), v3(), v4());
}
Reported by PMD.
Line: 63
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyCollectionOnPresentKey() {
assertTrue(multimap().putAll(k0(), Lists.newArrayList(v3(), v4())));
assertGet(k0(), v0(), v3(), v4());
}
@MapFeature.Require(SUPPORTS_PUT)
Reported by PMD.
Line: 64
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyCollectionOnPresentKey() {
assertTrue(multimap().putAll(k0(), Lists.newArrayList(v3(), v4())));
assertGet(k0(), v0(), v3(), v4());
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnAbsentKey() {
Reported by PMD.
Line: 68
assertGet(k0(), v0(), v3(), v4());
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnAbsentKey() {
assertTrue(
multimap()
.putAll(
k3(),
Reported by PMD.
Line: 69
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllNonEmptyIterableOnAbsentKey() {
assertTrue(
multimap()
.putAll(
k3(),
new Iterable<V>() {
Reported by PMD.
Line: 77
new Iterable<V>() {
@Override
public Iterator<V> iterator() {
return Lists.newArrayList(v3(), v4()).iterator();
}
}));
assertGet(k3(), v3(), v4());
}
Reported by PMD.
android/guava/src/com/google/common/cache/Striped64.java
66 issues
Line: 120
Class<?> ak = Cell.class;
valueOffset = UNSAFE.objectFieldOffset(ak.getDeclaredField("value"));
} catch (Exception e) {
throw new Error(e);
}
}
}
/**
Reported by PMD.
Line: 280
baseOffset = UNSAFE.objectFieldOffset(sk.getDeclaredField("base"));
busyOffset = UNSAFE.objectFieldOffset(sk.getDeclaredField("busy"));
} catch (Exception e) {
throw new Error(e);
}
}
/**
* Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package. Replace with a simple call
Reported by PMD.
Line: 310
}
});
} catch (java.security.PrivilegedActionException e) {
throw new RuntimeException("Could not initialize intrinsics", e.getCause());
}
}
}
Reported by PMD.
Line: 182
* @param hc the hash code holder
* @param wasUncontended false if CAS failed before call
*/
final void retryUpdate(long x, @CheckForNull int[] hc, boolean wasUncontended) {
int h;
if (hc == null) {
threadHashCode.set(hc = new int[1]); // Initialize randomly
int r = rng.nextInt(); // Avoid zero to allow xorShift rehash
h = hc[0] = (r == 0) ? 1 : r;
Reported by PMD.
Line: 182
* @param hc the hash code holder
* @param wasUncontended false if CAS failed before call
*/
final void retryUpdate(long x, @CheckForNull int[] hc, boolean wasUncontended) {
int h;
if (hc == null) {
threadHashCode.set(hc = new int[1]); // Initialize randomly
int r = rng.nextInt(); // Avoid zero to allow xorShift rehash
h = hc[0] = (r == 0) ? 1 : r;
Reported by PMD.
Line: 26
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class Striped64 extends Number {
/*
* This class maintains a lazily-initialized table of atomically
* updated variables, plus an extra "base" field. The table size
* is a power of two. Indexing uses masked per-thread hash codes.
* Nearly all declarations in this class are package-private,
Reported by PMD.
Line: 26
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class Striped64 extends Number {
/*
* This class maintains a lazily-initialized table of atomically
* updated variables, plus an extra "base" field. The table size
* is a power of two. Indexing uses masked per-thread hash codes.
* Nearly all declarations in this class are package-private,
Reported by PMD.
Line: 26
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class Striped64 extends Number {
/*
* This class maintains a lazily-initialized table of atomically
* updated variables, plus an extra "base" field. The table size
* is a power of two. Indexing uses masked per-thread hash codes.
* Nearly all declarations in this class are package-private,
Reported by PMD.
Line: 99
*/
static final class Cell {
volatile long p0, p1, p2, p3, p4, p5, p6;
volatile long value;
volatile long q0, q1, q2, q3, q4, q5, q6;
Cell(long x) {
value = x;
}
Reported by PMD.
Line: 119
UNSAFE = getUnsafe();
Class<?> ak = Cell.class;
valueOffset = UNSAFE.objectFieldOffset(ak.getDeclaredField("value"));
} catch (Exception e) {
throw new Error(e);
}
}
}
Reported by PMD.
guava/src/com/google/common/collect/ImmutableSortedMap.java
66 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.Maps.keyOrNull;
Reported by PMD.
Line: 65
*/
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxverideShim<K, V>
implements NavigableMap<K, V> {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableSortedMap} whose
* keys and values are the result of applying the provided mapping functions to the input
* elements. The generated map is sorted by the specified comparator.
Reported by PMD.
Line: 65
*/
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxverideShim<K, V>
implements NavigableMap<K, V> {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableSortedMap} whose
* keys and values are the result of applying the provided mapping functions to the input
* elements. The generated map is sorted by the specified comparator.
Reported by PMD.
Line: 66
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxverideShim<K, V>
implements NavigableMap<K, V> {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableSortedMap} whose
* keys and values are the result of applying the provided mapping functions to the input
* elements. The generated map is sorted by the specified comparator.
*
Reported by PMD.
Line: 119
ImmutableSortedSet.emptySet(Ordering.natural()), ImmutableList.<Object>of());
static <K, V> ImmutableSortedMap<K, V> emptyMap(Comparator<? super K> comparator) {
if (Ordering.natural().equals(comparator)) {
return of();
} else {
return new ImmutableSortedMap<>(
ImmutableSortedSet.emptySet(comparator), ImmutableList.<V>of());
}
Reported by PMD.
Line: 132
*
* <p><b>Performance note:</b> the instance returned is a singleton.
*/
@SuppressWarnings("unchecked")
// unsafe, comparator() returns a comparator on the specified type
// TODO(kevinb): evaluate whether or not of().comparator() should return null
public static <K, V> ImmutableSortedMap<K, V> of() {
return (ImmutableSortedMap<K, V>) NATURAL_EMPTY_MAP;
}
Reported by PMD.
Line: 194
* @throws IllegalArgumentException if any two keys are equal according to their natural ordering
*/
@SuppressWarnings("unchecked")
public static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
return ofEntries(
entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4), entryOf(k5, v5));
}
Reported by PMD.
Line: 303
// Collections.unmodifiableSortedMap requires the same key type.
@SuppressWarnings("unchecked")
ImmutableSortedMap<K, V> kvMap = (ImmutableSortedMap<K, V>) map;
if (!kvMap.isPartialView()) {
return kvMap;
}
}
return fromEntries(comparator, true, map.entrySet());
}
Reported by PMD.
Line: 315
boolean sameComparator = false;
if (map instanceof SortedMap) {
SortedMap<?, ?> sortedMap = (SortedMap<?, ?>) map;
Comparator<?> comparator2 = sortedMap.comparator();
sameComparator =
(comparator2 == null) ? comparator == NATURAL_ORDER : comparator.equals(comparator2);
}
if (sameComparator && (map instanceof ImmutableSortedMap)) {
Reported by PMD.
Line: 317
SortedMap<?, ?> sortedMap = (SortedMap<?, ?>) map;
Comparator<?> comparator2 = sortedMap.comparator();
sameComparator =
(comparator2 == null) ? comparator == NATURAL_ORDER : comparator.equals(comparator2);
}
if (sameComparator && (map instanceof ImmutableSortedMap)) {
// TODO(kevinb): Prove that this cast is safe, even though
// Collections.unmodifiableSortedMap requires the same key type.
Reported by PMD.