• Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects versions: Release 1.10
    • Fix versions: Release 1.10
    • Labels:
    • Approval:
    • Patch:


      The JDK now has a clearer policy regarding API deprecations. Currently, there are 6 deprecated call sites in Clojure as of Java 11:

      # build local self-contained jar (use Java 8 to match current baseline)
      mvn -Plocal -Dmaven.test.skip=true package
      # run jdeprscan tool to find deprecations (use Java 11 to get furthest report)
      jdeprscan --release 11 clojure.jar
      class clojure/pprint$translate_param uses deprecated method java/lang/Integer::<init>(Ljava/lang/String;)V 
      class clojure/java/browse_ui$open_url_in_swing uses deprecated method java/awt/Window::show()V
      class clojure/core$mix_collection_hash uses deprecated method java/lang/Long::<init>(J)V
      class clojure/core$hash_ordered_coll uses deprecated method java/lang/Long::<init>(J)V
      class clojure/core$hash_unordered_coll uses deprecated method java/lang/Long::<init>(J)V
      class clojure/lang/DynamicClassLoader uses deprecated method java/lang/ClassLoader::getPackage(Ljava/lang/String;)Ljava/lang/Package;

      The first two occur in clj files, and have clear replacement calls. The patch makes these replacements.

      The next three (the Long(long) constructors) are emitted by the compiler via asm's GeneratorAdapter while boxing invokeStatic and invokePrim. The Long constructors were deprecated in JDK9 [1], with the note that Hotspot intrinsifies the preferred call (Long/valueOf). GeneratorAdapter also has a valueOf() method so in the case of long/double returns, this is used instead (and otherwise it falls back to prior behavior).

      Addressing all of the above remains compatible with JDK8. The last issue is reported as of JDK 9. It recommends using getDefinedPackage instead, but that method does not exist until JDK 9 and we are using a JDK 8 baseline, so no change was made. (The method still exists through Java 11 and has not been removed.)

      Patch: clj-2375-2.patch




            • Assignee:
              gshayban Ghadi Shayban
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: