Uploaded image for project: 'Clojure'
  1. CLJ-2379

`proxy` fails with redefined interfaces

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: None
    • Fix versions: None
    • Labels:
    • Approval:
      Triaged
    • Patch:
      Code

      Description

      Before patch:

      user=> (definterface I (f []))
      user.I
      user=> (def p (proxy [Object I] [] (f [] 1)))
      #'user/p
      user=> (definterface I (f []))
      user.I
      user=> (def p (proxy [Object I] [] (f [] 1)))
      #'user/p
      user=> (.f ^I p)
      
      ClassCastException user.proxy$java.lang.Object$I$383c225e cannot be cast to user.I  user$eval7491.invokeStatic (:1)
      

      After patch:

      user=> (definterface I (f []))
      user.I
      user=> (def p (proxy [Object I] [] (f [] 1)))
      #'user/p
      user=> (definterface I (f []))
      user.I
      user=> (def p (proxy [Object I] [] (f [] 1)))
      #'user/p
      user=> (.f ^I p)
      1
      

      Cause: `proxy` caches the generated class using a set of classnames (see https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_proxy.clj#L280-L286), this is not safe under redefinition of interfaces

      Proposed: change the hashing function used to determine proxy class cache hits to take into account the identity of each interface/super class rather than just their name

      Patch: 0001-CLJ-2379-idempotent-proxy-name-just-on-identical-ins-v2.patch

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bronsa Nicola Mometto
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: