tools.analyzer

Different reflection warning from Clojure 1.6 for compiling interop expression directly vs. after emitting from t.a(.jvm)

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Latest t.a(.jvm) as of today (after TANAL-75 commit), Clojure 1.6.0, latest Eastwood as of today, latest version of 'fs' project as of Jan 29 2014 (and today):

% lein with-profile +1.6 eastwood '{:namespaces [ me.raynes.fs ]}'
Reflection warning, clojure/data/priority_map.clj:215:19 - call to method equiv on java.lang.Object can't be resolved (no such method).
Reflection warning, clojure/core/memoize.clj:72:23 - reference to field cache can't be resolved.
== Eastwood 0.1.2-SNAPSHOT Clojure 1.6.0 JVM 1.7.0_51
== Linting me.raynes.fs ==
Reflection warning, me/raynes/fs.clj:156:23 - reference to field toUrl on java.io.File can't be resolved.
Reflection warning, me/raynes/fs.clj:489:42 - reference to field getName can't be resolved.

It is the warning about 'reference to field toUrl' that is different here than when you run 'lein check', when the corresponding warning output line is:

Reflection warning, me/raynes/fs.clj:156:23 - call to toUrl can't be resolved.

I think that 'lein check' is warning about the macroexpanded version (. (. this (toFile)) (toUrl)), but t.a(.jvm) is emitting the form (.toUrl (.toFile this)).

Activity

Hide
Nicola Mometto added a comment -

There's nothing much I can do for the cases where tools.analyzer.jvm avoids some reflection that clojure does.

It's an enhancement that tools.analyzer.jvm provides over the current Clojure and I'd frankly consider this a bug of clojure if it cannot statically figure out the types of simple expressions like (.. this (toFile) (toUrl))

Show
Nicola Mometto added a comment - There's nothing much I can do for the cases where tools.analyzer.jvm avoids some reflection that clojure does. It's an enhancement that tools.analyzer.jvm provides over the current Clojure and I'd frankly consider this a bug of clojure if it cannot statically figure out the types of simple expressions like (.. this (toFile) (toUrl))
Hide
Andy Fingerhut added a comment -

Sorry for the noise. I think I see what you mean now. However, I would point out that this is a case where Clojure gives a reflection warning on the original code, and also on the code emitted by t.a(.jvm), but at least with Clojure 1.6.0 it is a different warning, simply because the Java interop form is different in the two cases. I think this is due to ambiguity in Java interop between whether (. symbol instance) means that symbol is a Java field, or a no-arg method.

Show
Andy Fingerhut added a comment - Sorry for the noise. I think I see what you mean now. However, I would point out that this is a case where Clojure gives a reflection warning on the original code, and also on the code emitted by t.a(.jvm), but at least with Clojure 1.6.0 it is a different warning, simply because the Java interop form is different in the two cases. I think this is due to ambiguity in Java interop between whether (. symbol instance) means that symbol is a Java field, or a no-arg method.
Hide
Nicola Mometto added a comment -

Oh, sorry, I misread the description.
I'll look into this then

Show
Nicola Mometto added a comment - Oh, sorry, I misread the description. I'll look into this then
Hide
Nicola Mometto added a comment -

Ok so, still nothing we can do.
tools.analyzer.jvm macroexpands the . form differntly than clojure, but it's still a valid expansion.

Anyway, looking into why this causes a reflection warning I discovered that the fs library has a typo in there, the method is called "toURL" rather then "toUrl"

Show
Nicola Mometto added a comment - Ok so, still nothing we can do. tools.analyzer.jvm macroexpands the . form differntly than clojure, but it's still a valid expansion. Anyway, looking into why this causes a reflection warning I discovered that the fs library has a typo in there, the method is called "toURL" rather then "toUrl"

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: