Re: Clojure 1.5.0 bug (Java interop: Compiler.load(new StringReader(str));)

Showing 1-4 of 4 messages
Re: Clojure 1.5.0 bug (Java interop: Compiler.load(new StringReader(str));) Andy Fingerhut 3/12/13 7:32 PM
Yegor Bugayenko posted in a comment on ticket CLJ-1172 (http://dev.clojure.org/jira/browse/CLJ-1172) that calling RT.init() before Compiler.load() solved what looks like a similar problem for him.

Andy

On Tue, Mar 12, 2013 at 6:29 PM, Taegyoon Kim <stelo...@gmail.com> wrote:
A new error occurred in Clojure 1.5.0.
 
(Java interop: Compiler.load(new StringReader(str));)
 
# Code #
import java.io.IOException;
import java.io.StringReader;
import clojure.lang.Compiler;
import clojure.lang.RT;
import clojure.lang.Var;
public class Main {
    public static void main(String[] args) throws IOException, ClassNotFoundException {       
        //clojure.main.main(args);
       
        // Load the Clojure script -- as a side effect this initializes the runtime.
        String str = "(ns user) (defn foo [a b]   (str a \" \" b)) (def a 3)";
        //RT.loadResourceScript("foo.clj");
        Compiler.load(new StringReader(str));
        // Get a reference to the foo function.
        Var foo = RT.var("user", "foo");
        Var a = RT.var("user", "a"); // reference to the variable a
        // Call it!
        Object result = foo.invoke("Hi", "there");
        System.out.println(result);
       
        System.out.println(a);
        System.out.println(a.get());
    }
}
 
 
 
$ java -version
java version "1.7.0_15"
OpenJDK Runtime Environment (IcedTea7 2.3.7) (7u15-2.3.7-0ubuntu1~12.04.1)
OpenJDK Client VM (build 23.7-b01, mixed mode, sharing)
$ java -cp clojure-1.5.0.jar:. Main

Exception in thread "main" java.lang.ExceptionInInitializerError
at clojure.lang.Compiler.<clinit>(Compiler.java:47)
at Main.main(Main.java:16)
Caused by: java.lang.NullPointerException
at clojure.lang.RT.baseLoader(RT.java:2043)
at clojure.lang.RT.load(RT.java:417)
at clojure.lang.RT.load(RT.java:411)
at clojure.lang.RT.doInit(RT.java:447)
at clojure.lang.RT.<clinit>(RT.java:329)
... 2 more
$ java -cp clojure-1.4.0.jar:. Main

Hi there
#'user/a
3
 
 

--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Clojure 1.5.0 bug (Java interop: Compiler.load(new StringReader(str));) Taegyoon Kim 3/12/13 9:41 PM
But then(putting RT.init()),
 
Compiler.load() works, but Console (stderr?) says
 
No need to call RT.init() anymore
 
So I think this problem should be fixed.
 

2013년 3월 13일 수요일 오전 11시 32분 5초 UTC+9, Andy Fingerhut 님의 말:
Re: Clojure 1.5.0 bug (Java interop: Compiler.load(new StringReader(str));) Sean Corfield 3/12/13 10:41 PM
Based on discussions I've seen on this list and clojure-dev, I think
you're using internal APIs that are not considered "supported" and
therefore subject to change at any time.

I asked about using clojure.lang.RT a while ago and was told to rely
on very little of the API, for example, so all I rely on is .var() and
calling .invoke() on the result of that. I would say the Compiler is
"out of bounds" and that you should instead use RT.var() and .invoke()
with basic Clojure functions to read and eval your string.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
Re: Clojure 1.5.0 bug (Java interop: Compiler.load(new StringReader(str));) Andy Fingerhut 3/12/13 11:04 PM
OK, I don't know whether this is really a bug or just an obsolete message being printed on the console, but I've reopened the ticket and added a pointer to this discussion, and a link to exactly which commit it was that caused this change in behavior (just before Clojure 1.5.0-RC4).

Andy