bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/22917] TreeSet & PriorityQueue in generics_branch cannot


From: gcc-bugzilla at gcc dot gnu dot org
Subject: [Bug classpath/22917] TreeSet & PriorityQueue in generics_branch cannot be compiled with sun's javac.
Date: 16 Oct 2005 01:27:40 -0000

Compiling it with Eclipse 3.1M6 is ok, sun's javac give invalid type errors.

The patches are here:

===================================================================
  RCS file:
/cvsroot/jnode/jnode/core/src/classpath/5.0/java/util/TreeSet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TreeSet.java      15 Apr 2005 07:46:57 -0000      1.1
  +++ TreeSet.java      15 Apr 2005 18:52:58 -0000      1.2
  @@ -151,7 +151,7 @@
     {
       Iterator<T> itr;

  -    map = new TreeMap<T, String>(sortedSet.comparator());
  +    map = new TreeMap<T, String>((Comparator<? super
T>)sortedSet.comparator());
       itr = ((SortedSet<T>) sortedSet).iterator();
       ((TreeMap<T, String>) map).putKeysLinear(itr, sortedSet.size());
     }



  1.2       +8 -4     
jnode/core/src/classpath/5.0/java/util/PriorityQueue.java

  Index: PriorityQueue.java
  ===================================================================
  RCS file:
/cvsroot/jnode/jnode/core/src/classpath/5.0/java/util/PriorityQueue.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PriorityQueue.java        15 Apr 2005 07:46:57 -0000      1.1
  +++ PriorityQueue.java        15 Apr 2005 18:52:58 -0000      1.2
  @@ -76,7 +76,8 @@
       if (c instanceof SortedSet)
         {
        SortedSet<? extends E> ss = (SortedSet<? extends E>) c;
  -     this.comparator = ss.comparator();
  +    // @classpath-bugfix Type mismatch using sun's compiler
  +     this.comparator = (Comparator<? super E>)ss.comparator();
        // We can insert the elements directly, since they are sorted.
        int i = 0;
        for (E val : ss)
  @@ -89,7 +90,8 @@
       else if (c instanceof PriorityQueue)
         {
        PriorityQueue<? extends E> pq = (PriorityQueue<? extends E>) c;
  -     this.comparator = pq.comparator();
  +    // @classpath-bugfix Type mismatch on sun's compiler
  +     this.comparator = (Comparator<? super E>)pq.comparator();
        // We can just copy the contents.
        System.arraycopy(pq.storage, 0, storage, 0, pq.storage.length);
         }
  @@ -111,14 +113,16 @@

     public PriorityQueue(PriorityQueue<? extends E> c)
     {
  -    this(Math.max(1, (int) (1.1 * c.size())), c.comparator());
  +      // @classpath-bugfix Type mismatch on sun's compiler
  +    this(Math.max(1, (int) (1.1 * c.size())), (Comparator<? super
E>)c.comparator());
       // We can just copy the contents.
       System.arraycopy(c.storage, 0, storage, 0, c.storage.length);
     }

     public PriorityQueue(SortedSet<? extends E> c)
     {
  -    this(Math.max(1, (int) (1.1 * c.size())), c.comparator());
  +      // @classpath-bugfix Type mismatch on sun's compiler
  +    this(Math.max(1, (int) (1.1 * c.size())), (Comparator<? super
E>)c.comparator());
       // We can insert the elements directly, since they are sorted.
       int i = 0;
       for (E val : c)




------- Comment #1 from from-classpath at savannah dot gnu dot org  2005-04-16 
11:40 -------
Patch committed, although I'd be interested to know as to which compiler has
the bug here.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22917





reply via email to

[Prev in Thread] Current Thread [Next in Thread]