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

javac generics compilation problem

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Cannot Reproduce
    • Affects Version/s: 5.0u6
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      This Code is valid Tiger+ Java:

      public class TestCase<B>
      {
          interface Base
          {
          }

          interface Interface extends Base
          {
          }

          static class Implementation implements Interface
          {
          }

          <T extends B, E extends T> E returnArg(Class<T> c, E e)
          {
              // do something with c
              return e;
          }

          public static void main(String[] args)
          {
              TestCase<Base> tc = new TestCase<Base>();
              tc.returnArg(Interface.class, new Implementation());
          }
      }

      but the compiler gives:

      TestCase.java:28: <T,E>returnArg(java.lang.Class<T>,E) in TestCase<TestCase.Base> cannot be applied to (java.lang.Class<TestCase.Interface>,TestCase.Implementation)
              tc.returnArg(Interface.class, new Implementation());
                ^
      1 error

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: