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

generate-proxy produces unpredictable method order in generated classes

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects versions: Release 1.9, Release 1.8
    • Fix versions: Release 1.11
    • Labels:
    • Environment:

      OSX, OpenJDK 8

    • Approval:
      Screened
    • Patch:
      Code

      Description

      Using core/proxy to generate proxies for Java classes produces unpredictable method ordering in the generated class files.
      This is a problem for repeatable builds (when doing AOT).

      Specifically, I'm running Clojure inside Docker, and I'd like my application image layer to be as small as those produced by Java developers (using Meta-inf classpaths and a lib directory). Anyway, to get this working properly so that all dependencies (including those compiled as part of AOT) are on a separate layer, I need the output of compiling my applications' dependencies' proxies to be the same each time I run the build. This reduces build time, image push time, image pull time and container scheduling time.

      Example code that exhibits the problem (you'll need to run it a few times to see the issue).

      https://github.com/kipz/predictable-proxies

      Cause: I've tracked it down to the use of an unsorted map here:

      https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_proxy.clj#L186

      Approach: Use a sorted map, sorted by hash of the key (which is a vector of method name, seq of param types, and return type).

      Patch: CLJ-1973-v5.patch

      Screened by: Alex Miller

        Attachments

        1. CLJ-1973-v1.patch
          2 kB
        2. CLJ-1973-v2.patch
          2 kB
        3. CLJ-1973-v3.patch
          2 kB
        4. CLJ-1973-v4.patch
          2 kB
        5. CLJ-1973-v5.patch
          2 kB

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              kipz James Carnegie
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: