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

1 == new Object() throws ClassCastException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.7.0
    • 1.6.8, 1.7.1, 1.8-beta-1
    • None
    • None
    • tested for 1.7.0 and 1.6.0

    Description

      Example 1:

      assertFalse(new Object() == 1) // this is ok
      assertFalse(1 == new Object()) // this throws a ClassCastException, because Groovy redirects the call to java.lang.Integer.compareTo(Integer i)

      Example 2:

      enum MyEnum

      { A, B, C }

      assertFalse(new Object() == MyEnum.A) // this is ok
      assertFalse(MyEnum.A == new Object()) // this throws a ClassCastException, because Groovy redirects the call to java.lang.Enum.compareTo(E e) where E extends java.lang.Enum<E>

      Attachments

        Issue Links

          Activity

            People

              roshandawrani Roshan Dawrani
              cptnuss Armin Weisser
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: