hrldcpr/pcollections

fix deprecation warnings

Opened this issue · 3 comments

mvn clean compile -Dmaven.compiler.showDeprecation=true

…they don't indicate any actual problem, they're just because we have to implement mutators to fulfill Collections interfaces, but we have also deprecated mutators in PCollections so that people get IDE warnings if they try to use them

possibly can suppress the warning with a suppression comment?

Since the project is on gradle now exclusively, what command would reproduce this?

Thanks good point. To see the warnings, add this to the bottom of build.gradle:

allprojects {
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:deprecation"
        }
    }
}

(specifically, as of now the warnings are:

src/main/java/org/pcollections/MapPBag.java:24: warning: [deprecation] addAll(Collection<? extends E>) in PCollection has been deprecated
public final class MapPBag<E> extends AbstractCollection<E> implements PBag<E>, Serializable {
             ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/MapPBag.java:24: warning: [deprecation] add(E) in PCollection has been deprecated
public final class MapPBag<E> extends AbstractCollection<E> implements PBag<E>, Serializable {
             ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/AmortizedPQueue.java:149: warning: [deprecation] poll() in PQueue has been deprecated
  public E poll() {
           ^
  where E is a type-variable:
    E extends Object declared in interface PQueue
src/main/java/org/pcollections/AmortizedPQueue.java:143: warning: [deprecation] offer(E) in PQueue has been deprecated
  public boolean offer(E o) {
                 ^
  where E is a type-variable:
    E extends Object declared in interface PQueue
src/main/java/org/pcollections/AmortizedPQueue.java:22: warning: [deprecation] addAll(Collection<? extends E>) in PCollection has been deprecated
public class AmortizedPQueue<E> extends AbstractQueue<E> implements PQueue<E>, Serializable {
       ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/AmortizedPQueue.java:22: warning: [deprecation] add(E) in PCollection has been deprecated
public class AmortizedPQueue<E> extends AbstractQueue<E> implements PQueue<E>, Serializable {
       ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/HashPMap.java:31: warning: [deprecation] putAll(Map<? extends K,? extends V>) in PMap has been deprecated
public final class HashPMap<K, V> extends AbstractMap<K, V> implements PMap<K, V>, Serializable {
             ^
  where K,V are type-variables:
    K extends Object declared in interface PMap
    V extends Object declared in interface PMap
src/main/java/org/pcollections/HashPMap.java:31: warning: [deprecation] put(K,V) in PMap has been deprecated
public final class HashPMap<K, V> extends AbstractMap<K, V> implements PMap<K, V>, Serializable {
             ^
  where K,V are type-variables:
    K extends Object declared in interface PMap
    V extends Object declared in interface PMap
src/main/java/org/pcollections/IntTreePMap.java:37: warning: [deprecation] putAll(Map<? extends K,? extends V>) in PMap has been deprecated
public final class IntTreePMap<V> extends AbstractMap<Integer, V>
             ^
  where K,V are type-variables:
    K extends Object declared in interface PMap
    V extends Object declared in interface PMap
src/main/java/org/pcollections/IntTreePMap.java:37: warning: [deprecation] put(K,V) in PMap has been deprecated
public final class IntTreePMap<V> extends AbstractMap<Integer, V>
             ^
  where K,V are type-variables:
    K extends Object declared in interface PMap
    V extends Object declared in interface PMap
src/main/java/org/pcollections/OrderedPSet.java:14: warning: [deprecation] addAll(Collection<? extends E>) in PCollection has been deprecated
public class OrderedPSet<E> extends AbstractSet<E> implements POrderedSet<E>, Serializable {
       ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/OrderedPSet.java:14: warning: [deprecation] add(E) in PCollection has been deprecated
public class OrderedPSet<E> extends AbstractSet<E> implements POrderedSet<E>, Serializable {
       ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/ConsPStack.java:25: warning: [deprecation] add(int,E) in PSequence has been deprecated
public final class ConsPStack<E> extends AbstractSequentialList<E>
             ^
  where E is a type-variable:
    E extends Object declared in interface PSequence
src/main/java/org/pcollections/ConsPStack.java:25: warning: [deprecation] set(int,E) in PSequence has been deprecated
public final class ConsPStack<E> extends AbstractSequentialList<E>
             ^
  where E is a type-variable:
    E extends Object declared in interface PSequence
src/main/java/org/pcollections/ConsPStack.java:25: warning: [deprecation] addAll(int,Collection<? extends E>) in PSequence has been deprecated
public final class ConsPStack<E> extends AbstractSequentialList<E>
             ^
  where E is a type-variable:
    E extends Object declared in interface PSequence
src/main/java/org/pcollections/ConsPStack.java:25: warning: [deprecation] addAll(Collection<? extends E>) in PCollection has been deprecated
public final class ConsPStack<E> extends AbstractSequentialList<E>
             ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/ConsPStack.java:25: warning: [deprecation] add(E) in PCollection has been deprecated
public final class ConsPStack<E> extends AbstractSequentialList<E>
             ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/MapPSet.java:23: warning: [deprecation] addAll(Collection<? extends E>) in PCollection has been deprecated
public final class MapPSet<E> extends AbstractSet<E> implements PSet<E>, Serializable {
             ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/MapPSet.java:23: warning: [deprecation] add(E) in PCollection has been deprecated
public final class MapPSet<E> extends AbstractSet<E> implements PSet<E>, Serializable {
             ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/TreePVector.java:27: warning: [deprecation] add(int,E) in PSequence has been deprecated
public class TreePVector<E> extends AbstractList<E> implements PVector<E>, Serializable {
       ^
  where E is a type-variable:
    E extends Object declared in interface PSequence
src/main/java/org/pcollections/TreePVector.java:27: warning: [deprecation] set(int,E) in PSequence has been deprecated
public class TreePVector<E> extends AbstractList<E> implements PVector<E>, Serializable {
       ^
  where E is a type-variable:
    E extends Object declared in interface PSequence
src/main/java/org/pcollections/TreePVector.java:27: warning: [deprecation] addAll(int,Collection<? extends E>) in PSequence has been deprecated
public class TreePVector<E> extends AbstractList<E> implements PVector<E>, Serializable {
       ^
  where E is a type-variable:
    E extends Object declared in interface PSequence
src/main/java/org/pcollections/TreePVector.java:27: warning: [deprecation] addAll(Collection<? extends E>) in PCollection has been deprecated
public class TreePVector<E> extends AbstractList<E> implements PVector<E>, Serializable {
       ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
src/main/java/org/pcollections/TreePVector.java:27: warning: [deprecation] add(E) in PCollection has been deprecated
public class TreePVector<E> extends AbstractList<E> implements PVector<E>, Serializable {
       ^
  where E is a type-variable:
    E extends Object declared in interface PCollection
24 warnings

)

adding @SuppressWarnings("deprecation") above a class seems to fix it, but isn't ideal since that will suppress any other deprecation warnings we might introduce… would be nice to suppress just these specific warnings.

Not marking the methods as deprecated is one solution, but I think those annotations are potentially quite useful for catching bugs, so... 🤔 maybe best to just leave it be