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

Valid generics code does not compile

    Details

    • Subcomponent:
    • Resolved In Build:
      b71
    • CPU:
      x86
    • OS:
      linux, windows_xp
    • Verification:
      Verified

      Backports

        Description

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


        A DESCRIPTION OF THE PROBLEM :
        Valid generics code does not compile under certain conditions

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Try to compile the code given.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The code should compile
        ACTUAL -
        The code does not compile

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        tests/CompileTest2.java:26: <R,W>test(java.util.Collection<R>) in tests.CompileTest2.RequestMap<java.lang.Object> cannot be applied to <tests.CompileTest2.DeltaRequest,double[]>(java.util.Collection<tests.CompileTest2.DeltaRequest>)
                        DeltaRequest o = m.<DeltaRequest, double[]>test (c);
                                          ^
        1 error


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        package tests;

        import java.util.Collection;
        import java.util.Collections;

        public class CompileTest2 {

        class Request<R extends Request<R, V>,V> {}

        class DeltaRequest extends Request<DeltaRequest, double[]> {}

        class RequestMap<V> {
        public <R extends Request<R, W>, W extends V> R test (Collection<R> c) {
        // In my real code I make use of W of course
        return null;
        }

        }

        public void f () {
        RequestMap<Object> m = new RequestMap<Object> ();
        Collection<DeltaRequest> c = Collections.singleton (new DeltaRequest ());
        // This line not compile?
        DeltaRequest o = m.<DeltaRequest, double[]>test (c);
        }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Remove the type parameter V from RequestMap

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ahe Peter Ahe
                  Reporter:
                  ndcosta Nelson Dcosta (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: