NoClassDefFoundError: lux_data_io/IO in example program
teaforthecat opened this issue · 17 comments
Going through the readme, the example program compiles, but doesn't run.
Here are the commands I ran after checking the lux program out into "lux"
experimental> cp -r lux/source/* source/
experimental> ls source/
lux lux.lux program.lux
experimental> java -jar -Xss4m lux-jvm-0.2.0-standalone.jar program
DEF lux;Bool
DEF lux;Int
...
DEF program;text:unit
DEF program;text:++
Compilation complete!
"Elapsed time: 27331.357 msecs"
experimental> cd target/jvm/ && java -jar program.jar
Exception in thread "main" java.lang.NoClassDefFoundError: lux_data_io/IO (wrong name: lux_data_io/io)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at lux_data_io.println.<clinit>(Unknown Source)
at program._.main(Unknown Source)
were those the right commands commands to run? Thanks!
Hmmm... Funny stuff...
I downloaded the .jar for the v0.2 compiler and it all worked fine.
Also tested the code for v0.2 using a REPL, and again it worked fine.
Check the target/jvm dir and look for the "lux_data_io" dir. Inside, among others, there should be the file IO.class. That file also gets packaged inside program.jar
If you can, upload your program.jar file somewhere and post me a link so I can take a look.
At the top of my head, the only idea I have is that for some reason the classes are not getting packaged properly inside the .jar post compilation.
Exception in thread "main" java.lang.NoClassDefFoundError: lux_data_io/IO (wrong name: lux_data_io/io)
Wait...
That might suggest the file exists and is packaged, but the .class file has the wrong name internally (io
instead of IO
). Please upload the JAR if you can so I can take a look.
I don't understand, don't you see the same result?
here is the jar: https://www.dropbox.com/s/cvdwa9t441r1c77/program.jar?dl=1
sounds like a case senstive filesystem detail.
@kryptt Indeed, it appears to be so.
@teaforthecat in the .jar you uploaded, there is IO.class, but no io.class (the .class generated for the io
macro [not to be confused with the IO
type]).
Also, when I checked IO.class the, internal name it had was lux_data_io/io
, which is incorrect.
In the program.jar file that I generate, both classes are there & both of them have the correct name.
Also, when I read the contents of your IO.class, it had the contents that belonged to io.class, which seems to indicate that the compiler first compiled IO
and generated IO.class, then proceeded to compile io
, and when it spit out io.class, IO.class got overwritten instead.
Then, when the program gets loaded, the JVM verifier panics because the name is wrong (since the .class is wrong).
@teaforthecat May I ask what operating system are you using?
I don't understand, don't you see the same result?
Nope. It's all fine and dandy over here.
I'm using a mac
Try this out to find out if your HD is case-insensitive:
http://apple.stackexchange.com/questions/71357/how-to-check-if-my-hd-is-case-sensitive-or-not
I'll be thinking of ways to make the compiler generate classes in a way that's not dependent on case, to avoid having this same issue in the future.
Indeed, it is case-insensitive. Good find! I'll be looking forward to a fix. Thanks!
File System Personality: Journaled HFS+
Type (Bundle): hfs
Name (User Visible): Mac OS Extended (Journaled)
If you want to play with Lux right now instead of waiting for a fix, you can go to the lux/data/io
module and change the name of the io
macro to something else (it's used in a few places inside that module, so you'll have to change those references).
The only other instance I can think of where there are definitions with similar names is in lux.lux
, which contains both the (exported) List
type and a (un-exported) list
macro, but you probably won't get an error there, since list
is not exported (there's another implementation of list
in lux/data/list
which is exported).
Fixed in branch v0.3
I'm still getting an error java.lang.NoClassDefFoundError: lux/List (wrong name: lux/list)
Here are the steps I ran:
git clone https://github.com/LuxLang/lux.git
git checkout -b v0.3 origin/v0.3
lein uberjar
java -jar -Xss4m target/lux-jvm-0.3.0-standalone.jar program #(after removing dict and stack)
the stacktrace is a little different:
InvocationTargetException #<NoClassDefFoundError java.lang.NoClassDefFoundError: lux/List (wrong name: lux/list)>
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at lux.base$fn__1554$memory_class_loader__1556$fn__1557.invoke(base.clj:578)
at lux.base.proxy$java.lang.ClassLoader$ff19274a.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at lux.base.proxy$java.lang.ClassLoader$ff19274a.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at lux.base.proxy$java.lang.ClassLoader$ff19274a.loadClass(Unknown Source)
at lux.compiler.base$load_class_BANG_.invoke(base.clj:62)
at lux.compiler.cache$load$fn__10592$fn__10594$fn__10596$fn__10598$fn__10615$fn__10624$fn__10627$fn__10630.invoke(cache.clj:130)
at lux.base$map_PERCENT_$fn__1428.invoke(base.clj:434)
Oh, yeah. Sorry. I didn't think you'd try again so soon.
I hadn't pushed the changes to the GitHub repo. I just did, so you shouldn't have any trouble now.
By the way, the list
and list&
macros are now @list
and @list&
, and the io
macro is now @io
.
git clone https://github.com/LuxLang/lux.git
git checkout -b v0.3 origin/v0.3
lein uberjar
. . .
There was a change in the standard library, so simply recompiling the compiler won't be enough. You also need to recompile the Lux program (the updated source-files are all in the repo)
. . .
java -jar -Xss4m target/lux-jvm-0.3.0-standalone.jar program #(after removing dict and stack)
^ ^ ^ The above command won't work well for you without recompiling the program.
Try with the latest version in the repo, as it comes with a fix for the pattern matching macro and some extra corrections.
It works! Yeah thanks! I see "Hello, world!"