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

REGRESSION: removal of "rvalue conversion" causes problems

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 6
    • 6
    • tools
    • b73
    • 6
    • b86
    • x86
    • windows_xp
    • Verified

    Description

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

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

      A DESCRIPTION OF THE PROBLEM :
      When I test my code with 1.6.0-beta2-b73, a new compiler error was introduced to my code.
      ####
      import java.util.Iterator;
      import java.util.List;

      public class GenericsTest<A> {
        
        interface Factory<T> {
          T invoke();
        }

        public static <E> Iterator<E> iterate(Iterable<E> iterable) {
          return iterable.iterator();
        }

        public Factory<Iterator<? extends A>> factory(final Factory<? extends List<? extends A>> factory) {
          return new Factory<Iterator<? extends A>>() {
            public Iterator<? extends A> invoke() {
              return iterate(factory.invoke());
            }
          };
        }
      }
      ####
      Removing one of the '? extends ...' parts in the declaration of the parameter factory
        public Factory<Iterator<? extends A>> factory(final Factory<List<? extends A>> factory)
      or
        public Factory<Iterator<? extends A>> factory(final Factory<? extends
      List<A>> factory)
      or calling the iterator method directly on the generated object
        return factory.invoke().iterator();
      causes 1.6.0-beta2-b73 to remove the error.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Simply try to compile the specified code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The code should be compiled without errors.
      ACTUAL -
      The code produces the specified error.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Test.java:17: <E>iterate(java.lang.Iterable<E>) in Test<A> cannot be applied to
      (capture#276 of ? extends java.util.List<? extends A>)
              return iterate(factory.invoke());
                     ^
      1 error

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class GenericsTest<A> {
        
        interface Factory<T> {
          T invoke();
        }

        public static <E> Iterator<E> iterate(Iterable<E> iterable) {
          return iterable.iterator();
        }

        public Factory<Iterator<? extends A>> factory(final Factory<? extends List<? extends A>> factory) {
          return new Factory<Iterator<? extends A>>() {
            public Iterator<? extends A> invoke() {
              return iterate(factory.invoke());
            }
          };
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Removing one of the '? extends ...' parts in the declaration of the parameter factory
        public Factory<Iterator<? extends A>> factory(final Factory<List<? extends A>> factory)
      or
        public Factory<Iterator<? extends A>> factory(final Factory<? extends
      List<A>> factory)
      or calling the iterator method directly on the generated object
        return factory.invoke().iterator();
      causes 1.6.0-beta2-b73 to remove the error.

      Release Regression From : 5.0
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      Attachments

        Issue Links

          Activity

            People

              ahe Peter Ahe
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: