The following issues were found

android/guava/src/com/google/common/util/concurrent/ForwardingCondition.java
7 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 28

              
  @Override
  public void await() throws InterruptedException {
    delegate().await();
  }

  @Override
  public boolean await(long time, TimeUnit unit) throws InterruptedException {
    return delegate().await(time, unit);

            

Reported by PMD.

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

Line: 33

              
  @Override
  public boolean await(long time, TimeUnit unit) throws InterruptedException {
    return delegate().await(time, unit);
  }

  @Override
  public void awaitUninterruptibly() {
    delegate().awaitUninterruptibly();

            

Reported by PMD.

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

Line: 38

              
  @Override
  public void awaitUninterruptibly() {
    delegate().awaitUninterruptibly();
  }

  @Override
  public long awaitNanos(long nanosTimeout) throws InterruptedException {
    return delegate().awaitNanos(nanosTimeout);

            

Reported by PMD.

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

Line: 43

              
  @Override
  public long awaitNanos(long nanosTimeout) throws InterruptedException {
    return delegate().awaitNanos(nanosTimeout);
  }

  @Override
  public boolean awaitUntil(Date deadline) throws InterruptedException {
    return delegate().awaitUntil(deadline);

            

Reported by PMD.

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

Line: 48

              
  @Override
  public boolean awaitUntil(Date deadline) throws InterruptedException {
    return delegate().awaitUntil(deadline);
  }

  @Override
  public void signal() {
    delegate().signal();

            

Reported by PMD.

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

Line: 53

              
  @Override
  public void signal() {
    delegate().signal();
  }

  @Override
  public void signalAll() {
    delegate().signalAll();

            

Reported by PMD.

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

Line: 58

              
  @Override
  public void signalAll() {
    delegate().signalAll();
  }
}

            

Reported by PMD.

android/guava-tests/test/com/google/common/reflect/ParameterTest.java
7 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 31

               */
public class ParameterTest extends TestCase {

  public void testNulls() {
    for (Method method : ParameterTest.class.getDeclaredMethods()) {
      for (Parameter param : Invokable.from(method).getParameters()) {
        new NullPointerTester().testAllPublicInstanceMethods(param);
      }
    }

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 31

               */
public class ParameterTest extends TestCase {

  public void testNulls() {
    for (Method method : ParameterTest.class.getDeclaredMethods()) {
      for (Parameter param : Invokable.from(method).getParameters()) {
        new NullPointerTester().testAllPublicInstanceMethods(param);
      }
    }

            

Reported by PMD.

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

Line: 33

              
  public void testNulls() {
    for (Method method : ParameterTest.class.getDeclaredMethods()) {
      for (Parameter param : Invokable.from(method).getParameters()) {
        new NullPointerTester().testAllPublicInstanceMethods(param);
      }
    }
  }


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 34

                public void testNulls() {
    for (Method method : ParameterTest.class.getDeclaredMethods()) {
      for (Parameter param : Invokable.from(method).getParameters()) {
        new NullPointerTester().testAllPublicInstanceMethods(param);
      }
    }
  }

  public void testEquals() {

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 39

                  }
  }

  public void testEquals() {
    EqualsTester tester = new EqualsTester();
    for (Method method : ParameterTest.class.getDeclaredMethods()) {
      for (Parameter param : Invokable.from(method).getParameters()) {
        tester.addEqualityGroup(param);
      }

            

Reported by PMD.

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

Line: 39

                  }
  }

  public void testEquals() {
    EqualsTester tester = new EqualsTester();
    for (Method method : ParameterTest.class.getDeclaredMethods()) {
      for (Parameter param : Invokable.from(method).getParameters()) {
        tester.addEqualityGroup(param);
      }

            

Reported by PMD.

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

Line: 42

                public void testEquals() {
    EqualsTester tester = new EqualsTester();
    for (Method method : ParameterTest.class.getDeclaredMethods()) {
      for (Parameter param : Invokable.from(method).getParameters()) {
        tester.addEqualityGroup(param);
      }
    }
    tester.testEquals();
  }

            

Reported by PMD.

android/guava/src/com/google/common/collect/Interners.java
7 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 44

                 * @since 21.0
   */
  public static class InternerBuilder {
    private final MapMaker mapMaker = new MapMaker();
    private boolean strong = true;

    private InternerBuilder() {}

    /**

            

Reported by PMD.

Field strong has the same name as a method
Error

Line: 45

                 */
  public static class InternerBuilder {
    private final MapMaker mapMaker = new MapMaker();
    private boolean strong = true;

    private InternerBuilder() {}

    /**
     * Instructs the {@link InternerBuilder} to build a strong interner.

            

Reported by PMD.

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

Line: 45

                 */
  public static class InternerBuilder {
    private final MapMaker mapMaker = new MapMaker();
    private boolean strong = true;

    private InternerBuilder() {}

    /**
     * Instructs the {@link InternerBuilder} to build a strong interner.

            

Reported by PMD.

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

Line: 116

                @VisibleForTesting
  static final class InternerImpl<E> implements Interner<E> {
    // MapMaker is our friend, we know about this type
    @VisibleForTesting final MapMakerInternalMap<E, Dummy, ?, ?> map;

    private InternerImpl(MapMaker mapMaker) {
      this.map =
          MapMakerInternalMap.createWithDummyValues(mapMaker.keyEquivalence(Equivalence.equals()));
    }

            

Reported by PMD.

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

Line: 130

                      @SuppressWarnings("rawtypes") // using raw types to avoid a bug in our nullness checker :(
        InternalEntry entry = map.getEntry(sample);
        if (entry != null) {
          Object canonical = entry.getKey();
          if (canonical != null) { // only matters if weak/soft keys are used
            // The compiler would know this is safe if not for our use of raw types (see above).
            @SuppressWarnings("unchecked")
            E result = (E) canonical;
            return result;

            

Reported by PMD.

Avoid empty if statements
Error

Line: 143

                      Dummy sneaky = map.putIfAbsent(sample, Dummy.VALUE);
        if (sneaky == null) {
          return sample;
        } else {
          /* Someone beat us to it! Trying again...
           *
           * Technically this loop not guaranteed to terminate, so theoretically (extremely
           * unlikely) this thread might starve, but even then, there is always going to be another
           * thread doing progress here.

            

Reported by PMD.

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

Line: 166

              
  private static class InternerFunction<E> implements Function<E, E> {

    private final Interner<E> interner;

    public InternerFunction(Interner<E> interner) {
      this.interner = interner;
    }


            

Reported by PMD.

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

Line: 48

                  extends AbstractFuture.TrustedFuture<OutputT> {
  // Lazily initialized the first time we see an exception; not released until all the input futures
  // have completed and we have processed them all.
  @CheckForNull private volatile Set<Throwable> seenExceptions = null;

  private volatile int remaining;

  private static final AtomicHelper ATOMIC_HELPER;


            

Reported by PMD.

Avoid using redundant field initializer for 'seenExceptions'
Performance

Line: 48

                  extends AbstractFuture.TrustedFuture<OutputT> {
  // Lazily initialized the first time we see an exception; not released until all the input futures
  // have completed and we have processed them all.
  @CheckForNull private volatile Set<Throwable> seenExceptions = null;

  private volatile int remaining;

  private static final AtomicHelper ATOMIC_HELPER;


            

Reported by PMD.

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

Line: 50

                // have completed and we have processed them all.
  @CheckForNull private volatile Set<Throwable> seenExceptions = null;

  private volatile int remaining;

  private static final AtomicHelper ATOMIC_HELPER;

  private static final Logger log = Logger.getLogger(AggregateFutureState.class.getName());


            

Reported by PMD.

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

Line: 64

                        new SafeAtomicHelper(
              newUpdater(AggregateFutureState.class, Set.class, "seenExceptions"),
              newUpdater(AggregateFutureState.class, "remaining"));
    } catch (Throwable reflectionFailure) {
      // Some Android 5.0.x Samsung devices have bugs in JDK reflection APIs that cause
      // getDeclaredField to throw a NoSuchFieldException when the field is definitely there.
      // For these users fallback to a suboptimal implementation, based on synchronized. This will
      // be a definite performance hit to those users.
      thrownReflectionFailure = reflectionFailure;

            

Reported by PMD.

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

Line: 149

                }

  final void clearSeenExceptions() {
    seenExceptions = null;
  }

  private abstract static class AtomicHelper {
    /** Atomic compare-and-set of the {@link AggregateFutureState#seenExceptions} field. */
    abstract void compareAndSetSeenExceptions(

            

Reported by PMD.

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

Line: 163

              
  private static final class SafeAtomicHelper extends AtomicHelper {
    final AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>
        seenExceptionsUpdater;

    final AtomicIntegerFieldUpdater<AggregateFutureState<?>> remainingCountUpdater;

    @SuppressWarnings({"rawtypes", "unchecked"}) // Unavoidable with reflection API
    SafeAtomicHelper(

            

Reported by PMD.

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

Line: 165

                  final AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>
        seenExceptionsUpdater;

    final AtomicIntegerFieldUpdater<AggregateFutureState<?>> remainingCountUpdater;

    @SuppressWarnings({"rawtypes", "unchecked"}) // Unavoidable with reflection API
    SafeAtomicHelper(
        AtomicReferenceFieldUpdater seenExceptionsUpdater,
        AtomicIntegerFieldUpdater remainingCountUpdater) {

            

Reported by PMD.

android/guava/src/com/google/common/collect/StandardRowSortedTable.java
7 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 75

                 */
  @Override
  public SortedSet<R> rowKeySet() {
    return (SortedSet<R>) rowMap().keySet();
  }

  /**
   * {@inheritDoc}
   *

            

Reported by PMD.

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

Line: 109

                  @Override
    @CheckForNull
    public Comparator<? super R> comparator() {
      return sortedBackingMap().comparator();
    }

    @Override
    public R firstKey() {
      return sortedBackingMap().firstKey();

            

Reported by PMD.

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

Line: 114

              
    @Override
    public R firstKey() {
      return sortedBackingMap().firstKey();
    }

    @Override
    public R lastKey() {
      return sortedBackingMap().lastKey();

            

Reported by PMD.

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

Line: 119

              
    @Override
    public R lastKey() {
      return sortedBackingMap().lastKey();
    }

    @Override
    public SortedMap<R, Map<C, V>> headMap(R toKey) {
      checkNotNull(toKey);

            

Reported by PMD.

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

Line: 125

                  @Override
    public SortedMap<R, Map<C, V>> headMap(R toKey) {
      checkNotNull(toKey);
      return new StandardRowSortedTable<R, C, V>(sortedBackingMap().headMap(toKey), factory)
          .rowMap();
    }

    @Override
    public SortedMap<R, Map<C, V>> subMap(R fromKey, R toKey) {

            

Reported by PMD.

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

Line: 133

                  public SortedMap<R, Map<C, V>> subMap(R fromKey, R toKey) {
      checkNotNull(fromKey);
      checkNotNull(toKey);
      return new StandardRowSortedTable<R, C, V>(sortedBackingMap().subMap(fromKey, toKey), factory)
          .rowMap();
    }

    @Override
    public SortedMap<R, Map<C, V>> tailMap(R fromKey) {

            

Reported by PMD.

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

Line: 140

                  @Override
    public SortedMap<R, Map<C, V>> tailMap(R fromKey) {
      checkNotNull(fromKey);
      return new StandardRowSortedTable<R, C, V>(sortedBackingMap().tailMap(fromKey), factory)
          .rowMap();
    }
  }

  private static final long serialVersionUID = 0;

            

Reported by PMD.

android/guava/src/com/google/common/cache/ForwardingLoadingCache.java
7 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 46

              
  @Override
  public V get(K key) throws ExecutionException {
    return delegate().get(key);
  }

  @Override
  public V getUnchecked(K key) {
    return delegate().getUnchecked(key);

            

Reported by PMD.

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

Line: 51

              
  @Override
  public V getUnchecked(K key) {
    return delegate().getUnchecked(key);
  }

  @Override
  public ImmutableMap<K, V> getAll(Iterable<? extends K> keys) throws ExecutionException {
    return delegate().getAll(keys);

            

Reported by PMD.

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

Line: 56

              
  @Override
  public ImmutableMap<K, V> getAll(Iterable<? extends K> keys) throws ExecutionException {
    return delegate().getAll(keys);
  }

  @Override
  public V apply(K key) {
    return delegate().apply(key);

            

Reported by PMD.

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

Line: 61

              
  @Override
  public V apply(K key) {
    return delegate().apply(key);
  }

  @Override
  public void refresh(K key) {
    delegate().refresh(key);

            

Reported by PMD.

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

Line: 66

              
  @Override
  public void refresh(K key) {
    delegate().refresh(key);
  }

  /**
   * A simplified version of {@link ForwardingLoadingCache} where subclasses can pass in an already
   * constructed {@link LoadingCache} as the delegate.

            

Reported by PMD.

Field delegate has the same name as a method
Error

Line: 77

                 */
  public abstract static class SimpleForwardingLoadingCache<K, V>
      extends ForwardingLoadingCache<K, V> {
    private final LoadingCache<K, V> delegate;

    protected SimpleForwardingLoadingCache(LoadingCache<K, V> delegate) {
      this.delegate = Preconditions.checkNotNull(delegate);
    }


            

Reported by PMD.

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

Line: 77

                 */
  public abstract static class SimpleForwardingLoadingCache<K, V>
      extends ForwardingLoadingCache<K, V> {
    private final LoadingCache<K, V> delegate;

    protected SimpleForwardingLoadingCache(LoadingCache<K, V> delegate) {
      this.delegate = Preconditions.checkNotNull(delegate);
    }


            

Reported by PMD.

android/guava/src/com/google/common/base/Equivalence.java
7 issues
The method name and parameter number are suspiciously close to equals(Object)
Error

Line: 317

                 * @since 8.0 (in Equivalences with null-friendly behavior)
   * @since 4.0 (in Equivalences)
   */
  public static Equivalence<Object> equals() {
    return Equals.INSTANCE;
  }

  /**
   * Returns an equivalence that uses {@code ==} to compare values and {@link

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 69

                 * long as neither {@code x} nor {@code y} is modified.
   */
  public final boolean equivalent(@CheckForNull T a, @CheckForNull T b) {
    if (a == b) {
      return true;
    }
    if (a == null || b == null) {
      return false;
    }

            

Reported by PMD.

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

Line: 180

                 * @since 10.0
   */
  public static final class Wrapper<T extends @Nullable Object> implements Serializable {
    private final Equivalence<? super T> equivalence;
    @ParametricNullness private final T reference;

    private Wrapper(Equivalence<? super T> equivalence, @ParametricNullness T reference) {
      this.equivalence = checkNotNull(equivalence);
      this.reference = reference;

            

Reported by PMD.

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

Line: 181

                 */
  public static final class Wrapper<T extends @Nullable Object> implements Serializable {
    private final Equivalence<? super T> equivalence;
    @ParametricNullness private final T reference;

    private Wrapper(Equivalence<? super T> equivalence, @ParametricNullness T reference) {
      this.equivalence = checkNotNull(equivalence);
      this.reference = reference;
    }

            

Reported by PMD.

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

Line: 214

                         */
          @SuppressWarnings("unchecked")
          Equivalence<Object> equivalence = (Equivalence<Object>) this.equivalence;
          return equivalence.equivalent(this.reference, that.reference);
        }
      }
      return false;
    }


            

Reported by PMD.

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

Line: 269

                private static final class EquivalentToPredicate<T>
      implements Predicate<@Nullable T>, Serializable {

    private final Equivalence<T> equivalence;
    @CheckForNull private final T target;

    EquivalentToPredicate(Equivalence<T> equivalence, @CheckForNull T target) {
      this.equivalence = checkNotNull(equivalence);
      this.target = target;

            

Reported by PMD.

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

Line: 270

                    implements Predicate<@Nullable T>, Serializable {

    private final Equivalence<T> equivalence;
    @CheckForNull private final T target;

    EquivalentToPredicate(Equivalence<T> equivalence, @CheckForNull T target) {
      this.equivalence = checkNotNull(equivalence);
      this.target = target;
    }

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java
7 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 107

                abstract static class OldAbstractFuture<V> implements ListenableFuture<V> {

    /** Synchronization control for AbstractFutures. */
    private final Sync<V> sync = new Sync<V>();

    // The execution list to hold our executors.
    private final ExecutionList executionList = new ExecutionList();

    /** Constructor for use by subclasses. */

            

Reported by PMD.

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

Line: 110

                  private final Sync<V> sync = new Sync<V>();

    // The execution list to hold our executors.
    private final ExecutionList executionList = new ExecutionList();

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

    /*

            

Reported by PMD.

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

Line: 272

                    static final int CANCELLED = 4;
      static final int INTERRUPTED = 8;

      private V value;
      private Throwable exception;

      /*
       * Acquisition succeeds if the future is done, otherwise it fails.
       */

            

Reported by PMD.

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

Line: 273

                    static final int INTERRUPTED = 8;

      private V value;
      private Throwable exception;

      /*
       * Acquisition succeeds if the future is done, otherwise it fails.
       */
      @Override

            

Reported by PMD.

A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 301

                     * if the timer expires, otherwise behaves like {@link #get()}.
       */
      V get(long nanos)
          throws TimeoutException, CancellationException, ExecutionException, InterruptedException {

        // Attempt to acquire the shared lock with a timeout.
        if (!tryAcquireSharedNanos(-1, nanos)) {
          throw new TimeoutException("Timeout waiting for task.");
        }

            

Reported by PMD.

A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 316

                     * a {@link CancellationException} if the task was cancelled, or a {@link ExecutionException}
       * if the task completed with an error.
       */
      V get() throws CancellationException, ExecutionException, InterruptedException {

        // Acquire the shared lock allowing interruption.
        acquireSharedInterruptibly(-1);
        return getValue();
      }

            

Reported by PMD.

A method or constructor should not explicitly declare unchecked exceptions in its 'throws' clause
Design

Line: 328

                     * exception on failure, a cancellation on cancellation, or an illegal state if the
       * synchronizer is in an invalid state.
       */
      private V getValue() throws CancellationException, ExecutionException {
        int state = getState();
        switch (state) {
          case COMPLETED:
            if (exception != null) {
              throw new ExecutionException(exception);

            

Reported by PMD.

android/guava/src/com/google/common/io/LineReader.java
7 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 42

              @GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class LineReader {
  private final Readable readable;
  @CheckForNull private final Reader reader;
  private final CharBuffer cbuf = createBuffer();
  private final char[] buf = cbuf.array();

  private final Queue<String> lines = new ArrayDeque<>();

            

Reported by PMD.

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

Line: 43

              @ElementTypesAreNonnullByDefault
public final class LineReader {
  private final Readable readable;
  @CheckForNull private final Reader reader;
  private final CharBuffer cbuf = createBuffer();
  private final char[] buf = cbuf.array();

  private final Queue<String> lines = new ArrayDeque<>();
  private final LineBuffer lineBuf =

            

Reported by PMD.

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

Line: 44

              public final class LineReader {
  private final Readable readable;
  @CheckForNull private final Reader reader;
  private final CharBuffer cbuf = createBuffer();
  private final char[] buf = cbuf.array();

  private final Queue<String> lines = new ArrayDeque<>();
  private final LineBuffer lineBuf =
      new LineBuffer() {

            

Reported by PMD.

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

Line: 45

                private final Readable readable;
  @CheckForNull private final Reader reader;
  private final CharBuffer cbuf = createBuffer();
  private final char[] buf = cbuf.array();

  private final Queue<String> lines = new ArrayDeque<>();
  private final LineBuffer lineBuf =
      new LineBuffer() {
        @Override

            

Reported by PMD.

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

Line: 47

                private final CharBuffer cbuf = createBuffer();
  private final char[] buf = cbuf.array();

  private final Queue<String> lines = new ArrayDeque<>();
  private final LineBuffer lineBuf =
      new LineBuffer() {
        @Override
        protected void handleLine(String line, String end) {
          lines.add(line);

            

Reported by PMD.

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

Line: 48

                private final char[] buf = cbuf.array();

  private final Queue<String> lines = new ArrayDeque<>();
  private final LineBuffer lineBuf =
      new LineBuffer() {
        @Override
        protected void handleLine(String line, String end) {
          lines.add(line);
        }

            

Reported by PMD.

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

Line: 59

                /** Creates a new instance that will read lines from the given {@code Readable} object. */
  public LineReader(Readable readable) {
    this.readable = checkNotNull(readable);
    this.reader = (readable instanceof Reader) ? (Reader) readable : null;
  }

  /**
   * Reads a line of text. A line is considered to be terminated by any one of a line feed ({@code
   * '\n'}), a carriage return ({@code '\r'}), or a carriage return followed immediately by a

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/ClassPathUtil.java
7 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 39

                // TODO(b/65488446): Make this a public API.
  static URL[] parseJavaClassPath() {
    ImmutableList.Builder<URL> urls = ImmutableList.builder();
    for (String entry : Splitter.on(PATH_SEPARATOR.value()).split(JAVA_CLASS_PATH.value())) {
      try {
        try {
          urls.add(new File(entry).toURI().toURL());
        } catch (SecurityException e) { // File.toURI checks to see if the file is a directory
          urls.add(new URL("file", null, new File(entry).getAbsolutePath()));

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 42

                  for (String entry : Splitter.on(PATH_SEPARATOR.value()).split(JAVA_CLASS_PATH.value())) {
      try {
        try {
          urls.add(new File(entry).toURI().toURL());
        } catch (SecurityException e) { // File.toURI checks to see if the file is a directory
          urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
        }
      } catch (MalformedURLException e) {
        AssertionError error = new AssertionError("malformed class path entry: " + entry);

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 44

                      try {
          urls.add(new File(entry).toURI().toURL());
        } catch (SecurityException e) { // File.toURI checks to see if the file is a directory
          urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
        }
      } catch (MalformedURLException e) {
        AssertionError error = new AssertionError("malformed class path entry: " + entry);
        error.initCause(e);
        throw error;

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 44

                      try {
          urls.add(new File(entry).toURI().toURL());
        } catch (SecurityException e) { // File.toURI checks to see if the file is a directory
          urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
        }
      } catch (MalformedURLException e) {
        AssertionError error = new AssertionError("malformed class path entry: " + entry);
        error.initCause(e);
        throw error;

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 47

                        urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
        }
      } catch (MalformedURLException e) {
        AssertionError error = new AssertionError("malformed class path entry: " + entry);
        error.initCause(e);
        throw error;
      }
    }
    return urls.build().toArray(new URL[0]);

            

Reported by PMD.

In J2EE, getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead.
Error

Line: 57

              
  /** Returns the URLs in the class path. */
  static URL[] getClassPathUrls() {
    return ClassPathUtil.class.getClassLoader() instanceof URLClassLoader
        ? ((URLClassLoader) ClassPathUtil.class.getClassLoader()).getURLs()
        : parseJavaClassPath();
  }
}

            

Reported by PMD.

In J2EE, getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead.
Error

Line: 58

                /** Returns the URLs in the class path. */
  static URL[] getClassPathUrls() {
    return ClassPathUtil.class.getClassLoader() instanceof URLClassLoader
        ? ((URLClassLoader) ClassPathUtil.class.getClassLoader()).getURLs()
        : parseJavaClassPath();
  }
}

            

Reported by PMD.