Clojure

Namespace is not loaded on defrecord class init

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.8
  • Component/s: None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

Screened: Approach 2, which makes loading the namespace optional. This makes the change purely additive, whereas Approach 1 changes semantics (load ordering) of existing programs. I don't know why we would want that risk, especially when it is not clear that most users of deftype would even want ns loading side effect.

Approach 1: require the namespace a record/type belongs to during the record/type class init
Patch: 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5-no-opts.patch

Approach 2: like Approach 1 but does the automatic loading only when a :load-ns option is set to true in the deftype/defrecord
Patch: 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5.patch

Note: patch for Approach 1 causes some generative tests to fail since the namespace used to evalaute a defrecord is immediately destroyed thus impossible to load

Activity

Hide
Nicola Mometto added a comment -

The attached patch approaches this issue by adding a :load-ns options to deftype/defrecord which defaults to false.
When true, the type/record be compiled with a call to clojure.core/require to its originating namespace in its static initializer.

The patch has two known limitations:

  • clojure.core deftypes/defrecords cannot have :load-ns since we use clojure.core/require to load the namespaces so clojure.core needs to be loaded manually anyway
  • clojure.lang.Compiler/demunge is used to get the originating namespace from the deftype/defrecord class name, this means that namespaces like foo_bar are not supported since they get demunged into foo-bar. If this is something that needs to be addressed, it shouldn't be too hard to just pass the unmunged namespace name in the opts map.
Show
Nicola Mometto added a comment - The attached patch approaches this issue by adding a :load-ns options to deftype/defrecord which defaults to false. When true, the type/record be compiled with a call to clojure.core/require to its originating namespace in its static initializer. The patch has two known limitations:
  • clojure.core deftypes/defrecords cannot have :load-ns since we use clojure.core/require to load the namespaces so clojure.core needs to be loaded manually anyway
  • clojure.lang.Compiler/demunge is used to get the originating namespace from the deftype/defrecord class name, this means that namespaces like foo_bar are not supported since they get demunged into foo-bar. If this is something that needs to be addressed, it shouldn't be too hard to just pass the unmunged namespace name in the opts map.
Hide
Nicola Mometto added a comment -

Updated patch fixing a whitespace error and mentionint :load-ns in the docstrings of deftype/defrecord

Show
Nicola Mometto added a comment - Updated patch fixing a whitespace error and mentionint :load-ns in the docstrings of deftype/defrecord
Hide
Nicola Mometto added a comment -

Updated patch so it applies on lastest HEAD

Show
Nicola Mometto added a comment - Updated patch so it applies on lastest HEAD
Hide
Michael Blume added a comment -

No longer applies I'm afraid

Show
Michael Blume added a comment - No longer applies I'm afraid
Hide
Nicola Mometto added a comment -

Thanks Michael, updated the patch. I have to say it's getting kind of annoying having to maintain a patch for months without any feedback.

Show
Nicola Mometto added a comment - Thanks Michael, updated the patch. I have to say it's getting kind of annoying having to maintain a patch for months without any feedback.
Hide
Alex Miller added a comment -

What are the negative impacts if this is always done, rather than being an option?

Show
Alex Miller added a comment - What are the negative impacts if this is always done, rather than being an option?
Hide
Alex Miller added a comment -

Also, you should never rely on demunge - it's best-effort for printing purposes only.

Show
Alex Miller added a comment - Also, you should never rely on demunge - it's best-effort for printing purposes only.
Hide
Nicola Mometto added a comment -

Does extra bytecode emitted count as a negative impact?

Show
Nicola Mometto added a comment - Does extra bytecode emitted count as a negative impact?
Hide
Alex Miller added a comment -

No, I'm not concerned about that.

Show
Alex Miller added a comment - No, I'm not concerned about that.
Hide
Nicola Mometto added a comment -

Attached patch that doesn't use demunge but change the macroexpansion of defrecord and deftype to include the namespace segment in the tagsym in deftype* special form

Show
Nicola Mometto added a comment - Attached patch that doesn't use demunge but change the macroexpansion of defrecord and deftype to include the namespace segment in the tagsym in deftype* special form
Hide
Nicola Mometto added a comment -

Alex, I attached two versions of the last patch, one with :load-ns and one without.
Making :load-ns the default behaviour causes some generative tests to fail since they immediately eliminate the namespace used to defrecord making the record class fail when trying to load said namespace.

I can try to change those tests if necessary.

Show
Nicola Mometto added a comment - Alex, I attached two versions of the last patch, one with :load-ns and one without. Making :load-ns the default behaviour causes some generative tests to fail since they immediately eliminate the namespace used to defrecord making the record class fail when trying to load said namespace. I can try to change those tests if necessary.
Hide
Michael Blume added a comment -

v5-no-opts breaks generative tests on my box:

test-generative:
     [java] java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError, compiling:(/Users/michael.blume/workspace/clojure/src/script/run_test_generative.clj:5:1)
     [java] 	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
     [java] 	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
     [java] 	at clojure.core$deref_future.invoke(core.clj:2186)
     [java] 	at clojure.core$future_call$reify__6736.deref(core.clj:6683)
     [java] 	at clojure.core$deref.invoke(core.clj:2206)
     [java] 	at clojure.core$map$fn__4553.invoke(core.clj:2622)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:56)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.core$seq__4128.invoke(core.clj:137)
     [java] 	at clojure.core$concat$cat__4217$fn__4218.invoke(core.clj:700)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.ChunkedCons.chunkedNext(ChunkedCons.java:59)
     [java] 	at clojure.core$chunk_next.invoke(core.clj:673)
     [java] 	at clojure.core.protocols$fn__6518.invoke(protocols.clj:139)
     [java] 	at clojure.core.protocols$fn__6478$G__6473__6487.invoke(protocols.clj:19)
     [java] 	at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
     [java] 	at clojure.core.protocols$fn__6506.invoke(protocols.clj:101)
     [java] 	at clojure.core.protocols$fn__6452$G__6447__6465.invoke(protocols.clj:13)
     [java] 	at clojure.core$reduce.invoke(core.clj:6519)
     [java] 	at clojure.test.generative.runner$run_suite.invoke(runner.clj:185)
     [java] 	at clojure.test.generative.runner$_main.doInvoke(runner.clj:208)
     [java] 	at clojure.lang.RestFn.invoke(RestFn.java:408)
     [java] 	at user$eval644.invoke(run_test_generative.clj:5)
     [java] 	at clojure.lang.Compiler.eval(Compiler.java:6797)
     [java] 	at clojure.lang.Compiler.load(Compiler.java:7242)
     [java] 	at clojure.lang.Compiler.loadFile(Compiler.java:7180)
     [java] 	at clojure.main$load_script.invoke(main.clj:275)
     [java] 	at clojure.main$script_opt.invoke(main.clj:337)
     [java] 	at clojure.main$main.doInvoke(main.clj:421)
     [java] 	at clojure.lang.RestFn.invoke(RestFn.java:408)
     [java] 	at clojure.lang.Var.invoke(Var.java:379)
     [java] 	at clojure.lang.AFn.applyToHelper(AFn.java:154)
     [java] 	at clojure.lang.Var.applyTo(Var.java:700)
     [java] 	at clojure.main.main(main.java:37)
     [java] Caused by: java.lang.ExceptionInInitializerError, compiling:(/Users/michael.blume/workspace/clojure/src/script/run_test_generative.clj:5:1)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6745)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6500)
     [java] 	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5880)
     [java] 	at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5311)
     [java] 	at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3925)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6736)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6726)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.access$300(Compiler.java:38)
     [java] 	at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:578)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6738)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6726)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6500)
     [java] 	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5878)
     [java] 	at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6194)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6738)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6500)
     [java] 	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5880)
     [java] 	at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5311)
     [java] 	at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3925)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6736)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.eval(Compiler.java:6794)
     [java] 	at clojure.lang.Compiler.eval(Compiler.java:6760)
     [java] 	at clojure.core$eval.invoke(core.clj:3081)
     [java] 	at clojure.test_clojure.generators$generate_namespaces$make_in_ns__830.invoke(generators.clj:30)
     [java] 	at clojure.test_clojure.generators$generate_namespaces$fn__836$fn__837.invoke(generators.clj:41)
     [java] 	at clojure.core$map$fn__4553.invoke(core.clj:2622)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.core$seq__4128.invoke(core.clj:137)
     [java] 	at clojure.core$concat$fn__4215.invoke(core.clj:691)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.core$seq__4128.invoke(core.clj:137)
     [java] 	at clojure.core$concat$cat__4217$fn__4218.invoke(core.clj:700)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.core$seq__4128.invoke(core.clj:137)
     [java] 	at clojure.core.protocols$seq_reduce.invoke(protocols.clj:30)
     [java] 	at clojure.core.protocols$fn__6506.invoke(protocols.clj:101)
     [java] 	at clojure.core.protocols$fn__6452$G__6447__6465.invoke(protocols.clj:13)
     [java] 	at clojure.core$reduce.invoke(core.clj:6519)
     [java] 	at clojure.core$into.invoke(core.clj:6600)
     [java] 	at clojure.test_clojure.generators$generate_namespaces.invoke(generators.clj:44)
     [java] 	at clojure.test_clojure.generators$fn__841.invoke(generators.clj:50)
     [java] 	at clojure.lang.Delay.deref(Delay.java:37)
     [java] 	at clojure.core$deref.invoke(core.clj:2206)
     [java] 	at clojure.test_clojure.generators$var.invoke(generators.clj:58)
     [java] 	at clojure.test.generative.runner$eval559$fn__560$fn__561$fn__562$fn__563.invoke(runner.clj:66)
     [java] 	at clojure.core$map$fn__4553.invoke(core.clj:2622)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.core$seq__4128.invoke(core.clj:137)
     [java] 	at clojure.core.protocols$seq_reduce.invoke(protocols.clj:30)
     [java] 	at clojure.core.protocols$fn__6506.invoke(protocols.clj:101)
     [java] 	at clojure.core.protocols$fn__6452$G__6447__6465.invoke(protocols.clj:13)
     [java] 	at clojure.core$reduce.invoke(core.clj:6519)
     [java] 	at clojure.core$into.invoke(core.clj:6600)
     [java] 	at clojure.test.generative.runner$eval559$fn__560$fn__561$fn__562.invoke(runner.clj:66)
     [java] 	at clojure.core$repeatedly$fn__5111.invoke(core.clj:4921)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.lang.RT.nthFrom(RT.java:924)
     [java] 	at clojure.lang.RT.nth(RT.java:883)
     [java] 	at clojure.test.generative.runner$run_one$fn__588$fn__589$fn__590.invoke(runner.clj:94)
     [java] 	at clojure.test.generative.runner$run_one$fn__588$fn__589.invoke(runner.clj:93)
     [java] 	at clojure.core$binding_conveyor_fn$fn__4444.invoke(core.clj:1916)
     [java] 	at clojure.lang.AFn.call(AFn.java:18)
     [java] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
     [java] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
     [java] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
     [java] 	at java.lang.Thread.run(Thread.java:745)
     [java] Caused by: java.lang.ExceptionInInitializerError
     [java] 	at java.lang.Class.forName0(Native Method)
     [java] 	at java.lang.Class.forName(Class.java:344)
     [java] 	at clojure.lang.RT.classForName(RT.java:2154)
     [java] 	at clojure.lang.RT.classForName(RT.java:2163)
     [java] 	at clojure.lang.Compiler$HostExpr.maybeClass(Compiler.java:1017)
     [java] 	at clojure.lang.Compiler$HostExpr.access$600(Compiler.java:795)
     [java] 	at clojure.lang.Compiler$NewExpr$Parser.parse(Compiler.java:2609)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6738)
     [java] 	... 82 more
     [java] Caused by: java.io.FileNotFoundException: Could not locate clojure/generated/ns0__init.class or clojure/generated/ns0.clj on classpath.
     [java] 	at clojure.lang.RT.load(RT.java:449)
     [java] 	at clojure.lang.RT.load(RT.java:412)
     [java] 	at clojure.core$load$fn__5448.invoke(core.clj:5866)
     [java] 	at clojure.core$load.doInvoke(core.clj:5865)
     [java] 	at clojure.lang.RestFn.invoke(RestFn.java:408)
     [java] 	at clojure.core$load_one.invoke(core.clj:5671)
     [java] 	at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
     [java] 	at clojure.core$load_lib.doInvoke(core.clj:5710)
     [java] 	at clojure.lang.RestFn.applyTo(RestFn.java:142)
     [java] 	at clojure.core$apply.invoke(core.clj:632)
     [java] 	at clojure.core$load_libs.doInvoke(core.clj:5749)
     [java] 	at clojure.lang.RestFn.applyTo(RestFn.java:137)
     [java] 	at clojure.core$apply.invoke(core.clj:632)
     [java] 	at clojure.core$require.doInvoke(core.clj:5832)
     [java] 	at clojure.lang.RestFn.invoke(RestFn.java:408)
     [java] 	at clojure.generated.ns0.ExampleRecord-0.<clinit>(run_test_generative.clj:5)
     [java] 	... 90 more
Show
Michael Blume added a comment - v5-no-opts breaks generative tests on my box:
test-generative:
     [java] java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError, compiling:(/Users/michael.blume/workspace/clojure/src/script/run_test_generative.clj:5:1)
     [java] 	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
     [java] 	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
     [java] 	at clojure.core$deref_future.invoke(core.clj:2186)
     [java] 	at clojure.core$future_call$reify__6736.deref(core.clj:6683)
     [java] 	at clojure.core$deref.invoke(core.clj:2206)
     [java] 	at clojure.core$map$fn__4553.invoke(core.clj:2622)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:56)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.core$seq__4128.invoke(core.clj:137)
     [java] 	at clojure.core$concat$cat__4217$fn__4218.invoke(core.clj:700)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.ChunkedCons.chunkedNext(ChunkedCons.java:59)
     [java] 	at clojure.core$chunk_next.invoke(core.clj:673)
     [java] 	at clojure.core.protocols$fn__6518.invoke(protocols.clj:139)
     [java] 	at clojure.core.protocols$fn__6478$G__6473__6487.invoke(protocols.clj:19)
     [java] 	at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
     [java] 	at clojure.core.protocols$fn__6506.invoke(protocols.clj:101)
     [java] 	at clojure.core.protocols$fn__6452$G__6447__6465.invoke(protocols.clj:13)
     [java] 	at clojure.core$reduce.invoke(core.clj:6519)
     [java] 	at clojure.test.generative.runner$run_suite.invoke(runner.clj:185)
     [java] 	at clojure.test.generative.runner$_main.doInvoke(runner.clj:208)
     [java] 	at clojure.lang.RestFn.invoke(RestFn.java:408)
     [java] 	at user$eval644.invoke(run_test_generative.clj:5)
     [java] 	at clojure.lang.Compiler.eval(Compiler.java:6797)
     [java] 	at clojure.lang.Compiler.load(Compiler.java:7242)
     [java] 	at clojure.lang.Compiler.loadFile(Compiler.java:7180)
     [java] 	at clojure.main$load_script.invoke(main.clj:275)
     [java] 	at clojure.main$script_opt.invoke(main.clj:337)
     [java] 	at clojure.main$main.doInvoke(main.clj:421)
     [java] 	at clojure.lang.RestFn.invoke(RestFn.java:408)
     [java] 	at clojure.lang.Var.invoke(Var.java:379)
     [java] 	at clojure.lang.AFn.applyToHelper(AFn.java:154)
     [java] 	at clojure.lang.Var.applyTo(Var.java:700)
     [java] 	at clojure.main.main(main.java:37)
     [java] Caused by: java.lang.ExceptionInInitializerError, compiling:(/Users/michael.blume/workspace/clojure/src/script/run_test_generative.clj:5:1)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6745)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6500)
     [java] 	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5880)
     [java] 	at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5311)
     [java] 	at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3925)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6736)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6726)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.access$300(Compiler.java:38)
     [java] 	at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:578)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6738)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6726)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6500)
     [java] 	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5878)
     [java] 	at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6194)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6738)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6500)
     [java] 	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5880)
     [java] 	at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5311)
     [java] 	at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3925)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6736)
     [java] 	at clojure.lang.Compiler.analyze(Compiler.java:6539)
     [java] 	at clojure.lang.Compiler.eval(Compiler.java:6794)
     [java] 	at clojure.lang.Compiler.eval(Compiler.java:6760)
     [java] 	at clojure.core$eval.invoke(core.clj:3081)
     [java] 	at clojure.test_clojure.generators$generate_namespaces$make_in_ns__830.invoke(generators.clj:30)
     [java] 	at clojure.test_clojure.generators$generate_namespaces$fn__836$fn__837.invoke(generators.clj:41)
     [java] 	at clojure.core$map$fn__4553.invoke(core.clj:2622)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.core$seq__4128.invoke(core.clj:137)
     [java] 	at clojure.core$concat$fn__4215.invoke(core.clj:691)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.core$seq__4128.invoke(core.clj:137)
     [java] 	at clojure.core$concat$cat__4217$fn__4218.invoke(core.clj:700)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.core$seq__4128.invoke(core.clj:137)
     [java] 	at clojure.core.protocols$seq_reduce.invoke(protocols.clj:30)
     [java] 	at clojure.core.protocols$fn__6506.invoke(protocols.clj:101)
     [java] 	at clojure.core.protocols$fn__6452$G__6447__6465.invoke(protocols.clj:13)
     [java] 	at clojure.core$reduce.invoke(core.clj:6519)
     [java] 	at clojure.core$into.invoke(core.clj:6600)
     [java] 	at clojure.test_clojure.generators$generate_namespaces.invoke(generators.clj:44)
     [java] 	at clojure.test_clojure.generators$fn__841.invoke(generators.clj:50)
     [java] 	at clojure.lang.Delay.deref(Delay.java:37)
     [java] 	at clojure.core$deref.invoke(core.clj:2206)
     [java] 	at clojure.test_clojure.generators$var.invoke(generators.clj:58)
     [java] 	at clojure.test.generative.runner$eval559$fn__560$fn__561$fn__562$fn__563.invoke(runner.clj:66)
     [java] 	at clojure.core$map$fn__4553.invoke(core.clj:2622)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.core$seq__4128.invoke(core.clj:137)
     [java] 	at clojure.core.protocols$seq_reduce.invoke(protocols.clj:30)
     [java] 	at clojure.core.protocols$fn__6506.invoke(protocols.clj:101)
     [java] 	at clojure.core.protocols$fn__6452$G__6447__6465.invoke(protocols.clj:13)
     [java] 	at clojure.core$reduce.invoke(core.clj:6519)
     [java] 	at clojure.core$into.invoke(core.clj:6600)
     [java] 	at clojure.test.generative.runner$eval559$fn__560$fn__561$fn__562.invoke(runner.clj:66)
     [java] 	at clojure.core$repeatedly$fn__5111.invoke(core.clj:4921)
     [java] 	at clojure.lang.LazySeq.sval(LazySeq.java:40)
     [java] 	at clojure.lang.LazySeq.seq(LazySeq.java:49)
     [java] 	at clojure.lang.RT.seq(RT.java:507)
     [java] 	at clojure.lang.RT.nthFrom(RT.java:924)
     [java] 	at clojure.lang.RT.nth(RT.java:883)
     [java] 	at clojure.test.generative.runner$run_one$fn__588$fn__589$fn__590.invoke(runner.clj:94)
     [java] 	at clojure.test.generative.runner$run_one$fn__588$fn__589.invoke(runner.clj:93)
     [java] 	at clojure.core$binding_conveyor_fn$fn__4444.invoke(core.clj:1916)
     [java] 	at clojure.lang.AFn.call(AFn.java:18)
     [java] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
     [java] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
     [java] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
     [java] 	at java.lang.Thread.run(Thread.java:745)
     [java] Caused by: java.lang.ExceptionInInitializerError
     [java] 	at java.lang.Class.forName0(Native Method)
     [java] 	at java.lang.Class.forName(Class.java:344)
     [java] 	at clojure.lang.RT.classForName(RT.java:2154)
     [java] 	at clojure.lang.RT.classForName(RT.java:2163)
     [java] 	at clojure.lang.Compiler$HostExpr.maybeClass(Compiler.java:1017)
     [java] 	at clojure.lang.Compiler$HostExpr.access$600(Compiler.java:795)
     [java] 	at clojure.lang.Compiler$NewExpr$Parser.parse(Compiler.java:2609)
     [java] 	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6738)
     [java] 	... 82 more
     [java] Caused by: java.io.FileNotFoundException: Could not locate clojure/generated/ns0__init.class or clojure/generated/ns0.clj on classpath.
     [java] 	at clojure.lang.RT.load(RT.java:449)
     [java] 	at clojure.lang.RT.load(RT.java:412)
     [java] 	at clojure.core$load$fn__5448.invoke(core.clj:5866)
     [java] 	at clojure.core$load.doInvoke(core.clj:5865)
     [java] 	at clojure.lang.RestFn.invoke(RestFn.java:408)
     [java] 	at clojure.core$load_one.invoke(core.clj:5671)
     [java] 	at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
     [java] 	at clojure.core$load_lib.doInvoke(core.clj:5710)
     [java] 	at clojure.lang.RestFn.applyTo(RestFn.java:142)
     [java] 	at clojure.core$apply.invoke(core.clj:632)
     [java] 	at clojure.core$load_libs.doInvoke(core.clj:5749)
     [java] 	at clojure.lang.RestFn.applyTo(RestFn.java:137)
     [java] 	at clojure.core$apply.invoke(core.clj:632)
     [java] 	at clojure.core$require.doInvoke(core.clj:5832)
     [java] 	at clojure.lang.RestFn.invoke(RestFn.java:408)
     [java] 	at clojure.generated.ns0.ExampleRecord-0.<clinit>(run_test_generative.clj:5)
     [java] 	... 90 more
Hide
Nicola Mometto added a comment -

Michael, that's already noted in the ticket description and the screened patch is v5.patch, not v5-no-opts.patch

Show
Nicola Mometto added a comment - Michael, that's already noted in the ticket description and the screened patch is v5.patch, not v5-no-opts.patch
Hide
Michael Blume added a comment -

Aha, missed that, sorry

Show
Michael Blume added a comment - Aha, missed that, sorry
Hide
Michael Blume added a comment -

The screened patch seems to break 'lein check' for clj-http

Compiling namespace clj-http.client
Exception in thread "main" java.lang.NoClassDefFoundError: IllegalName: compile__stub.clj_http.headers.clj-http.headers/HeaderMap, compiling:(clj_http/headers.clj:105:1)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6749)
	at clojure.lang.Compiler.analyze(Compiler.java:6543)
	at clojure.lang.Compiler.analyze(Compiler.java:6504)
	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5882)
	at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6198)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6742)
	at clojure.lang.Compiler.analyze(Compiler.java:6543)
	at clojure.lang.Compiler.analyze(Compiler.java:6504)
	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5884)
	at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5315)
	at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3926)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6740)
	at clojure.lang.Compiler.analyze(Compiler.java:6543)
	at clojure.lang.Compiler.eval(Compiler.java:6798)
	at clojure.lang.Compiler.eval(Compiler.java:6790)
	at clojure.lang.Compiler.load(Compiler.java:7246)
	at clojure.lang.RT.loadResourceScript(RT.java:371)
	at clojure.lang.RT.loadResourceScript(RT.java:362)
	at clojure.lang.RT.load(RT.java:446)
	at clojure.lang.RT.load(RT.java:412)
	at clojure.core$load$fn__5448.invoke(core.clj:5866)
	at clojure.core$load.doInvoke(core.clj:5865)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invoke(core.clj:5671)
	at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
	at clojure.core$load_lib.doInvoke(core.clj:5710)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invoke(core.clj:632)
	at clojure.core$load_libs.doInvoke(core.clj:5749)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invoke(core.clj:632)
	at clojure.core$require.doInvoke(core.clj:5832)
	at clojure.lang.RestFn.invoke(RestFn.java:482)
	at clj_http.core$eval237$loading__5340__auto____238.invoke(core.clj:1)
	at clj_http.core$eval237.invoke(core.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6801)
	at clojure.lang.Compiler.eval(Compiler.java:6790)
	at clojure.lang.Compiler.load(Compiler.java:7246)
	at clojure.lang.RT.loadResourceScript(RT.java:371)
	at clojure.lang.RT.loadResourceScript(RT.java:362)
	at clojure.lang.RT.load(RT.java:446)
	at clojure.lang.RT.load(RT.java:412)
	at clojure.core$load$fn__5448.invoke(core.clj:5866)
	at clojure.core$load.doInvoke(core.clj:5865)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invoke(core.clj:5671)
	at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
	at clojure.core$load_lib.doInvoke(core.clj:5710)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invoke(core.clj:632)
	at clojure.core$load_libs.doInvoke(core.clj:5749)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invoke(core.clj:632)
	at clojure.core$require.doInvoke(core.clj:5832)
	at clojure.lang.RestFn.invoke(RestFn.java:805)
	at clj_http.client$eval83$loading__5340__auto____84.invoke(client.clj:1)
	at clj_http.client$eval83.invoke(client.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6801)
	at clojure.lang.Compiler.eval(Compiler.java:6790)
	at clojure.lang.Compiler.load(Compiler.java:7246)
	at clojure.lang.RT.loadResourceScript(RT.java:371)
	at clojure.lang.RT.loadResourceScript(RT.java:362)
	at clojure.lang.RT.load(RT.java:446)
	at clojure.lang.RT.load(RT.java:412)
	at clojure.core$load$fn__5448.invoke(core.clj:5866)
	at clojure.core$load.doInvoke(core.clj:5865)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at user$eval60$fn__71.invoke(form-init8647608528776892632.clj:1)
	at user$eval60.invoke(form-init8647608528776892632.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6801)
	at clojure.lang.Compiler.eval(Compiler.java:6791)
	at clojure.lang.Compiler.load(Compiler.java:7246)
	at clojure.lang.Compiler.loadFile(Compiler.java:7184)
	at clojure.main$load_script.invoke(main.clj:275)
	at clojure.main$init_opt.invoke(main.clj:280)
	at clojure.main$initialize.invoke(main.clj:308)
	at clojure.main$null_opt.invoke(main.clj:343)
	at clojure.main$main.doInvoke(main.clj:421)
	at clojure.lang.RestFn.invoke(RestFn.java:421)
	at clojure.lang.Var.invoke(Var.java:383)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.Var.applyTo(Var.java:700)
	at clojure.main.main(main.java:37)
Caused by: java.lang.NoClassDefFoundError: IllegalName: compile__stub.clj_http.headers.clj-http.headers/HeaderMap
	at java.lang.ClassLoader.preDefineClass(ClassLoader.java:654)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:758)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
	at clojure.lang.DynamicClassLoader.defineClass(DynamicClassLoader.java:46)
	at clojure.lang.Compiler$NewInstanceExpr.compileStub(Compiler.java:7767)
	at clojure.lang.Compiler$NewInstanceExpr.build(Compiler.java:7632)
	at clojure.lang.Compiler$NewInstanceExpr$DeftypeParser.parse(Compiler.java:7542)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6742)
	... 82 more
Failed.

Will try to create a minimal failing repo.

Show
Michael Blume added a comment - The screened patch seems to break 'lein check' for clj-http
Compiling namespace clj-http.client
Exception in thread "main" java.lang.NoClassDefFoundError: IllegalName: compile__stub.clj_http.headers.clj-http.headers/HeaderMap, compiling:(clj_http/headers.clj:105:1)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6749)
	at clojure.lang.Compiler.analyze(Compiler.java:6543)
	at clojure.lang.Compiler.analyze(Compiler.java:6504)
	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5882)
	at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6198)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6742)
	at clojure.lang.Compiler.analyze(Compiler.java:6543)
	at clojure.lang.Compiler.analyze(Compiler.java:6504)
	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5884)
	at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5315)
	at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3926)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6740)
	at clojure.lang.Compiler.analyze(Compiler.java:6543)
	at clojure.lang.Compiler.eval(Compiler.java:6798)
	at clojure.lang.Compiler.eval(Compiler.java:6790)
	at clojure.lang.Compiler.load(Compiler.java:7246)
	at clojure.lang.RT.loadResourceScript(RT.java:371)
	at clojure.lang.RT.loadResourceScript(RT.java:362)
	at clojure.lang.RT.load(RT.java:446)
	at clojure.lang.RT.load(RT.java:412)
	at clojure.core$load$fn__5448.invoke(core.clj:5866)
	at clojure.core$load.doInvoke(core.clj:5865)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invoke(core.clj:5671)
	at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
	at clojure.core$load_lib.doInvoke(core.clj:5710)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invoke(core.clj:632)
	at clojure.core$load_libs.doInvoke(core.clj:5749)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invoke(core.clj:632)
	at clojure.core$require.doInvoke(core.clj:5832)
	at clojure.lang.RestFn.invoke(RestFn.java:482)
	at clj_http.core$eval237$loading__5340__auto____238.invoke(core.clj:1)
	at clj_http.core$eval237.invoke(core.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6801)
	at clojure.lang.Compiler.eval(Compiler.java:6790)
	at clojure.lang.Compiler.load(Compiler.java:7246)
	at clojure.lang.RT.loadResourceScript(RT.java:371)
	at clojure.lang.RT.loadResourceScript(RT.java:362)
	at clojure.lang.RT.load(RT.java:446)
	at clojure.lang.RT.load(RT.java:412)
	at clojure.core$load$fn__5448.invoke(core.clj:5866)
	at clojure.core$load.doInvoke(core.clj:5865)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invoke(core.clj:5671)
	at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
	at clojure.core$load_lib.doInvoke(core.clj:5710)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invoke(core.clj:632)
	at clojure.core$load_libs.doInvoke(core.clj:5749)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invoke(core.clj:632)
	at clojure.core$require.doInvoke(core.clj:5832)
	at clojure.lang.RestFn.invoke(RestFn.java:805)
	at clj_http.client$eval83$loading__5340__auto____84.invoke(client.clj:1)
	at clj_http.client$eval83.invoke(client.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6801)
	at clojure.lang.Compiler.eval(Compiler.java:6790)
	at clojure.lang.Compiler.load(Compiler.java:7246)
	at clojure.lang.RT.loadResourceScript(RT.java:371)
	at clojure.lang.RT.loadResourceScript(RT.java:362)
	at clojure.lang.RT.load(RT.java:446)
	at clojure.lang.RT.load(RT.java:412)
	at clojure.core$load$fn__5448.invoke(core.clj:5866)
	at clojure.core$load.doInvoke(core.clj:5865)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at user$eval60$fn__71.invoke(form-init8647608528776892632.clj:1)
	at user$eval60.invoke(form-init8647608528776892632.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6801)
	at clojure.lang.Compiler.eval(Compiler.java:6791)
	at clojure.lang.Compiler.load(Compiler.java:7246)
	at clojure.lang.Compiler.loadFile(Compiler.java:7184)
	at clojure.main$load_script.invoke(main.clj:275)
	at clojure.main$init_opt.invoke(main.clj:280)
	at clojure.main$initialize.invoke(main.clj:308)
	at clojure.main$null_opt.invoke(main.clj:343)
	at clojure.main$main.doInvoke(main.clj:421)
	at clojure.lang.RestFn.invoke(RestFn.java:421)
	at clojure.lang.Var.invoke(Var.java:383)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.Var.applyTo(Var.java:700)
	at clojure.main.main(main.java:37)
Caused by: java.lang.NoClassDefFoundError: IllegalName: compile__stub.clj_http.headers.clj-http.headers/HeaderMap
	at java.lang.ClassLoader.preDefineClass(ClassLoader.java:654)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:758)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
	at clojure.lang.DynamicClassLoader.defineClass(DynamicClassLoader.java:46)
	at clojure.lang.Compiler$NewInstanceExpr.compileStub(Compiler.java:7767)
	at clojure.lang.Compiler$NewInstanceExpr.build(Compiler.java:7632)
	at clojure.lang.Compiler$NewInstanceExpr$DeftypeParser.parse(Compiler.java:7542)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6742)
	... 82 more
Failed.
Will try to create a minimal failing repo.
Hide
Michael Blume added a comment -

Looks like it just breaks potemkin's def-map-type.

Show
Michael Blume added a comment - Looks like it just breaks potemkin's def-map-type.
Hide
Nicola Mometto added a comment - - edited

This is a bug in potemkin caused by the fact that it assumes deftype expands to an unqualified second argument.
The deftype* special form takes as first argument the tagsym and as a second argument the class name, potemkin passes a wrong second argument, it expands to :

(deftype* user/Foo user.user/Foo ..)

rather than

(deftype* user/Foo user.Foo ..)

I'll open a PR fixing this issue in potemkin and link back to this ticket.

Show
Nicola Mometto added a comment - - edited This is a bug in potemkin caused by the fact that it assumes deftype expands to an unqualified second argument. The deftype* special form takes as first argument the tagsym and as a second argument the class name, potemkin passes a wrong second argument, it expands to :
(deftype* user/Foo user.user/Foo ..)
rather than
(deftype* user/Foo user.Foo ..)
I'll open a PR fixing this issue in potemkin and link back to this ticket.
Hide
Nicola Mometto added a comment -
Show
Nicola Mometto added a comment - Opened PR: https://github.com/ztellman/potemkin/pull/40

People

Vote (5)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved: