"Invalid this class index..." exception

623 views
Skip to first unread message

Paul Stadig

unread,
Oct 14, 2008, 1:55:52 PM10/14/08
to clo...@googlegroups.com
I'm getting the following error message when trying to load a 12MB clojure file that is basically just a big hashmap of fundamental types (i.e. strings, numbers, keywords, etc.).

java -cp /home/pstadig/.emacs.d/clojure/target/clojure-lang-1.0-SNAPSHOT.jar:./gen clojure.lang.Script db.clj
Exception in thread "main" java.lang.ClassFormatError: Invalid this class index 3171 in constant pool in class file clojure/eval__2459 (db.clj:0)
    at clojure.lang.Compiler.eval(Compiler.java:4116)
    at clojure.lang.Compiler.load(Compiler.java:4432)
    at clojure.lang.Compiler.loadFile(Compiler.java:4399)
    at clojure.lang.Script.main(Script.java:65)
Caused by: java.lang.ClassFormatError: Invalid this class index 3171 in constant pool in class file clojure/eval__2459
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at clojure.lang.RT.classForName(RT.java:1509)
    at clojure.lang.Compiler$FnExpr.getCompiledClass(Compiler.java:3180)
    at clojure.lang.Compiler$FnExpr.eval(Compiler.java:3190)
    at clojure.lang.Compiler.eval(Compiler.java:4104)
    ... 3 more

I'm using revision 1068 with Sun Java 1.6.0, as indicated below. I've also gotten this error with earlier revisions of Clojure.  I forget the revision (around 2008-10-06), but I think it was before AOT. I'm not sure what the issue is. I can send along the file if needed.

svn info
Path: .
URL: https://clojure.svn.sourceforge.net/svnroot/clojure/trunk
Repository Root: https://clojure.svn.sourceforge.net/svnroot/clojure
Repository UUID: b4165764-bd0f-0410-b771-ab16a44d2305
Revision: 1068
Node Kind: directory
Schedule: normal
Last Changed Author: rhickey
Last Changed Rev: 1068
Last Changed Date: 2008-10-13 19:57:11 -0400 (Mon, 13 Oct 2008)

java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode)


Paul

Rich Hickey

unread,
Oct 14, 2008, 2:09:29 PM10/14/08
to Clojure


On Oct 14, 1:55 pm, "Paul Stadig" <p...@stadig.name> wrote:
> I'm getting the following error message when trying to load a 12MB clojure
> file that is basically just a big hashmap of fundamental types (i.e.
> strings, numbers, keywords, etc.).
>
> java -cp
> /home/pstadig/.emacs.d/clojure/target/clojure-lang-1.0-SNAPSHOT.jar:./gen
> clojure.lang.Script db.clj
> Exception in thread "main" java.lang.ClassFormatError: Invalid this class
> index 3171 in constant pool in class file clojure/eval__2459 (db.clj:0)

> I'm using revision 1068 with Sun Java 1.6.0, as indicated below. I've also
> gotten this error with earlier revisions of Clojure. I forget the revision
> (around 2008-10-06), but I think it was before AOT. I'm not sure what the
> issue is. I can send along the file if needed.
>

Looks like you might be using Clojure data structures literals as a
data format. That's great, and fine, but you probably want to read
that file rather than load it. Loading it will force the compiler to
treat it as code, and, now, as needed by the AOT support, try to put
the data structure into a classfile, where it won't fit. Reading it
will work.

Rich

Paul Stadig

unread,
Oct 14, 2008, 2:34:53 PM10/14/08
to clo...@googlegroups.com
Thanks, Rich. Reading made the difference. I was confused because I was able to load smaller data structure literal files, but it would choke on the 12MB file. That's why I thought there was something about the way the larger file was being loaded.

I think I avoided using read because it needed a PushbackReader and load-file was just so easy to pass a path to. Anyway, sorry about the dumb question, and thanks for the response.


Paul

Matthew D. Swank

unread,
Oct 14, 2008, 3:40:03 PM10/14/08
to Clojure
Has anyone gotten swank-clojure to work with this change?
Thanks,

Matt

Paul Stadig

unread,
Oct 14, 2008, 3:45:42 PM10/14/08
to clo...@googlegroups.com
I have. I just had to add "/home/pstadig/gen" to swank-clojure-extra-classpaths. When I start emacs (from my Application menu) it starts in my home directory. If you started emacs in a different directory, then I guess you would just have to add "[THAT DIR]/gen" to the classpath.


Paul
Reply all
Reply to author
Forward
0 new messages