[CLJ-1066] No dependency on jsr166y Created: 11/Sep/12 Updated: 20/Oct/12 Resolved: 20/Oct/12 |
|
| Status: | Closed |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.5 |
| Fix Version/s: | Release 1.5 |
| Type: | Defect | Priority: | Major |
| Reporter: | Wolodja Wentland | Assignee: | Stuart Halloway |
| Resolution: | Completed | Votes: | 4 |
| Labels: | patch | ||
| Environment: |
$ java -version |
||
| Attachments: |
|
| Patch: | Code |
| Approval: | Ok |
| Description |
|
The Clojure 1.5.0-alpha4 jars that have been deployed to maven.org seem to have been compiled against JDK6 which causes — snip — user=> (require '[clojure.core.reducers :as r]) ;; JDK7 + clojure 1.5.0-alpha4 from maven.org user=> (r/fold + (r/map inc v)) ;; JDK7 + clojure 1.5.0-alpha4 from maven.org user=> (r/fold + (r/map inc v)) ;; JDK7 + clojure 1.5.0-alpha4 locally compiled (mvn install) against OpenJDK7 user=> (r/fold + (r/map inc v)) It would be wonderful if this issue could be fixed before the release of 1.5.0. Have a nice day Wolodja |
| Comments |
| Comment by Tassilo Horn [ 12/Sep/12 9:44 AM ] |
|
That's really a nasty problem. I wrote the code that makes it possible to compile clojure with either a JDK7 and native ForkJoin or an older JDK + jsr166y. Unfortunately, if you build clojure with a JDK7, reducers' fold requires a JDK7 at runtime, and if you build clojure with a JDK <7 + jsr166y, fold also requires jsr166y at runtime. The essential problem is that clojure is AOT-compiled to class-files and those are put into the release jars. Ordinary clojure libraries are distributed as jar files containing clj files that are compiled when loaded. There, the implemented approach works just fine. For example, again your example with 1.5.0-alpha4: ;; 1.5.0-master4 compiled with JDK6 + jsr166y running on a JDK7 user=> (require '[clojure.core.reducers :as r]) nil user=> (def v (vec (range 10000))) #'user/v user=> (r/fold + (r/map inc v)) ClassNotFoundException jsr166y.ForkJoinTask java.net.URLClassLoader$1.run (URLClassLoader.java:366) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Now load the reducers.clj source code again, so that it ;; picks the right ForkJoin-impl for the current platform (load-file "/home/horn/Repos/clj/clojure/src/clj/clojure/core/reducers.clj") nil user=> (r/fold + (r/map inc v)) 50005000 So IMO, the best thing we can do is to omit AOT-compilation for reducers but to include only its clj file so that it'll be compiled automatically on the platform it eventually runs. |
| Comment by Tassilo Horn [ 12/Sep/12 11:55 AM ] |
|
This patch removes the clojure.core.reducers namespace from the namespaces to be AOT compiled. So now this namespace will be JIT-compiled when being required, and at that point either the JDK7 ForkJoin classes or the jsr166y classes need to be there. |
| Comment by Stuart Halloway [ 21/Sep/12 1:31 PM ] |
|
Rich: what is the right approach here? |