clj-http icon indicating copy to clipboard operation
clj-http copied to clipboard

AOT issues with clj_http.headers.HeaderMap

Open pesterhazy opened this issue 2 years ago • 4 comments

I'm following the guide for using AOT. This works ... except for clj-http.

The error I'm getting is not when compiling but when loading the compiled classes (rather than clj files):

Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:641).
clj_http.headers.HeaderMap

When I rm -rf classes/clj_http, it works again.

Unfortunately I couldn't come up with a simple repro case - when I tried it outside of the main app, it worked. Not sure why - race condition?

I suspect (but cannot prove) that the AOT incompatibility is due to the use of potemkin.

There's an earlier report from 2016, but I'm not using Leiningen https://clojurians.slack.com/archives/C0AB48493/p1469153573000034

clj-http/clj-http 3.12.3
potemkin/potemkin 0.4.5

pesterhazy avatar Oct 16 '23 14:10 pesterhazy

BTW uberjars work fine - the issue happens only when AOT-compiling for development

pesterhazy avatar Oct 16 '23 14:10 pesterhazy

After some investigations, here's what I learned:

• Part of the problem seems to be loading namespaces in user.clj. After stopping to load stuff in user.clj, the problem went away for me (this explains why lein uberjar etc doesn't have the problem)

• Generally what seems to be happening is this: I'm loading clj-http and then compiling it. "Something is loading clj-http before you do the aot compilation, and on the second loading (for aot) potemkins type definition stuff no-ops, so the class doesn't get written to disk"

More discussion here: https://clojurians.slack.com/archives/C03S1KBA2/p1697468125926469

This still seems like a wrinkle in clj-http, though maybe not a bug (maybe in potemkin?)

pesterhazy avatar Oct 17 '23 09:10 pesterhazy

Something is loading clj-http before you do the aot compilation

Could this be something internal to leiningen itself that's loading clj-http?

dakrone avatar Oct 23 '23 23:10 dakrone

I'm using tools.deps for this report. I'm pretty sure the problem is because the lib was loaded in user.clj, then compiled

On Tue 24. Oct 2023 at 01:10, Lee Hinman @.***> wrote:

Something is loading clj-http before you do the aot compilation

Could this be something internal to leiningen itself that's loading clj-http?

— Reply to this email directly, view it on GitHub https://github.com/dakrone/clj-http/issues/638#issuecomment-1776167738, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZ6WEHT3YVQEWFYEVZ6IDYA32N3AVCNFSM6AAAAAA6CKWF62VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZWGE3DONZTHA . You are receiving this because you authored the thread.Message ID: @.***>

pesterhazy avatar Oct 25 '23 16:10 pesterhazy