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

        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
        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
        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.
        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.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: