The following issues were found

guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
21 issues
This class has too many methods, consider refactoring it.
Design

Line: 38

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractExecutionThreadService implements Service {
  private static final Logger logger =
      Logger.getLogger(AbstractExecutionThreadService.class.getName());

  /* use AbstractService for state management */
  private final Service delegate =

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 43

                    Logger.getLogger(AbstractExecutionThreadService.class.getName());

  /* use AbstractService for state management */
  private final Service delegate =
      new AbstractService() {
        @Override
        protected final void doStart() {
          Executor executor =
              MoreExecutors.renamingDecorator(

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 67

                                  // which case we should skip right down to shutdown.
                    if (isRunning()) {
                      try {
                        AbstractExecutionThreadService.this.run();
                      } catch (Throwable t) {
                        try {
                          shutDown();
                        } catch (Exception ignored) {
                          // TODO(lukes): if guava ever moves to java7, this would be a good

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 67

                                  // which case we should skip right down to shutdown.
                    if (isRunning()) {
                      try {
                        AbstractExecutionThreadService.this.run();
                      } catch (Throwable t) {
                        try {
                          shutDown();
                        } catch (Exception ignored) {
                          // TODO(lukes): if guava ever moves to java7, this would be a good

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 68

                                  if (isRunning()) {
                      try {
                        AbstractExecutionThreadService.this.run();
                      } catch (Throwable t) {
                        try {
                          shutDown();
                        } catch (Exception ignored) {
                          // TODO(lukes): if guava ever moves to java7, this would be a good
                          // candidate for a suppressed exception, or maybe we could generalize

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 71

                                    } catch (Throwable t) {
                        try {
                          shutDown();
                        } catch (Exception ignored) {
                          // TODO(lukes): if guava ever moves to java7, this would be a good
                          // candidate for a suppressed exception, or maybe we could generalize
                          // Closer.Suppressor
                          logger.log(
                              Level.WARNING,

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 87

              
                    shutDown();
                    notifyStopped();
                  } catch (Throwable t) {
                    notifyFailed(t);
                  }
                }
              });
        }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 101

              
        @Override
        public String toString() {
          return AbstractExecutionThreadService.this.toString();
        }
      };

  /** Constructor for use by subclasses. */
  protected AbstractExecutionThreadService() {}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 101

              
        @Override
        public String toString() {
          return AbstractExecutionThreadService.this.toString();
        }
      };

  /** Constructor for use by subclasses. */
  protected AbstractExecutionThreadService() {}

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 113

                 *
   * <p>By default this method does nothing.
   */
  protected void startUp() throws Exception {}

  /**
   * Run the service. This method is invoked on the execution thread. Implementations must respond
   * to stop requests. You could poll for lifecycle changes in a work loop:
   *

            

Reported by PMD.

guava-tests/test/com/google/common/reflect/ReflectionTest.java
20 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 28

              /** Tests for {@link Reflection} */
public class ReflectionTest extends TestCase {

  public void testGetPackageName() throws Exception {
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class));
    assertEquals("java", Reflection.getPackageName("java.MyType"));
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class.getName()));
    assertEquals("", Reflection.getPackageName("NoPackage"));
    assertEquals("java.util", Reflection.getPackageName(Map.Entry.class));

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 28

              /** Tests for {@link Reflection} */
public class ReflectionTest extends TestCase {

  public void testGetPackageName() throws Exception {
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class));
    assertEquals("java", Reflection.getPackageName("java.MyType"));
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class.getName()));
    assertEquals("", Reflection.getPackageName("NoPackage"));
    assertEquals("java.util", Reflection.getPackageName(Map.Entry.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

              public class ReflectionTest extends TestCase {

  public void testGetPackageName() throws Exception {
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class));
    assertEquals("java", Reflection.getPackageName("java.MyType"));
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class.getName()));
    assertEquals("", Reflection.getPackageName("NoPackage"));
    assertEquals("java.util", Reflection.getPackageName(Map.Entry.class));
  }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

              
  public void testGetPackageName() throws Exception {
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class));
    assertEquals("java", Reflection.getPackageName("java.MyType"));
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class.getName()));
    assertEquals("", Reflection.getPackageName("NoPackage"));
    assertEquals("java.util", Reflection.getPackageName(Map.Entry.class));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                public void testGetPackageName() throws Exception {
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class));
    assertEquals("java", Reflection.getPackageName("java.MyType"));
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class.getName()));
    assertEquals("", Reflection.getPackageName("NoPackage"));
    assertEquals("java.util", Reflection.getPackageName(Map.Entry.class));
  }

  public void testNewProxy() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 32

                  assertEquals("java.lang", Reflection.getPackageName(Iterable.class));
    assertEquals("java", Reflection.getPackageName("java.MyType"));
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class.getName()));
    assertEquals("", Reflection.getPackageName("NoPackage"));
    assertEquals("java.util", Reflection.getPackageName(Map.Entry.class));
  }

  public void testNewProxy() throws Exception {
    Runnable runnable = Reflection.newProxy(Runnable.class, X_RETURNER);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                  assertEquals("java", Reflection.getPackageName("java.MyType"));
    assertEquals("java.lang", Reflection.getPackageName(Iterable.class.getName()));
    assertEquals("", Reflection.getPackageName("NoPackage"));
    assertEquals("java.util", Reflection.getPackageName(Map.Entry.class));
  }

  public void testNewProxy() throws Exception {
    Runnable runnable = Reflection.newProxy(Runnable.class, X_RETURNER);
    assertEquals("x", runnable.toString());

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 36

                  assertEquals("java.util", Reflection.getPackageName(Map.Entry.class));
  }

  public void testNewProxy() throws Exception {
    Runnable runnable = Reflection.newProxy(Runnable.class, X_RETURNER);
    assertEquals("x", runnable.toString());
  }

  public void testNewProxyCantWorkOnAClass() throws Exception {

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 38

              
  public void testNewProxy() throws Exception {
    Runnable runnable = Reflection.newProxy(Runnable.class, X_RETURNER);
    assertEquals("x", runnable.toString());
  }

  public void testNewProxyCantWorkOnAClass() throws Exception {
    try {
      Reflection.newProxy(Object.class, X_RETURNER);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 38

              
  public void testNewProxy() throws Exception {
    Runnable runnable = Reflection.newProxy(Runnable.class, X_RETURNER);
    assertEquals("x", runnable.toString());
  }

  public void testNewProxyCantWorkOnAClass() throws Exception {
    try {
      Reflection.newProxy(Object.class, X_RETURNER);

            

Reported by PMD.

guava/src/com/google/common/primitives/Doubles.java
20 issues
Avoid using a branching statement as the last in a loop.
Error

Line: 177

                        continue outer;
        }
      }
      return i;
    }
    return -1;
  }

  /**

            

Reported by PMD.

Possible God Class (WMC=51, ATFD=27, TCC=0.000%)
Design

Line: 53

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Doubles extends DoublesMethodsForWeb {
  private Doubles() {}

  /**
   * The number of bytes required to represent a primitive {@code double} value.
   *

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 53

               */
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Doubles extends DoublesMethodsForWeb {
  private Doubles() {}

  /**
   * The number of bytes required to represent a primitive {@code double} value.
   *

            

Reported by PMD.

Too many control variables in the for statement
Design

Line: 465

                public static void reverse(double[] array, int fromIndex, int toIndex) {
    checkNotNull(array);
    checkPositionIndexes(fromIndex, toIndex, array.length);
    for (int i = fromIndex, j = toIndex - 1; i < j; i++, j--) {
      double tmp = array[i];
      array[i] = array[j];
      array[j] = tmp;
    }
  }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 528

                @GwtCompatible
  private static class DoubleArrayAsList extends AbstractList<Double>
      implements RandomAccess, Serializable {
    final double[] array;
    final int start;
    final int end;

    DoubleArrayAsList(double[] array) {
      this(array, 0, array.length);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 529

                private static class DoubleArrayAsList extends AbstractList<Double>
      implements RandomAccess, Serializable {
    final double[] array;
    final int start;
    final int end;

    DoubleArrayAsList(double[] array) {
      this(array, 0, array.length);
    }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 530

                    implements RandomAccess, Serializable {
    final double[] array;
    final int start;
    final int end;

    DoubleArrayAsList(double[] array) {
      this(array, 0, array.length);
    }


            

Reported by PMD.

The user-supplied array 'array' is stored directly.
Design

Line: 536

                    this(array, 0, array.length);
    }

    DoubleArrayAsList(double[] array, int start, int end) {
      this.array = array;
      this.start = start;
      this.end = end;
    }


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 621

                    if (object instanceof DoubleArrayAsList) {
        DoubleArrayAsList that = (DoubleArrayAsList) object;
        int size = size();
        if (that.size() != size) {
          return false;
        }
        for (int i = 0; i < size; i++) {
          if (array[start + i] != that.array[that.start + i]) {
            return false;

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 685

                  String completeHex = "0[xX]" + hex + "[pP][+-]?\\d+#[fFdD]?";
    String fpPattern = "[+-]?(?:NaN|Infinity|" + completeDec + "|" + completeHex + ")";
    fpPattern =
        fpPattern.replace(
            "#",
            "+"
            );
    return
    java.util.regex.Pattern

            

Reported by PMD.

guava/src/com/google/common/util/concurrent/CombinedFuture.java
20 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 36

              @ElementTypesAreNonnullByDefault
final class CombinedFuture<V extends @Nullable Object>
    extends AggregateFuture<@Nullable Object, V> {
  @CheckForNull private CombinedFutureInterruptibleTask<?> task;

  CombinedFuture(
      ImmutableCollection<? extends ListenableFuture<?>> futures,
      boolean allMustSucceed,
      Executor listenerExecutor,

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 80

                   * or after the output future is done, whichever comes first.
     */
    if (reason == OUTPUT_FUTURE_DONE) {
      this.task = null;
    }
  }

  @Override
  protected void interruptTask() {

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 93

                }

  @WeakOuter
  private abstract class CombinedFutureInterruptibleTask<T extends @Nullable Object>
      extends InterruptibleTask<T> {
    private final Executor listenerExecutor;

    CombinedFutureInterruptibleTask(Executor listenerExecutor) {
      this.listenerExecutor = checkNotNull(listenerExecutor);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 95

                @WeakOuter
  private abstract class CombinedFutureInterruptibleTask<T extends @Nullable Object>
      extends InterruptibleTask<T> {
    private final Executor listenerExecutor;

    CombinedFutureInterruptibleTask(Executor listenerExecutor) {
      this.listenerExecutor = checkNotNull(listenerExecutor);
    }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 103

              
    @Override
    final boolean isDone() {
      return CombinedFuture.this.isDone();
    }

    final void execute() {
      try {
        listenerExecutor.execute(this);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 103

              
    @Override
    final boolean isDone() {
      return CombinedFuture.this.isDone();
    }

    final void execute() {
      try {
        listenerExecutor.execute(this);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 110

                    try {
        listenerExecutor.execute(this);
      } catch (RejectedExecutionException e) {
        CombinedFuture.this.setException(e);
      }
    }

    @Override
    final void afterRanInterruptiblySuccess(@ParametricNullness T result) {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 110

                    try {
        listenerExecutor.execute(this);
      } catch (RejectedExecutionException e) {
        CombinedFuture.this.setException(e);
      }
    }

    @Override
    final void afterRanInterruptiblySuccess(@ParametricNullness T result) {

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 127

                     * InterruptibleTask itself might also eliminate some of the existing boilerplate for, e.g.,
       * pendingToString().)
       */
      CombinedFuture.this.task = null;

      setValue(result);
    }

    @Override

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 135

                  @Override
    final void afterRanInterruptiblyFailure(Throwable error) {
      // See afterRanInterruptiblySuccess.
      CombinedFuture.this.task = null;

      if (error instanceof ExecutionException) {
        /*
         * Cast to ExecutionException to satisfy our nullness checker, which (unsoundly but
         * *usually* safely) assumes that getCause() returns non-null on an ExecutionException.

            

Reported by PMD.

guava/src/com/google/common/eventbus/SubscriberRegistry.java
20 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 15

               * the License.
 */

package com.google.common.eventbus;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 69

                    Maps.newConcurrentMap();

  /** The event bus this registry belongs to. */
  @Weak private final EventBus bus;

  SubscriberRegistry(EventBus bus) {
    this.bus = checkNotNull(bus);
  }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 79

                void register(Object listener) {
    Multimap<Class<?>, Subscriber> listenerMethods = findAllSubscribers(listener);

    for (Entry<Class<?>, Collection<Subscriber>> entry : listenerMethods.asMap().entrySet()) {
      Class<?> eventType = entry.getKey();
      Collection<Subscriber> eventMethodsInListener = entry.getValue();

      CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 86

                    CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);

      if (eventSubscribers == null) {
        CopyOnWriteArraySet<Subscriber> newSet = new CopyOnWriteArraySet<>();
        eventSubscribers =
            MoreObjects.firstNonNull(subscribers.putIfAbsent(eventType, newSet), newSet);
      }

      eventSubscribers.addAll(eventMethodsInListener);

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 91

                          MoreObjects.firstNonNull(subscribers.putIfAbsent(eventType, newSet), newSet);
      }

      eventSubscribers.addAll(eventMethodsInListener);
    }
  }

  /** Unregisters all subscribers on the given listener object. */
  void unregister(Object listener) {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 99

                void unregister(Object listener) {
    Multimap<Class<?>, Subscriber> listenerMethods = findAllSubscribers(listener);

    for (Entry<Class<?>, Collection<Subscriber>> entry : listenerMethods.asMap().entrySet()) {
      Class<?> eventType = entry.getKey();
      Collection<Subscriber> listenerMethodsForType = entry.getValue();

      CopyOnWriteArraySet<Subscriber> currentSubscribers = subscribers.get(eventType);
      if (currentSubscribers == null || !currentSubscribers.removeAll(listenerMethodsForType)) {

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 104

                    Collection<Subscriber> listenerMethodsForType = entry.getValue();

      CopyOnWriteArraySet<Subscriber> currentSubscribers = subscribers.get(eventType);
      if (currentSubscribers == null || !currentSubscribers.removeAll(listenerMethodsForType)) {
        // if removeAll returns true, all we really know is that at least one subscriber was
        // removed... however, barring something very strange we can assume that if at least one
        // subscriber was removed, all subscribers on listener for that event type were... after
        // all, the definition of subscribers on a particular class is totally static
        throw new IllegalArgumentException(

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 131

                  ImmutableSet<Class<?>> eventTypes = flattenHierarchy(event.getClass());

    List<Iterator<Subscriber>> subscriberIterators =
        Lists.newArrayListWithCapacity(eventTypes.size());

    for (Class<?> eventType : eventTypes) {
      CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);
      if (eventSubscribers != null) {
        // eager no-copy snapshot

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 137

                    CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);
      if (eventSubscribers != null) {
        // eager no-copy snapshot
        subscriberIterators.add(eventSubscribers.iterator());
      }
    }

    return Iterators.concat(subscriberIterators.iterator());
  }

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 141

                    }
    }

    return Iterators.concat(subscriberIterators.iterator());
  }

  /**
   * A thread-safe cache that contains the mapping from each class to all methods in that class and
   * all super-classes, that are annotated with {@code @Subscribe}. The cache is shared across all

            

Reported by PMD.

guava/src/com/google/common/graph/ForwardingValueGraph.java
20 issues
This class has too many methods, consider refactoring it.
Design

Line: 31

               * @author Joshua O'Madadhain
 */
@ElementTypesAreNonnullByDefault
abstract class ForwardingValueGraph<N, V> extends AbstractValueGraph<N, V> {

  abstract ValueGraph<N, V> delegate();

  @Override
  public Set<N> nodes() {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 37

              
  @Override
  public Set<N> nodes() {
    return delegate().nodes();
  }

  /**
   * Defer to {@link AbstractValueGraph#edges()} (based on {@link #successors(Object)}) for full
   * edges() implementation.

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 46

                 */
  @Override
  protected long edgeCount() {
    return delegate().edges().size();
  }

  @Override
  public boolean isDirected() {
    return delegate().isDirected();

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 46

                 */
  @Override
  protected long edgeCount() {
    return delegate().edges().size();
  }

  @Override
  public boolean isDirected() {
    return delegate().isDirected();

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 51

              
  @Override
  public boolean isDirected() {
    return delegate().isDirected();
  }

  @Override
  public boolean allowsSelfLoops() {
    return delegate().allowsSelfLoops();

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 56

              
  @Override
  public boolean allowsSelfLoops() {
    return delegate().allowsSelfLoops();
  }

  @Override
  public ElementOrder<N> nodeOrder() {
    return delegate().nodeOrder();

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 61

              
  @Override
  public ElementOrder<N> nodeOrder() {
    return delegate().nodeOrder();
  }

  @Override
  public ElementOrder<N> incidentEdgeOrder() {
    return delegate().incidentEdgeOrder();

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 66

              
  @Override
  public ElementOrder<N> incidentEdgeOrder() {
    return delegate().incidentEdgeOrder();
  }

  @Override
  public Set<N> adjacentNodes(N node) {
    return delegate().adjacentNodes(node);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 71

              
  @Override
  public Set<N> adjacentNodes(N node) {
    return delegate().adjacentNodes(node);
  }

  @Override
  public Set<N> predecessors(N node) {
    return delegate().predecessors(node);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 76

              
  @Override
  public Set<N> predecessors(N node) {
    return delegate().predecessors(node);
  }

  @Override
  public Set<N> successors(N node) {
    return delegate().successors(node);

            

Reported by PMD.

guava/src/com/google/common/reflect/Invokable.java
20 issues
Avoid throwing raw exception types.
Design

Line: 435

                    try {
        return constructor.newInstance(args);
      } catch (InstantiationException e) {
        throw new RuntimeException(constructor + " failed.", e);
      }
    }

    /**
     * If the class is parameterized, such as {@link java.util.ArrayList ArrayList}, this returns

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 69

              @Beta
@ElementTypesAreNonnullByDefault
public abstract class Invokable<T, R> implements AnnotatedElement, Member {
  private final AccessibleObject accessibleObject;
  private final Member member;

  <M extends AccessibleObject & Member> Invokable(M member) {
    checkNotNull(member);
    this.accessibleObject = member;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 70

              @ElementTypesAreNonnullByDefault
public abstract class Invokable<T, R> implements AnnotatedElement, Member {
  private final AccessibleObject accessibleObject;
  private final Member member;

  <M extends AccessibleObject & Member> Invokable(M member) {
    checkNotNull(member);
    this.accessibleObject = member;
    this.member = member;

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 128

                  try {
      accessibleObject.setAccessible(true);
      return true;
    } catch (RuntimeException e) {
      return false;
    }
  }

  /** See {@link java.lang.reflect.AccessibleObject#isAccessible()}. */

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 218

                public boolean equals(@CheckForNull Object obj) {
    if (obj instanceof Invokable) {
      Invokable<?, ?> that = (Invokable<?, ?>) obj;
      return getOwnerType().equals(that.getOwnerType()) && member.equals(that.member);
    }
    return false;
  }

  @Override

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 218

                public boolean equals(@CheckForNull Object obj) {
    if (obj instanceof Invokable) {
      Invokable<?, ?> that = (Invokable<?, ?>) obj;
      return getOwnerType().equals(that.getOwnerType()) && member.equals(that.member);
    }
    return false;
  }

  @Override

            

Reported by PMD.

The String literal 'unchecked' appears 6 times in this file; the first occurrence is on line 256
Error

Line: 256

                 * @throws InvocationTargetException if the underlying method or constructor throws an exception.
   */
  // All subclasses are owned by us and we'll make sure to get the R type right, including nullness.
  @SuppressWarnings({"unchecked", "nullness"})
  @CanIgnoreReturnValue
  @CheckForNull
  public final R invoke(@CheckForNull T receiver, @Nullable Object... args)
      throws InvocationTargetException, IllegalAccessException {
    return (R) invokeInternal(receiver, checkNotNull(args));

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 283

                  ImmutableList.Builder<Parameter> builder = ImmutableList.builder();
    for (int i = 0; i < parameterTypes.length; i++) {
      builder.add(
          new Parameter(
              this, i, TypeToken.of(parameterTypes[i]), annotations[i], annotatedTypes[i]));
    }
    return builder.build();
  }


            

Reported by PMD.

The method 'getOwnerType()' is missing an @Override annotation.
Design

Line: 334

                /** Returns the type of {@code T}. */
  // Overridden in TypeToken#method() and TypeToken#constructor()
  @SuppressWarnings("unchecked") // The declaring class is T.
  public TypeToken<T> getOwnerType() {
    return (TypeToken<T>) TypeToken.of(getDeclaringClass());
  }

  @CheckForNull
  abstract Object invokeInternal(@CheckForNull Object receiver, @Nullable Object[] args)

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 357

              
  static class MethodInvokable<T> extends Invokable<T, Object> {

    final Method method;

    MethodInvokable(Method method) {
      super(method);
      this.method = method;
    }

            

Reported by PMD.

guava/src/com/google/common/util/concurrent/InterruptibleTask.java
20 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 35

              // Since this class only needs CAS on one field, we can avoid this bug by extending AtomicReference
// instead of using an AtomicReferenceFieldUpdater. This reference stores Thread instances
// and DONE/INTERRUPTED - they have a common ancestor of Runnable.
abstract class InterruptibleTask<T extends @Nullable Object>
    extends AtomicReference<@Nullable Runnable> implements Runnable {
  static {
    // Prevent rare disastrous classloading in first call to LockSupport.park.
    // See: https://bugs.openjdk.java.net/browse/JDK-8074773
    @SuppressWarnings("unused")

            

Reported by PMD.

A catch statement should never catch throwable since it includes errors.
Error

Line: 76

                    if (run) {
        result = runInterruptibly();
      }
    } catch (Throwable t) {
      error = t;
    } finally {
      // Attempt to set the task as done so that further attempts to interrupt will fail.
      if (!compareAndSet(currentThread, DONE)) {
        waitForInterrupt(currentThread);

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 117

                  //                ||     ||
    Runnable state = get();
    Blocker blocker = null;
    while (state instanceof Blocker || state == PARKED) {
      if (state instanceof Blocker) {
        blocker = (Blocker) state;
      }
      spinCount++;
      if (spinCount > MAX_BUSY_WAIT_SPINS) {

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 130

                       * predictable what work might be done. (e.g., close a file and flush buffers to disk). To
         * protect ourselves from this, we park ourselves and tell our interrupter that we did so.
         */
        if (state == PARKED || compareAndSet(state, PARKED)) {
          // Interrupting Cow Says:
          //  ______
          // < Park >
          //  ------
          //        \   ^__^

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 171

                 * interrupted.
   */
  @ParametricNullness
  abstract T runInterruptibly() throws Exception;

  /**
   * Any interruption that happens as a result of calling interruptTask will arrive before this
   * method is called. Complete Futures here.
   */

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 206

                        ((Thread) currentRunner).interrupt();
        } finally {
          Runnable prev = getAndSet(DONE);
          if (prev == PARKED) {
            LockSupport.unpark((Thread) currentRunner);
          }
        }
      }
    }

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 220

                 * identify deadlocks.
   */
  @VisibleForTesting
  static final class Blocker extends AbstractOwnableSynchronizer implements Runnable {
    private final InterruptibleTask<?> task;

    private Blocker(InterruptibleTask<?> task) {
      this.task = task;
    }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 221

                 */
  @VisibleForTesting
  static final class Blocker extends AbstractOwnableSynchronizer implements Runnable {
    private final InterruptibleTask<?> task;

    private Blocker(InterruptibleTask<?> task) {
      this.task = task;
    }


            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 244

                public final String toString() {
    Runnable state = get();
    final String result;
    if (state == DONE) {
      result = "running=[DONE]";
    } else if (state instanceof Blocker) {
      result = "running=[INTERRUPTED]";
    } else if (state instanceof Thread) {
      // getName is final on Thread, no need to worry about exceptions

            

Reported by PMD.

Found 'DD'-anomaly for variable 'result' (lines '70'-'74').
Error

Line: 70

                  }

    boolean run = !isDone();
    T result = null;
    Throwable error = null;
    try {
      if (run) {
        result = runInterruptibly();
      }

            

Reported by PMD.

guava/src/com/google/common/graph/EndpointPair.java
20 issues
This class has too many methods, consider refactoring it.
Design

Line: 43

              @Beta
@Immutable(containerOf = {"N"})
@ElementTypesAreNonnullByDefault
public abstract class EndpointPair<N> implements Iterable<N> {
  private final N nodeU;
  private final N nodeV;

  private EndpointPair(N nodeU, N nodeV) {
    this.nodeU = checkNotNull(nodeU);

            

Reported by PMD.

Field nodeU has the same name as a method
Error

Line: 44

              @Immutable(containerOf = {"N"})
@ElementTypesAreNonnullByDefault
public abstract class EndpointPair<N> implements Iterable<N> {
  private final N nodeU;
  private final N nodeV;

  private EndpointPair(N nodeU, N nodeV) {
    this.nodeU = checkNotNull(nodeU);
    this.nodeV = checkNotNull(nodeV);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 44

              @Immutable(containerOf = {"N"})
@ElementTypesAreNonnullByDefault
public abstract class EndpointPair<N> implements Iterable<N> {
  private final N nodeU;
  private final N nodeV;

  private EndpointPair(N nodeU, N nodeV) {
    this.nodeU = checkNotNull(nodeU);
    this.nodeV = checkNotNull(nodeV);

            

Reported by PMD.

Field nodeV has the same name as a method
Error

Line: 45

              @ElementTypesAreNonnullByDefault
public abstract class EndpointPair<N> implements Iterable<N> {
  private final N nodeU;
  private final N nodeV;

  private EndpointPair(N nodeU, N nodeV) {
    this.nodeU = checkNotNull(nodeU);
    this.nodeV = checkNotNull(nodeV);
  }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 45

              @ElementTypesAreNonnullByDefault
public abstract class EndpointPair<N> implements Iterable<N> {
  private final N nodeU;
  private final N nodeV;

  private EndpointPair(N nodeU, N nodeV) {
    this.nodeU = checkNotNull(nodeU);
    this.nodeV = checkNotNull(nodeV);
  }

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 177

                    }

      EndpointPair<?> other = (EndpointPair<?>) obj;
      if (isOrdered() != other.isOrdered()) {
        return false;
      }

      return source().equals(other.source()) && target().equals(other.target());
    }

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 181

                      return false;
      }

      return source().equals(other.source()) && target().equals(other.target());
    }

    @Override
    public int hashCode() {
      return Objects.hashCode(source(), target());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 181

                      return false;
      }

      return source().equals(other.source()) && target().equals(other.target());
    }

    @Override
    public int hashCode() {
      return Objects.hashCode(source(), target());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 181

                      return false;
      }

      return source().equals(other.source()) && target().equals(other.target());
    }

    @Override
    public int hashCode() {
      return Objects.hashCode(source(), target());

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 181

                      return false;
      }

      return source().equals(other.source()) && target().equals(other.target());
    }

    @Override
    public int hashCode() {
      return Objects.hashCode(source(), target());

            

Reported by PMD.

android/guava/src/com/google/common/util/concurrent/CombinedFuture.java
20 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 36

              @ElementTypesAreNonnullByDefault
final class CombinedFuture<V extends @Nullable Object>
    extends AggregateFuture<@Nullable Object, V> {
  @CheckForNull private CombinedFutureInterruptibleTask<?> task;

  CombinedFuture(
      ImmutableCollection<? extends ListenableFuture<?>> futures,
      boolean allMustSucceed,
      Executor listenerExecutor,

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 80

                   * or after the output future is done, whichever comes first.
     */
    if (reason == OUTPUT_FUTURE_DONE) {
      this.task = null;
    }
  }

  @Override
  protected void interruptTask() {

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 93

                }

  @WeakOuter
  private abstract class CombinedFutureInterruptibleTask<T extends @Nullable Object>
      extends InterruptibleTask<T> {
    private final Executor listenerExecutor;

    CombinedFutureInterruptibleTask(Executor listenerExecutor) {
      this.listenerExecutor = checkNotNull(listenerExecutor);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 95

                @WeakOuter
  private abstract class CombinedFutureInterruptibleTask<T extends @Nullable Object>
      extends InterruptibleTask<T> {
    private final Executor listenerExecutor;

    CombinedFutureInterruptibleTask(Executor listenerExecutor) {
      this.listenerExecutor = checkNotNull(listenerExecutor);
    }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 103

              
    @Override
    final boolean isDone() {
      return CombinedFuture.this.isDone();
    }

    final void execute() {
      try {
        listenerExecutor.execute(this);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 103

              
    @Override
    final boolean isDone() {
      return CombinedFuture.this.isDone();
    }

    final void execute() {
      try {
        listenerExecutor.execute(this);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 110

                    try {
        listenerExecutor.execute(this);
      } catch (RejectedExecutionException e) {
        CombinedFuture.this.setException(e);
      }
    }

    @Override
    final void afterRanInterruptiblySuccess(@ParametricNullness T result) {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 110

                    try {
        listenerExecutor.execute(this);
      } catch (RejectedExecutionException e) {
        CombinedFuture.this.setException(e);
      }
    }

    @Override
    final void afterRanInterruptiblySuccess(@ParametricNullness T result) {

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 127

                     * InterruptibleTask itself might also eliminate some of the existing boilerplate for, e.g.,
       * pendingToString().)
       */
      CombinedFuture.this.task = null;

      setValue(result);
    }

    @Override

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 135

                  @Override
    final void afterRanInterruptiblyFailure(Throwable error) {
      // See afterRanInterruptiblySuccess.
      CombinedFuture.this.task = null;

      if (error instanceof ExecutionException) {
        /*
         * Cast to ExecutionException to satisfy our nullness checker, which (unsoundly but
         * *usually* safely) assumes that getCause() returns non-null on an ExecutionException.

            

Reported by PMD.