Uploaded image for project: 'core.typed'
  1. CTYP-283

Directly-linking in Clojure 1.8.0 interferes with load monkey-patching

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects versions: None
    • Fix versions: 0.3.20, 0.3.15
    • Components: Clojure Checker
    • Labels:
      None

      Description

      Clojure 1.8.0's jar contains clojure.core with directly linked vars.

      This means our trick of monkey-patching `load` no longer works.

      Instead, we must also monkey-patch `require` and `use`, and completely
      copy their implementations.

      20 November 2015 reopen

      clojure.core/compile similarly uses `load`. It's safe to insert core.typed into this pipeline because we pass the results of type checking to Compiler.java anyway, so the results of type checking can be AOT compiled.

      End reopen

      Future Revert (Completed, see 27th January changes)

      Ideally CLJ-1845 fixes the original problem, but it is not clear if it actually does.

      user=> (alter-var-root #'load (fn [f] (fn [& args] (prn "patched") (apply f args))))
      #object[user$eval1241$fn__1242$fn__1243 0x1c857e6 "user$eval1241$fn__1242$fn__1243@1c857e6"]
      user=> (load)
      "patched"
      nil
      user=> (require 'clojure.core :reload)
      nil
      user=> (require 'clojure.tools.analyzer :reload)
      nil
      user=> (require 'clojure.tools.analyzer :reload-all)
      nil
      

      This should print "patched" after every `require`.

      Pull request: 72
      Commit: fe7ae4a
      Release: 0.3.15

      20 November reopen

      Pull request: 87
      Commit: 9cd4f720
      Release: 0.3.20

      End 20 November reopen

      27 Jan 2015 Revert

      Now Clojure 1.8.0 is released and there are no direct-linking issues, we can revert both patches.

      Pull request: 91
      Commits: 6b92bb 9eb6c9
      Release: 0.3.20

      End 27 Jan 2015 Revert

        Attachments

          Activity

            People

            • Assignee:
              ambrosebs Ambrose BS
              Reporter:
              ambrosebs Ambrose BS
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: