Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5101303

misleading "incompatible types" compiler error

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      Name: gm110360 Date: 09/13/2004


      FULL PRODUCT VERSION :
      java version "1.5.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
      Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Compiling the attached source emits the following error message:

      21: incompatible types
      found : java.util.Iterator<R>
      required: java.util.Iterator<R>
            return iterator;
                   ^
      1 error

      I cannot see what might be wrong with the source, but in any case the error message is not helpful.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile the sample source


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      21: incompatible types
      found : java.util.Iterator<R>
      required: java.util.Iterator<R>
            return iterator;
                   ^
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Iterator;

      class MyIterator<R> implements Iterator<R> {
        public void remove() {
        }

        public R next() {
          return null;
        }

        public boolean hasNext() {
          return false;
        }
      }

      class MyClass<R> {
        final Iterator<R> iterator = new MyIterator<R>();

        class IterableImpl<R> implements Iterable<R> {
          public Iterator<R> iterator() {
            return iterator;
          }
        }
      }

      ---------- END SOURCE ----------
      (Incident Review ID: 305630)
      ======================================================================
      ###@###.### 10/8/04 20:28 GMT

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                gmanwanisunw Girish Manwani (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: