On Thu, Jan 29, 2009 at 12:44 PM, seertaak <[email protected]> wrote:
>
> Hello,
>
> After a recent discussion on proggit in which I complained that java
> interop in clojure was deficient because you couldn't create
> subclasses of abstract classes without resorting to java, and was
> subsequently alerted to the existence of the 'proxy' form, I decided
> to give clojure another go.
>
> Sod's law in action: I think I may have found a compiler bug.
>
> The code I have looks like this:
>
> (if my-test
> (do
> (import '(com.X.Y.Z MyClass))
> (....))
> (println "blah"))
>
> Now when I execute said code with my-test equal to nil, I get:
>
> Exception in thread "main" java.lang.Exception: No such namespace:
> MyClass (xxx:13)
Line 13?
I don't think you are showing all the code.
Perchance you are refering to MyClass elsewhere in your code and since
my-test is nil, you will be lacking an expected import?
I put the following:
(def x nil)
(if x
(do (import '(java.io IOException))))
(println "poke")
In a file, and executed that as the argument to clojure.main, and it
did not print any stack trace. This was with revision 1232.
> at clojure.lang.Compiler.analyze(Compiler.java:3950)
> at clojure.lang.Compiler.analyze(Compiler.java:3908)
> at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:2732)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:4108)
> at clojure.lang.Compiler.analyze(Compiler.java:3935)
> at clojure.lang.Compiler.access$100(Compiler.java:38)
> at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:
> 3724)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106)
> at clojure.lang.Compiler.analyze(Compiler.java:3935)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:4094)
> at clojure.lang.Compiler.analyze(Compiler.java:3935)
> at clojure.lang.Compiler.analyze(Compiler.java:3908)
> at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:
> 3613)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106)
> at clojure.lang.Compiler.analyze(Compiler.java:3935)
> at clojure.lang.Compiler.analyze(Compiler.java:3908)
> at clojure.lang.Compiler$IfExpr$Parser.parse(Compiler.java:
> 2383)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106)
> at clojure.lang.Compiler.analyze(Compiler.java:3935)
> at clojure.lang.Compiler.analyze(Compiler.java:3908)
> at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:
> 3613)
> at clojure.lang.Compiler$FnMethod.parse(Compiler.java:3456)
> at clojure.lang.Compiler$FnMethod.access$1100(Compiler.java:
> 3335)
> at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2921)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:4104)
> at clojure.lang.Compiler.analyze(Compiler.java:3935)
> at clojure.lang.Compiler.eval(Compiler.java:4140)
> at clojure.lang.Compiler.load(Compiler.java:4470)
> at clojure.lang.Compiler.loadFile(Compiler.java:4437)
> at clojure.lang.Script.main(Script.java:65)
> Caused by: java.lang.Exception: No such namespace: MyClass
> at clojure.lang.Compiler.resolveIn(Compiler.java:4263)
> at clojure.lang.Compiler.resolve(Compiler.java:4237)
> at clojure.lang.Compiler.analyzeSymbol(Compiler.java:4214)
> at clojure.lang.Compiler.analyze(Compiler.java:3923)
>
> Now, for starters, that error message seems wrong, because if I move
> the import to the top of the file, I get an error that looks like:
> Exception in thread "main" java.lang.ExceptionInInitializerError...
> which I *do* expect, because the static initializer of this class
> invokes some code which relies on an RMI object which relies on
> rmiregistry which is running on a different machine. But the problem
> is *not* that there is no such namespace, unless I'm misunderstanding
> something. In other words, the class certainly does exist within the
> com.X.Y.Z package, so the code should be correct.
>
> I think what's going on is that while the then-branch is not really
> evaluated, the parser walks over the AST and then something funny
> happens and we attempt to load MyClass without realizing that it is
> actually in package com.X.Y.Z.
>
> In any case, it's not a show-stopper for me, but I just wanted to
> alert you to the bug.
>
> Many thanks in advance,
> seertaak
> >
>
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---