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

Some static initialisers still run at compile time if used in type hints

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Completed
    • Affects versions: None
    • Fix versions: Release 1.9
    • Approval:
      Ok
    • Patch:
      Code and Test

      Description

      AOT compiling on an x86 machine to be run on an ARM machine when a Java dependency has a native component and the class with the native dependency is used in a type hint.

      In this situation, the only native library available on the classpath is the ARM dependency, and obviously won't load on the compiling x86 machine. Java libraries tend to load the native dependencies in the static initialiser of the class, which will fail in this situation as the architecture is x86 and the dependencies are ARM, for which reason CLJ-1315 Closed made the change to not run static initialisers at compile time.

      This covers a case which didn't come up as part of CLJ-1315 Closed , that the same problem occurs if rather than constructing the class, you simply use it as a type hint (which IMO is doubly surprising as something to have a side-effect).

      Approach: Don't cause class to load merely from being in a type hint.

      Patch: clj-1714-4.patch

      This patch has been used in production for over a year with no adverse effects (as has anybody using the clojure-android build of clojure).

      Prescreened: Alex Miller

        Attachments

        1. CLJ-1714-v3.patch
          3 kB
        2. CLJ-1714-v2.patch
          3 kB
        3. clj-1714-4.patch
          4 kB
        4. CLJ-1714.patch
          1 kB

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              adamclements AdamClements
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: