groovy
  1. groovy
  2. GROOVY-2801

Override toString in coerced Map fails for interfaces but is ok for concrete classes

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Issue Links

        Activity

        blackdrag blackdrag made changes -
        Field Original Value New Value
        Fix Version/s 1.5.7 [ 14242 ]
        Fix Version/s 1.6-beta-2 [ 14261 ]
        Guillaume Laforge made changes -
        Fix Version/s 1.5.8 [ 14630 ]
        Fix Version/s 1.6-beta-2 [ 14261 ]
        Fix Version/s 1.5.7 [ 14242 ]
        Hide
        Roshan Dawrani added a comment -

        Currently, the delegate for the proxy created, when a map of closures is coerced into an interface, treats methods of java.lang.Object class a little differently. Such methods are not relayed to the map of closures that is being coerced. Instead they are called on the proxy delegate itself.

        If toString() is to be excused from this behavior, the attached patch can probably be used for it (for 1.5.8).

        rgds,
        Roshan

        Show
        Roshan Dawrani added a comment - Currently, the delegate for the proxy created, when a map of closures is coerced into an interface, treats methods of java.lang.Object class a little differently. Such methods are not relayed to the map of closures that is being coerced. Instead they are called on the proxy delegate itself. If toString() is to be excused from this behavior, the attached patch can probably be used for it (for 1.5.8). rgds, Roshan
        Roshan Dawrani made changes -
        Attachment 2801Patch.txt [ 37600 ]
        Hide
        Roshan Dawrani added a comment -

        Hi,
        Wanted to check if I can go ahead with the solution suggested in the previous comment.

        Currently, the way "mapOfClosures as AnInterface" works is that, if it receives a call to the method that is present on java.lang.Object, the implementation provided in mapOfClosures is not used.

        If overriding of toString() is to be allowed, while checking if can handle toString() a little differently from other methods of java.lang.Object so that it is dispatched to mapOfClosures.

        Show
        Roshan Dawrani added a comment - Hi, Wanted to check if I can go ahead with the solution suggested in the previous comment. Currently, the way "mapOfClosures as AnInterface" works is that, if it receives a call to the method that is present on java.lang.Object, the implementation provided in mapOfClosures is not used. If overriding of toString() is to be allowed, while checking if can handle toString() a little differently from other methods of java.lang.Object so that it is dispatched to mapOfClosures.
        Hide
        blackdrag blackdrag added a comment -

        sounds reasonable to me... in fact I don't remember why we checked for methods declared on Object

        Show
        blackdrag blackdrag added a comment - sounds reasonable to me... in fact I don't remember why we checked for methods declared on Object
        Paul King made changes -
        Link This issue is related to GROOVY-2599 [ GROOVY-2599 ]
        Hide
        Paul King added a comment -

        Linking another toString() issue. Probably solved by different changes but we should think about consistency between them.

        Show
        Paul King added a comment - Linking another toString() issue. Probably solved by different changes but we should think about consistency between them.
        Roshan Dawrani made changes -
        Assignee Roshan Dawrani [ roshandawrani ]
        Hide
        Roshan Dawrani added a comment -

        Fixed. Now allows overriding toString() in a 'map-of-closures as AnInterface' implementation.

        Show
        Roshan Dawrani added a comment - Fixed. Now allows overriding toString() in a 'map-of-closures as AnInterface' implementation.
        Roshan Dawrani made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.6-rc-1 [ 14009 ]
        Fix Version/s 1.7-beta-1 [ 14014 ]
        Resolution Fixed [ 1 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Maurice Nicholson
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: