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

Report warnings if *unchecked-math* and boxing happens


    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Completed
    • Affects versions: Release 1.6
    • Fix versions: Release 1.7
    • Labels:
    • Approval:
    • Patch:
      Code and Test


      Currently, it is difficult to tell that the compiler is using boxed math unless you look at the generated bytecode. The proposed enhancement here is to emit new warnings if *unchecked-math* is on and boxed math is occurring.

      Approach: In the compiler, when compiling a StaticMethodExpr, if *unchecked-math* is true and the class is clojure.lang.Numbers and one of the parameters of static method is of type java.lang.Object or java.lang.Number, then emit a warning at compile-time.

      In addition, there is a new WarnBoxedMath Java annotation - a small number of methods on Numbers with Object parameters use this annotation to indicate that warning should not take place. The same annotation can be (but is not currently) used to mark methods on Numbers without Object/Number params that should warn. See boxedmath.txt for a list of methods and categories.

      Patch: clj-1325-v3.patch

      Screened by:


        1. boxed.diff
          6 kB
        2. boxedmath.txt
          9 kB
        3. clj-1325.patch
          11 kB
        4. clj-1325-v2.patch
          11 kB
        5. clj-1325-v3.patch
          11 kB



            • Assignee:
              alexmiller Alex Miller
              alexmiller Alex Miller
            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: