The following issues were found
guava/src/com/google/common/reflect/ClassPath.java
50 issues
Line: 467
return;
}
} catch (SecurityException e) {
logger.warning("Cannot access " + file + ": " + e);
// TODO(emcmanus): consider whether to log other failure cases too.
return;
}
if (file.isDirectory()) {
scanDirectory(file, builder);
Reported by PMD.
Line: 542
throws IOException {
File[] files = directory.listFiles();
if (files == null) {
logger.warning("Cannot read directory " + directory);
// IO error, just skip the directory
return;
}
for (File f : files) {
String name = f.getName();
Reported by PMD.
Line: 606
url = getClassPathEntry(jarFile, path);
} catch (MalformedURLException e) {
// Ignore bad entry
logger.warning("Invalid Class-Path entry: " + path);
continue;
}
if (url.getProtocol().equals("file")) {
builder.add(toFile(url));
}
Reported by PMD.
Line: 661
urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
}
} catch (MalformedURLException e) {
logger.log(WARNING, "malformed classpath entry: " + entry, e);
}
}
return urls.build();
}
Reported by PMD.
Line: 15
* the License.
*/
package com.google.common.reflect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH;
import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR;
Reported by PMD.
Line: 160
* @since 16.0
*/
public ImmutableSet<ClassInfo> getAllClasses() {
return FluentIterable.from(resources).filter(ClassInfo.class).toSet();
}
/**
* Returns all top level classes loadable from the current class path. Note that "top-level-ness"
* is determined heuristically by class name (see {@link ClassInfo#isTopLevel}).
Reported by PMD.
Line: 160
* @since 16.0
*/
public ImmutableSet<ClassInfo> getAllClasses() {
return FluentIterable.from(resources).filter(ClassInfo.class).toSet();
}
/**
* Returns all top level classes loadable from the current class path. Note that "top-level-ness"
* is determined heuristically by class name (see {@link ClassInfo#isTopLevel}).
Reported by PMD.
Line: 185
checkNotNull(packageName);
ImmutableSet.Builder<ClassInfo> builder = ImmutableSet.builder();
for (ClassInfo classInfo : getTopLevelClasses()) {
if (classInfo.getPackageName().equals(packageName)) {
builder.add(classInfo);
}
}
return builder.build();
}
Reported by PMD.
Line: 201
String packagePrefix = packageName + '.';
ImmutableSet.Builder<ClassInfo> builder = ImmutableSet.builder();
for (ClassInfo classInfo : getTopLevelClasses()) {
if (classInfo.getName().startsWith(packagePrefix)) {
builder.add(classInfo);
}
}
return builder.build();
}
Reported by PMD.
Line: 219
private final File file;
private final String resourceName;
final ClassLoader loader;
static ResourceInfo of(File file, String resourceName, ClassLoader loader) {
if (resourceName.endsWith(CLASS_FILE_NAME_EXTENSION)) {
return new ClassInfo(file, resourceName, loader);
} else {
Reported by PMD.
android/guava/src/com/google/common/reflect/TypeResolver.java
50 issues
Line: 56
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class TypeResolver {
private final TypeTable typeTable;
public TypeResolver() {
this.typeTable = new TypeTable();
Reported by PMD.
Line: 56
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class TypeResolver {
private final TypeTable typeTable;
public TypeResolver() {
this.typeTable = new TypeTable();
Reported by PMD.
Line: 56
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class TypeResolver {
private final TypeTable typeTable;
public TypeResolver() {
this.typeTable = new TypeTable();
Reported by PMD.
Line: 58
@ElementTypesAreNonnullByDefault
public final class TypeResolver {
private final TypeTable typeTable;
public TypeResolver() {
this.typeTable = new TypeTable();
}
Reported by PMD.
Line: 91
* <capture-of-? extends Object>}, effectively preventing {@code set} from accepting any type.
*/
static TypeResolver invariantly(Type contextType) {
Type invariantContext = WildcardCapturer.INSTANCE.capture(contextType);
return new TypeResolver().where(TypeMappingIntrospector.getTypeMappings(invariantContext));
}
/**
* Returns a new {@code TypeResolver} with type variables in {@code formal} mapping to types in
Reported by PMD.
Line: 125
return new TypeResolver(typeTable.where(mappings));
}
private static void populateTypeMappings(
final Map<TypeVariableKey, Type> mappings, final Type from, final Type to) {
if (from.equals(to)) {
return;
}
new TypeVisitor() {
Reported by PMD.
Line: 125
return new TypeResolver(typeTable.where(mappings));
}
private static void populateTypeMappings(
final Map<TypeVariableKey, Type> mappings, final Type from, final Type to) {
if (from.equals(to)) {
return;
}
new TypeVisitor() {
Reported by PMD.
Line: 125
return new TypeResolver(typeTable.where(mappings));
}
private static void populateTypeMappings(
final Map<TypeVariableKey, Type> mappings, final Type from, final Type to) {
if (from.equals(to)) {
return;
}
new TypeVisitor() {
Reported by PMD.
Line: 143
}
WildcardType toWildcardType = (WildcardType) to;
Type[] fromUpperBounds = fromWildcardType.getUpperBounds();
Type[] toUpperBounds = toWildcardType.getUpperBounds();
Type[] fromLowerBounds = fromWildcardType.getLowerBounds();
Type[] toLowerBounds = toWildcardType.getLowerBounds();
checkArgument(
fromUpperBounds.length == toUpperBounds.length
&& fromLowerBounds.length == toLowerBounds.length,
Reported by PMD.
Line: 145
Type[] fromUpperBounds = fromWildcardType.getUpperBounds();
Type[] toUpperBounds = toWildcardType.getUpperBounds();
Type[] fromLowerBounds = fromWildcardType.getLowerBounds();
Type[] toLowerBounds = toWildcardType.getLowerBounds();
checkArgument(
fromUpperBounds.length == toUpperBounds.length
&& fromLowerBounds.length == toLowerBounds.length,
"Incompatible type: %s vs. %s",
fromWildcardType,
Reported by PMD.
android/guava/src/com/google/common/reflect/ClassPath.java
50 issues
Line: 467
return;
}
} catch (SecurityException e) {
logger.warning("Cannot access " + file + ": " + e);
// TODO(emcmanus): consider whether to log other failure cases too.
return;
}
if (file.isDirectory()) {
scanDirectory(file, builder);
Reported by PMD.
Line: 542
throws IOException {
File[] files = directory.listFiles();
if (files == null) {
logger.warning("Cannot read directory " + directory);
// IO error, just skip the directory
return;
}
for (File f : files) {
String name = f.getName();
Reported by PMD.
Line: 606
url = getClassPathEntry(jarFile, path);
} catch (MalformedURLException e) {
// Ignore bad entry
logger.warning("Invalid Class-Path entry: " + path);
continue;
}
if (url.getProtocol().equals("file")) {
builder.add(toFile(url));
}
Reported by PMD.
Line: 661
urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
}
} catch (MalformedURLException e) {
logger.log(WARNING, "malformed classpath entry: " + entry, e);
}
}
return urls.build();
}
Reported by PMD.
Line: 15
* the License.
*/
package com.google.common.reflect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH;
import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR;
Reported by PMD.
Line: 160
* @since 16.0
*/
public ImmutableSet<ClassInfo> getAllClasses() {
return FluentIterable.from(resources).filter(ClassInfo.class).toSet();
}
/**
* Returns all top level classes loadable from the current class path. Note that "top-level-ness"
* is determined heuristically by class name (see {@link ClassInfo#isTopLevel}).
Reported by PMD.
Line: 160
* @since 16.0
*/
public ImmutableSet<ClassInfo> getAllClasses() {
return FluentIterable.from(resources).filter(ClassInfo.class).toSet();
}
/**
* Returns all top level classes loadable from the current class path. Note that "top-level-ness"
* is determined heuristically by class name (see {@link ClassInfo#isTopLevel}).
Reported by PMD.
Line: 185
checkNotNull(packageName);
ImmutableSet.Builder<ClassInfo> builder = ImmutableSet.builder();
for (ClassInfo classInfo : getTopLevelClasses()) {
if (classInfo.getPackageName().equals(packageName)) {
builder.add(classInfo);
}
}
return builder.build();
}
Reported by PMD.
Line: 201
String packagePrefix = packageName + '.';
ImmutableSet.Builder<ClassInfo> builder = ImmutableSet.builder();
for (ClassInfo classInfo : getTopLevelClasses()) {
if (classInfo.getName().startsWith(packagePrefix)) {
builder.add(classInfo);
}
}
return builder.build();
}
Reported by PMD.
Line: 219
private final File file;
private final String resourceName;
final ClassLoader loader;
static ResourceInfo of(File file, String resourceName, ClassLoader loader) {
if (resourceName.endsWith(CLASS_FILE_NAME_EXTENSION)) {
return new ClassInfo(file, resourceName, loader);
} else {
Reported by PMD.
guava/src/com/google/common/reflect/TypeResolver.java
50 issues
Line: 56
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class TypeResolver {
private final TypeTable typeTable;
public TypeResolver() {
this.typeTable = new TypeTable();
Reported by PMD.
Line: 56
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class TypeResolver {
private final TypeTable typeTable;
public TypeResolver() {
this.typeTable = new TypeTable();
Reported by PMD.
Line: 56
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class TypeResolver {
private final TypeTable typeTable;
public TypeResolver() {
this.typeTable = new TypeTable();
Reported by PMD.
Line: 58
@ElementTypesAreNonnullByDefault
public final class TypeResolver {
private final TypeTable typeTable;
public TypeResolver() {
this.typeTable = new TypeTable();
}
Reported by PMD.
Line: 91
* <capture-of-? extends Object>}, effectively preventing {@code set} from accepting any type.
*/
static TypeResolver invariantly(Type contextType) {
Type invariantContext = WildcardCapturer.INSTANCE.capture(contextType);
return new TypeResolver().where(TypeMappingIntrospector.getTypeMappings(invariantContext));
}
/**
* Returns a new {@code TypeResolver} with type variables in {@code formal} mapping to types in
Reported by PMD.
Line: 125
return new TypeResolver(typeTable.where(mappings));
}
private static void populateTypeMappings(
final Map<TypeVariableKey, Type> mappings, final Type from, final Type to) {
if (from.equals(to)) {
return;
}
new TypeVisitor() {
Reported by PMD.
Line: 125
return new TypeResolver(typeTable.where(mappings));
}
private static void populateTypeMappings(
final Map<TypeVariableKey, Type> mappings, final Type from, final Type to) {
if (from.equals(to)) {
return;
}
new TypeVisitor() {
Reported by PMD.
Line: 125
return new TypeResolver(typeTable.where(mappings));
}
private static void populateTypeMappings(
final Map<TypeVariableKey, Type> mappings, final Type from, final Type to) {
if (from.equals(to)) {
return;
}
new TypeVisitor() {
Reported by PMD.
Line: 143
}
WildcardType toWildcardType = (WildcardType) to;
Type[] fromUpperBounds = fromWildcardType.getUpperBounds();
Type[] toUpperBounds = toWildcardType.getUpperBounds();
Type[] fromLowerBounds = fromWildcardType.getLowerBounds();
Type[] toLowerBounds = toWildcardType.getLowerBounds();
checkArgument(
fromUpperBounds.length == toUpperBounds.length
&& fromLowerBounds.length == toLowerBounds.length,
Reported by PMD.
Line: 145
Type[] fromUpperBounds = fromWildcardType.getUpperBounds();
Type[] toUpperBounds = toWildcardType.getUpperBounds();
Type[] fromLowerBounds = fromWildcardType.getLowerBounds();
Type[] toLowerBounds = toWildcardType.getLowerBounds();
checkArgument(
fromUpperBounds.length == toUpperBounds.length
&& fromLowerBounds.length == toLowerBounds.length,
"Incompatible type: %s vs. %s",
fromWildcardType,
Reported by PMD.
guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
50 issues
Line: 39
@GwtCompatible(emulated = true)
public class ImmutableMultimapTest extends TestCase {
public void testBuilder_withImmutableEntry() {
ImmutableMultimap<String, Integer> multimap =
new Builder<String, Integer>().put(Maps.immutableEntry("one", 1)).build();
assertEquals(Arrays.asList(1), multimap.get("one"));
}
Reported by PMD.
Line: 41
public void testBuilder_withImmutableEntry() {
ImmutableMultimap<String, Integer> multimap =
new Builder<String, Integer>().put(Maps.immutableEntry("one", 1)).build();
assertEquals(Arrays.asList(1), multimap.get("one"));
}
public void testBuilder_withImmutableEntryAndNullContents() {
Builder<String, Integer> builder = new Builder<>();
Reported by PMD.
Line: 42
public void testBuilder_withImmutableEntry() {
ImmutableMultimap<String, Integer> multimap =
new Builder<String, Integer>().put(Maps.immutableEntry("one", 1)).build();
assertEquals(Arrays.asList(1), multimap.get("one"));
}
public void testBuilder_withImmutableEntryAndNullContents() {
Builder<String, Integer> builder = new Builder<>();
try {
Reported by PMD.
Line: 45
assertEquals(Arrays.asList(1), multimap.get("one"));
}
public void testBuilder_withImmutableEntryAndNullContents() {
Builder<String, Integer> builder = new Builder<>();
try {
builder.put(Maps.immutableEntry("one", (Integer) null));
fail();
} catch (NullPointerException expected) {
Reported by PMD.
Line: 49
Builder<String, Integer> builder = new Builder<>();
try {
builder.put(Maps.immutableEntry("one", (Integer) null));
fail();
} catch (NullPointerException expected) {
}
try {
builder.put(Maps.immutableEntry((String) null, 1));
fail();
Reported by PMD.
Line: 49
Builder<String, Integer> builder = new Builder<>();
try {
builder.put(Maps.immutableEntry("one", (Integer) null));
fail();
} catch (NullPointerException expected) {
}
try {
builder.put(Maps.immutableEntry((String) null, 1));
fail();
Reported by PMD.
Line: 50
try {
builder.put(Maps.immutableEntry("one", (Integer) null));
fail();
} catch (NullPointerException expected) {
}
try {
builder.put(Maps.immutableEntry((String) null, 1));
fail();
} catch (NullPointerException expected) {
Reported by PMD.
Line: 50
try {
builder.put(Maps.immutableEntry("one", (Integer) null));
fail();
} catch (NullPointerException expected) {
}
try {
builder.put(Maps.immutableEntry((String) null, 1));
fail();
} catch (NullPointerException expected) {
Reported by PMD.
Line: 54
}
try {
builder.put(Maps.immutableEntry((String) null, 1));
fail();
} catch (NullPointerException expected) {
}
}
private static class StringHolder {
Reported by PMD.
Line: 54
}
try {
builder.put(Maps.immutableEntry((String) null, 1));
fail();
} catch (NullPointerException expected) {
}
}
private static class StringHolder {
Reported by PMD.
android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
49 issues
Line: 52
* @author Nick Kralevich
*/
@GwtCompatible(emulated = true)
public class ImmutableSetTest extends AbstractImmutableSetTest {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
Reported by PMD.
Line: 54
@GwtCompatible(emulated = true)
public class ImmutableSetTest extends AbstractImmutableSetTest {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(new ImmutableSetCopyOfGenerator())
Reported by PMD.
Line: 198
return ImmutableSet.copyOf(elements);
}
public void testCreation_allDuplicates() {
ImmutableSet<String> set = ImmutableSet.copyOf(Lists.newArrayList("a", "a"));
assertTrue(set instanceof SingletonImmutableSet);
assertEquals(Lists.newArrayList("a"), Lists.newArrayList(set));
}
Reported by PMD.
Line: 198
return ImmutableSet.copyOf(elements);
}
public void testCreation_allDuplicates() {
ImmutableSet<String> set = ImmutableSet.copyOf(Lists.newArrayList("a", "a"));
assertTrue(set instanceof SingletonImmutableSet);
assertEquals(Lists.newArrayList("a"), Lists.newArrayList(set));
}
Reported by PMD.
Line: 204
assertEquals(Lists.newArrayList("a"), Lists.newArrayList(set));
}
public void testCreation_oneDuplicate() {
// now we'll get the varargs overload
ImmutableSet<String> set =
ImmutableSet.of("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "a");
assertEquals(
Lists.newArrayList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"),
Reported by PMD.
Line: 213
Lists.newArrayList(set));
}
public void testCreation_manyDuplicates() {
// now we'll get the varargs overload
ImmutableSet<String> set =
ImmutableSet.of("a", "b", "c", "c", "c", "c", "b", "b", "a", "a", "c", "c", "c", "a");
assertThat(set).containsExactly("a", "b", "c").inOrder();
}
Reported by PMD.
Line: 217
// now we'll get the varargs overload
ImmutableSet<String> set =
ImmutableSet.of("a", "b", "c", "c", "c", "c", "b", "b", "a", "a", "c", "c", "c", "a");
assertThat(set).containsExactly("a", "b", "c").inOrder();
}
@GwtIncompatible("Builder impl")
public void testBuilderForceCopy() {
ImmutableSet.Builder<Integer> builder = ImmutableSet.builder();
Reported by PMD.
Line: 217
// now we'll get the varargs overload
ImmutableSet<String> set =
ImmutableSet.of("a", "b", "c", "c", "c", "c", "b", "b", "a", "a", "c", "c", "c", "a");
assertThat(set).containsExactly("a", "b", "c").inOrder();
}
@GwtIncompatible("Builder impl")
public void testBuilderForceCopy() {
ImmutableSet.Builder<Integer> builder = ImmutableSet.builder();
Reported by PMD.
Line: 220
assertThat(set).containsExactly("a", "b", "c").inOrder();
}
@GwtIncompatible("Builder impl")
public void testBuilderForceCopy() {
ImmutableSet.Builder<Integer> builder = ImmutableSet.builder();
builder.add(-1);
Object[] prevArray = null;
for (int i = 0; i < 10; i++) {
Reported by PMD.
Line: 229
builder.add(i);
assertNotSame(builder.contents, prevArray);
prevArray = builder.contents;
ImmutableSet<Integer> unused = builder.build();
}
}
@GwtIncompatible("Builder impl")
public void testPresizedBuilderDedups() {
Reported by PMD.
android/guava/src/com/google/common/collect/HashBiMap.java
49 issues
Line: 473
* Updates the specified entry to point to the new value: removes the old value from the V-to-K
* mapping and puts the new one in. The entry does not move in the insertion order of the bimap.
*/
private void replaceValueInEntry(int entry, @ParametricNullness V newValue, boolean force) {
checkArgument(entry != ABSENT);
int newValueHash = Hashing.smearedHash(newValue);
int newValueIndex = findEntryByValue(newValue, newValueHash);
if (newValueIndex != ABSENT) {
if (force) {
Reported by PMD.
Line: 498
* mapping and puts the new one in. The entry is moved to the end of the insertion order, or to
* the position of the new key if it was previously present.
*/
private void replaceKeyInEntry(int entry, @ParametricNullness K newKey, boolean force) {
checkArgument(entry != ABSENT);
int newKeyHash = Hashing.smearedHash(newKey);
int newKeyIndex = findEntryByKey(newKey, newKeyHash);
int newPredecessor = lastInInsertionOrder;
Reported by PMD.
Line: 15
* the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
import static com.google.common.collect.NullnessCasts.unsafeNull;
Reported by PMD.
Line: 57
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMap<K, V> implements BiMap<K, V>, Serializable {
/** Returns a new, empty {@code HashBiMap} with the default initial capacity (16). */
public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create() {
return create(16);
Reported by PMD.
Line: 57
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMap<K, V> implements BiMap<K, V>, Serializable {
/** Returns a new, empty {@code HashBiMap} with the default initial capacity (16). */
public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create() {
return create(16);
Reported by PMD.
Line: 57
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMap<K, V> implements BiMap<K, V>, Serializable {
/** Returns a new, empty {@code HashBiMap} with the default initial capacity (16). */
public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create() {
return create(16);
Reported by PMD.
Line: 57
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMap<K, V> implements BiMap<K, V>, Serializable {
/** Returns a new, empty {@code HashBiMap} with the default initial capacity (16). */
public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create() {
return create(16);
Reported by PMD.
Line: 58
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMap<K, V> implements BiMap<K, V>, Serializable {
/** Returns a new, empty {@code HashBiMap} with the default initial capacity (16). */
public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create() {
return create(16);
}
Reported by PMD.
Line: 83
public static <K extends @Nullable Object, V extends @Nullable Object> HashBiMap<K, V> create(
Map<? extends K, ? extends V> map) {
HashBiMap<K, V> bimap = create(map.size());
bimap.putAll(map);
return bimap;
}
private static final int ABSENT = -1;
private static final int ENDPOINT = -2;
Reported by PMD.
Line: 93
/** Maps an "entry" to the key of that entry. */
transient @Nullable K[] keys;
/** Maps an "entry" to the value of that entry. */
transient @Nullable V[] values;
transient int size;
transient int modCount;
/** Maps a bucket to the "entry" of its first element. */
private transient int[] hashTableKToV;
Reported by PMD.
guava/src/com/google/common/collect/LinkedHashMultimap.java
48 issues
Line: 89
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public final class LinkedHashMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends LinkedHashMultimapGwtSerializationDependencies<K, V> {
/** Creates a new, empty {@code LinkedHashMultimap} with the default initial capacities. */
public static <K extends @Nullable Object, V extends @Nullable Object>
LinkedHashMultimap<K, V> create() {
return new LinkedHashMultimap<>(DEFAULT_KEY_CAPACITY, DEFAULT_VALUE_SET_CAPACITY);
Reported by PMD.
Line: 122
*/
public static <K extends @Nullable Object, V extends @Nullable Object>
LinkedHashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
LinkedHashMultimap<K, V> result = create(multimap.keySet().size(), DEFAULT_VALUE_SET_CAPACITY);
result.putAll(multimap);
return result;
}
private interface ValueSetLink<K extends @Nullable Object, V extends @Nullable Object> {
Reported by PMD.
Line: 123
public static <K extends @Nullable Object, V extends @Nullable Object>
LinkedHashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
LinkedHashMultimap<K, V> result = create(multimap.keySet().size(), DEFAULT_VALUE_SET_CAPACITY);
result.putAll(multimap);
return result;
}
private interface ValueSetLink<K extends @Nullable Object, V extends @Nullable Object> {
ValueSetLink<K, V> getPredecessorInValueSet();
Reported by PMD.
Line: 166
* whole.
*/
@VisibleForTesting
static final class ValueEntry<K extends @Nullable Object, V extends @Nullable Object>
extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
final int smearedValueHash;
@CheckForNull ValueEntry<K, V> nextInValueBucket;
/*
Reported by PMD.
Line: 166
* whole.
*/
@VisibleForTesting
static final class ValueEntry<K extends @Nullable Object, V extends @Nullable Object>
extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
final int smearedValueHash;
@CheckForNull ValueEntry<K, V> nextInValueBucket;
/*
Reported by PMD.
Line: 168
@VisibleForTesting
static final class ValueEntry<K extends @Nullable Object, V extends @Nullable Object>
extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
final int smearedValueHash;
@CheckForNull ValueEntry<K, V> nextInValueBucket;
/*
* The *InValueSet and *InMultimap fields below are null after construction, but we almost
* always call succeedsIn*() to initialize them immediately thereafter.
Reported by PMD.
Line: 170
extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
final int smearedValueHash;
@CheckForNull ValueEntry<K, V> nextInValueBucket;
/*
* The *InValueSet and *InMultimap fields below are null after construction, but we almost
* always call succeedsIn*() to initialize them immediately thereafter.
*
* The exception is the *InValueSet fields of multimapHeaderEntry, which are never set. (That
Reported by PMD.
Line: 262
private static final int DEFAULT_VALUE_SET_CAPACITY = 2;
@VisibleForTesting static final double VALUE_SET_LOAD_FACTOR = 1.0;
@VisibleForTesting transient int valueSetCapacity = DEFAULT_VALUE_SET_CAPACITY;
private transient ValueEntry<K, V> multimapHeaderEntry;
private LinkedHashMultimap(int keyCapacity, int valueSetCapacity) {
super(Platform.<K, Collection<V>>newLinkedHashMapWithExpectedSize(keyCapacity));
checkNonnegative(valueSetCapacity, "expectedValuesPerKey");
Reported by PMD.
Line: 325
* time the entry is returned by a method call to the collection or its iterator.
*/
@Override
public Set<Entry<K, V>> entries() {
return super.entries();
}
/**
* Returns a view collection of all <i>distinct</i> keys contained in this multimap. Note that the
Reported by PMD.
Line: 340
* <i>adding</i> to the returned set is not possible.
*/
@Override
public Set<K> keySet() {
return super.keySet();
}
/**
* Returns a collection of all values in the multimap. Changes to the returned collection will
Reported by PMD.
android/guava/src/com/google/common/math/IntMath.java
48 issues
Line: 107
static int lessThanBranchFree(int x, int y) {
// The double negation is optimized away by normal Java, but is necessary for GWT
// to make sure bit twiddling works as expected.
return ~~(x - y) >>> (Integer.SIZE - 1);
}
/**
* Returns the base-2 logarithm of {@code x}, rounded according to the specified rounding mode.
*
Reported by PMD.
Line: 228
* @throws IllegalArgumentException if {@code k < 0}
*/
@GwtIncompatible // failing tests
public static int pow(int b, int k) {
checkNonNegative("exponent", k);
switch (b) {
case 0:
return (k == 0) ? 1 : 0;
case 1:
Reported by PMD.
Line: 228
* @throws IllegalArgumentException if {@code k < 0}
*/
@GwtIncompatible // failing tests
public static int pow(int b, int k) {
checkNonNegative("exponent", k);
switch (b) {
case 0:
return (k == 0) ? 1 : 0;
case 1:
Reported by PMD.
Line: 405
*
* @throws IllegalArgumentException if {@code a < 0} or {@code b < 0}
*/
public static int gcd(int a, int b) {
/*
* The reason we require both arguments to be >= 0 is because otherwise, what do you return on
* gcd(0, Integer.MIN_VALUE)? BigInteger.gcd would return positive 2^31, but positive 2^31 isn't
* an int.
*/
Reported by PMD.
Line: 405
*
* @throws IllegalArgumentException if {@code a < 0} or {@code b < 0}
*/
public static int gcd(int a, int b) {
/*
* The reason we require both arguments to be >= 0 is because otherwise, what do you return on
* gcd(0, Integer.MIN_VALUE)? BigInteger.gcd would return positive 2^31, but positive 2^31 isn't
* an int.
*/
Reported by PMD.
Line: 405
*
* @throws IllegalArgumentException if {@code a < 0} or {@code b < 0}
*/
public static int gcd(int a, int b) {
/*
* The reason we require both arguments to be >= 0 is because otherwise, what do you return on
* gcd(0, Integer.MIN_VALUE)? BigInteger.gcd would return positive 2^31, but positive 2^31 isn't
* an int.
*/
Reported by PMD.
Line: 405
*
* @throws IllegalArgumentException if {@code a < 0} or {@code b < 0}
*/
public static int gcd(int a, int b) {
/*
* The reason we require both arguments to be >= 0 is because otherwise, what do you return on
* gcd(0, Integer.MIN_VALUE)? BigInteger.gcd would return positive 2^31, but positive 2^31 isn't
* an int.
*/
Reported by PMD.
Line: 405
*
* @throws IllegalArgumentException if {@code a < 0} or {@code b < 0}
*/
public static int gcd(int a, int b) {
/*
* The reason we require both arguments to be >= 0 is because otherwise, what do you return on
* gcd(0, Integer.MIN_VALUE)? BigInteger.gcd would return positive 2^31, but positive 2^31 isn't
* an int.
*/
Reported by PMD.
Line: 491
* @throws ArithmeticException if {@code b} to the {@code k}th power overflows in signed {@code
* int} arithmetic
*/
public static int checkedPow(int b, int k) {
checkNonNegative("exponent", k);
switch (b) {
case 0:
return (k == 0) ? 1 : 0;
case 1:
Reported by PMD.
Line: 491
* @throws ArithmeticException if {@code b} to the {@code k}th power overflows in signed {@code
* int} arithmetic
*/
public static int checkedPow(int b, int k) {
checkNonNegative("exponent", k);
switch (b) {
case 0:
return (k == 0) ? 1 : 0;
case 1:
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java
48 issues
Line: 18
/** Unit test for {@link AtomicDouble}. */
public class AtomicDoubleTest extends JSR166TestCase {
private static final double[] VALUES = {
Double.NEGATIVE_INFINITY,
-Double.MAX_VALUE,
(double) Long.MIN_VALUE,
Reported by PMD.
Line: 43
/** The notion of equality used by AtomicDouble */
static boolean bitEquals(double x, double y) {
return Double.doubleToRawLongBits(x) == Double.doubleToRawLongBits(y);
}
static void assertBitEquals(double x, double y) {
assertEquals(Double.doubleToRawLongBits(x), Double.doubleToRawLongBits(y));
}
Reported by PMD.
Line: 51
}
/** constructor initializes to given value */
public void testConstructor() {
for (double x : VALUES) {
AtomicDouble a = new AtomicDouble(x);
assertBitEquals(x, a.get());
}
}
Reported by PMD.
Line: 53
/** constructor initializes to given value */
public void testConstructor() {
for (double x : VALUES) {
AtomicDouble a = new AtomicDouble(x);
assertBitEquals(x, a.get());
}
}
/** default constructed initializes to zero */
Reported by PMD.
Line: 59
}
/** default constructed initializes to zero */
public void testConstructor2() {
AtomicDouble a = new AtomicDouble();
assertBitEquals(0.0, a.get());
}
/** get returns the last value set */
Reported by PMD.
Line: 65
}
/** get returns the last value set */
public void testGetSet() {
AtomicDouble at = new AtomicDouble(1.0);
assertBitEquals(1.0, at.get());
for (double x : VALUES) {
at.set(x);
assertBitEquals(x, at.get());
Reported by PMD.
Line: 65
}
/** get returns the last value set */
public void testGetSet() {
AtomicDouble at = new AtomicDouble(1.0);
assertBitEquals(1.0, at.get());
for (double x : VALUES) {
at.set(x);
assertBitEquals(x, at.get());
Reported by PMD.
Line: 75
}
/** get returns the last value lazySet in same thread */
public void testGetLazySet() {
AtomicDouble at = new AtomicDouble(1.0);
assertBitEquals(1.0, at.get());
for (double x : VALUES) {
at.lazySet(x);
assertBitEquals(x, at.get());
Reported by PMD.
Line: 75
}
/** get returns the last value lazySet in same thread */
public void testGetLazySet() {
AtomicDouble at = new AtomicDouble(1.0);
assertBitEquals(1.0, at.get());
for (double x : VALUES) {
at.lazySet(x);
assertBitEquals(x, at.get());
Reported by PMD.
Line: 85
}
/** compareAndSet succeeds in changing value if equal to expected else fails */
public void testCompareAndSet() {
double prev = Math.E;
double unused = Math.E + Math.PI;
AtomicDouble at = new AtomicDouble(prev);
for (double x : VALUES) {
assertBitEquals(prev, at.get());
Reported by PMD.