Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1994

Generic behavior is not correct.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Won't Fix
    • 1.1-beta-2
    • 1.1-beta-3
    • None
    • None
    • Windows 2000
      Groovy Version: 1.1-beta-2
       JVM: 1.5.0_08-b03

    Description

      public class GenericTest<T> {
      private T t
      public GenericTest(T t)

      { this.t=t }

      public void print()

      { println t }

      public static void main(String[] args)

      { GenericTest<String> t = new GenericTest<String>(new Date()) //should be thrown a exception t.print() }

      }

      The code: GenericTest<String> t = new GenericTest<String>(new Date()) should be thrown a exception due to Date is not a String type.
      But it can run normally.

      The issue also existed the following code snippet,

      List<String> list = new ArrayList<String>()
      list.add(new Date())

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            tiger_shark Tiger Shark
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: