Cursive and gen-class

299 views
Skip to first unread message

William la Forge

unread,
Aug 22, 2015, 11:17:56 AM8/22/15
to Clojure
I searched and did not see anything recent on gen-class problems in Cursive. I find when I have a reference to a gen-class instance that instance? works in Cursive but .getClass does not. (Everything works with lein, of course.)

What I am trying to do is to call the count method via (.count x). What I do not want to do is call the clojure count function, (count x). Again, no issues with lein. 

I suspect I simply have not completed the setup cursive for compiles or something, as all the complaints about cursive/gen-class that I could find were a year old.

I know I need to switch to emacs at some times. I mean, it's only been 30 years since I used it last. :D

Here's the error I'm getting:

Exception in thread "main" java.lang.NoClassDefFoundError: java/util/function/UnaryOperator, compiling:(C:\Users\Bill\Documents\GitHub\aa-collections\test\aa_collections\immutable_set_test.clj:22:10)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6730)
at clojure.lang.Compiler.analyze(Compiler.java:6524)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6711)
at clojure.lang.Compiler.analyze(Compiler.java:6524)
at clojure.lang.Compiler.analyze(Compiler.java:6485)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3791)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6725)
at clojure.lang.Compiler.analyze(Compiler.java:6524)
at clojure.lang.Compiler.analyze(Compiler.java:6485)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5861)
at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6179)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6723)
at clojure.lang.Compiler.analyze(Compiler.java:6524)
at clojure.lang.Compiler.analyze(Compiler.java:6485)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5861)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5296)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3925)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6721)
at clojure.lang.Compiler.analyze(Compiler.java:6524)
at clojure.lang.Compiler.eval(Compiler.java:6779)
at clojure.lang.Compiler.load(Compiler.java:7227)
at clojure.lang.Compiler.loadFile(Compiler.java:7165)
at clojure.main$load_script.invoke(main.clj:275)
at clojure.main$script_opt.invoke(main.clj:337)
at clojure.main$main.doInvoke(main.clj:421)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:379)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

Colin Fleming

unread,
Aug 22, 2015, 4:24:40 PM8/22/15
to clo...@googlegroups.com
Hi William,

Right, you'll need to tell Cursive to compile that namespace in Settings->Build, Execution, Deployment->Compiler->Clojure Compiler. Once you've done that things should work. Cursive doesn't currently pick the set of namespaces to be compiled up from lein - it probably should.

Cheers,
Colin

--
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/d/optout.

William la Forge

unread,
Aug 22, 2015, 5:37:13 PM8/22/15
to Clojure
Hi Colin!

I've set it up to compile all. No doubt this will be very helpful as I will no longer need to compile using an external `lein compile`. But run still dies on the call (.getClass x), when x is a gen-class compiled class instance.

On the other hand I still can not credit this as a Cursive bug. Calling methods on gen-class compiled class instances is to basic. But it is likely related to Cursive, as 'lein test' works great.

William la Forge

unread,
Aug 22, 2015, 5:49:24 PM8/22/15
to Clojure
More weirdness. This works:

(let [^Object aa (.seq a5)]
(println (.getClass aa)))

But not this:

(let [^AASetSequence aa (.seq a5)]
(println (.getClass aa))))

Nor, of course, this:

(let [^AASetSequence aa (.seq a5)]
(println (.count aa)))

Here's the error I'm getting now:

Information:8/22/2015 5:45 PM - Compilation completed with 1 error and 0 warnings in 2s 743ms
C:\Users\Bill\Documents\GitHub\aa-collections\test\aa_collections\immutable_set_test.clj
Error:(26, 12) clojure: java.lang.NoClassDefFoundError: java/util/function/UnaryOperator, compiling:(aa_collections/immutable_set_test.clj:26:12)
java.lang.ClassNotFoundException: java.util.function.UnaryOperator
 at java.net.URLClassLoader$1.run (URLClassLoader.java:366)
    java.net.URLClassLoader$1.run (URLClassLoader.java:355)
    java.security.AccessController.doPrivileged (AccessController.java:-2)
    java.net.URLClassLoader.findClass (URLClassLoader.java:354)
    java.lang.ClassLoader.loadClass (ClassLoader.java:425)
    java.lang.ClassLoader.loadClass (ClassLoader.java:358)
    java.lang.Class.getDeclaredMethods0 (Class.java:-2)
    java.lang.Class.privateGetDeclaredMethods (Class.java:2570)
    java.lang.Class.privateGetPublicMethods (Class.java:2690)
    java.lang.Class.getMethods (Class.java:1467)

William la Forge

unread,
Aug 22, 2015, 5:58:13 PM8/22/15
to Clojure
Bingo! Everything works when I revert to clojure 1.6.0.

Colin Fleming

unread,
Aug 22, 2015, 6:56:46 PM8/22/15
to clo...@googlegroups.com
That's very strange. I'd need more detailed instructions to try to reproduce this. But the class it can't find is new in Java 8 so it looks like you have a JVM version issue. I suspect that this shows up in Cursive but not in lein because you're using a different JDK version in your Cursive project than the one that is picked up on the command line.

I'm guessing that java -version on the command line will show Java 8, but the one you have configured in your Cursive project (File->Project Structure->Project->Project SDK and File->Project Structure->Modules->(your module)->Module SDK) is less than that. Is that the case?

William la Forge

unread,
Aug 22, 2015, 8:07:22 PM8/22/15
to Clojure
At the moment I am dead in the water. Uninstalled cursive and now I can't reinstall. Dies after downloading.

Using Java 1.7.0_65 in the IDE. Lein says:

Leiningen 2.5.2 on Java 1.8.0_31 Java HotSpot(TM) 64-Bit Server VM.

Going to try manually downloading cursive, if I can figure out how.

William la Forge

unread,
Aug 22, 2015, 8:12:30 PM8/22/15
to Clojure
lean version shows java 8, but the ide sdk is java7. Didn't know they would be connected. :0

William la Forge

unread,
Aug 22, 2015, 8:42:42 PM8/22/15
to Clojure
Loving this. I had uninstalled cursive so I could reinstall. But the download of the plugin fails and when installing from disk it says cursive-14-0.1.60 is not compatible. (I'm running with idea 14.1.4.)

Deleted the idea system cache, restarted, still incompatible. :-(

William la Forge

unread,
Aug 22, 2015, 9:14:28 PM8/22/15
to Clojure
Woh! I had to revert to 14.0.2 before idea accepted the clojure plugin as being compatible. 

Fluid Dynamics

unread,
Aug 22, 2015, 9:14:54 PM8/22/15
to Clojure
On Saturday, August 22, 2015 at 8:42:42 PM UTC-4, William la Forge wrote:
Loving this. I had uninstalled cursive so I could reinstall. But the download of the plugin fails and when installing from disk it says cursive-14-0.1.60 is not compatible. (I'm running with idea 14.1.4.)

Deleted the idea system cache, restarted, still incompatible. :-(

It never ceases to amaze me that people pay for proprietary junk like IntelliJ and Windoze that are prone to hose themselves to the point of needing a format+reinstall to get them working again, while there are good, free alternatives out there like Eclipse/CCW and Linux that Just Work(tm).

William la Forge

unread,
Aug 22, 2015, 9:22:02 PM8/22/15
to Clojure
Set the ide to Java 8 and clojure 1.7. And now it works great. Good catch. Thanks!

As for Cursive, I'm guessing it is set to be compatible with idea 14.0.x, though fortunately when you go to 14.1 the plugins get grandfathered in. Which is a bit weird!

Colin Fleming

unread,
Aug 23, 2015, 4:00:33 AM8/23/15
to clo...@googlegroups.com
Hi William,

You have to ensure that you download the version of Cursive that corresponds to your IntelliJ version - the links are in the getting started guide here: https://cursiveclojure.com/userguide/. It's unfortunate but necessary that the versions coincide since the IntelliJ APIs change from version to version.

Cheers,
Colin

Colin Fleming

unread,
Aug 23, 2015, 4:01:17 AM8/23/15
to clo...@googlegroups.com
I totally agree that some people are endlessly amazing.

--

William la Forge

unread,
Aug 23, 2015, 7:04:29 AM8/23/15
to Clojure
OK. NOW I see support for 14.1. Why I didn't see that before! (hand slaps forehead)

Alan Moore

unread,
Aug 24, 2015, 11:07:37 AM8/24/15
to Clojure
FWIW - My experience with Eclipse vs IntelliJ is exactly the opposite - we have been using Eclipse at my day job but I have recently abandoned it due to hangs, crashes, slow downs, etc. and have moved over to IntelliJ. YMMV.

Alan

Daniel Compton

unread,
Aug 24, 2015, 11:42:52 PM8/24/15
to Clojure
Fluid Dynamics, your comment was neither nice, nor helpful, and doesn't have a place in the Clojure mailing list. Please keep your inflammatory comments to yourself.

On Tue, Aug 25, 2015 at 3:07 AM Alan Moore <kahun...@coopsource.org> wrote:
FWIW - My experience with Eclipse vs IntelliJ is exactly the opposite - we have been using Eclipse at my day job but I have recently abandoned it due to hangs, crashes, slow downs, etc. and have moved over to IntelliJ. YMMV.

Alan

--
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/d/optout.
--
--
Daniel

Fluid Dynamics

unread,
Aug 25, 2015, 1:43:39 AM8/25/15
to Clojure
 Daniel Compton, your comment was neither nice, nor helpful, and doesn't have a place in the Clojure mailing list. Please keep your inflammatory comments to yourself.

Alex Miller

unread,
Aug 25, 2015, 8:25:12 AM8/25/15
to Clojure
Fluid, I agree with Daniel that calling something "junk" is unnecessary, especially when the people making and using such a tool are on the list. We would like this to be a thoughtful, encouraging forum for discussion.

Alex

Fluid Dynamics

unread,
Aug 25, 2015, 12:23:00 PM8/25/15
to Clojure
On Tuesday, August 25, 2015 at 8:25:12 AM UTC-4, Alex Miller wrote:
Fluid, I agree with Daniel that calling something "junk" is unnecessary, especially when the people making and using such a tool are on the list. We would like this to be a thoughtful, encouraging forum for discussion.

Alex


I seem to recall criticizing a piece of Clojure-relevant *technology* that had the rather remarkable property that it could be working, be deleted and reinstalled (exact same version), and suddenly be *not* working.

Daniel, on the other hand,  criticized a *person* and moreover his post had nothing whatsoever to do with Clojure.

Colin Fleming

unread,
Aug 25, 2015, 1:05:30 PM8/25/15
to clo...@googlegroups.com
On 25 August 2015 at 18:22, Fluid Dynamics <a209...@trbvm.com> wrote:
I seem to recall criticizing a piece of Clojure-relevant *technology* that had the rather remarkable property that it could be working, be deleted and reinstalled (exact same version), and suddenly be *not* working.

Except that's not actually what happened. The sequence of events is difficult to work out from the email chain, but William was trying to install a version of Cursive into a version of IntelliJ it didn't support. That never works, and I'm 100% sure that it hadn't worked for him previously. It's a fairly common mistake that users make when upgrading IntelliJ for the first time when using Cursive, it's no big deal.
 
Daniel, on the other hand,  criticized a *person* and moreover his post had nothing whatsoever to do with Clojure.

No, he didn't, he criticized the comment you made and said it wasn't appropriate for the Clojure community, which is very relevant to Clojure.

Personally, I'm pretty confident in the ability of this community to recognise and disregard uninformed ranting when they see it, so I'm not at all bothered by it.

Alex Miller

unread,
Aug 25, 2015, 1:12:08 PM8/25/15
to Clojure

On Tuesday, August 25, 2015 at 11:23:00 AM UTC-5, Fluid Dynamics wrote:
On Tuesday, August 25, 2015 at 8:25:12 AM UTC-4, Alex Miller wrote:
Fluid, I agree with Daniel that calling something "junk" is unnecessary, especially when the people making and using such a tool are on the list. We would like this to be a thoughtful, encouraging forum for discussion.

Alex


I seem to recall criticizing a piece of Clojure-relevant *technology* that had the rather remarkable property that it could be working, be deleted and reinstalled (exact same version), and suddenly be *not* working.

Criticism and discussion of problems is perfectly fine. Throwing insults that don't add to that discussion is unnecessary and potentially harmful.
 
Daniel, on the other hand,  criticized a *person* and moreover his post had nothing whatsoever to do with Clojure.

No, Daniel criticized *behavior*. I'm sure you're a fine person. His post had to do with the tone of the discussion here and I believe that's entirely relevant. 

There are community expectations here for civil discussion and Daniel (and now me) are telling you it went a step too far. I know that you have been a long time contributor to the list and often provide valuable discussion, but sometimes you also cross the line (this is not the first time someone has complained). My suggestion would be that you just tone it down a notch and we all get back to talking Clojure.

Alex

Colin Yates

unread,
Aug 25, 2015, 1:15:32 PM8/25/15
to clo...@googlegroups.com

+1, let's keep the Clojure community respectful and welcoming.  This has been distracting enough already.

--

Fluid Dynamics

unread,
Aug 25, 2015, 2:08:16 PM8/25/15
to Clojure
On Tuesday, August 25, 2015 at 1:05:30 PM UTC-4, Colin Fleming wrote:
On 25 August 2015 at 18:22, Fluid Dynamics <a209...@trbvm.com> wrote:
I seem to recall criticizing a piece of Clojure-relevant *technology* that had the rather remarkable property that it could be working, be deleted and reinstalled (exact same version), and suddenly be *not* working.

Except that's not actually what happened. The sequence of events is difficult to work out from the email chain, but William was trying to install a version of Cursive into a version of IntelliJ it didn't support. That never works, and I'm 100% sure that it hadn't worked for him previously.

I'm pretty sure he said he uninstalled Cursive, then reinstalled the exact same version of Cursive that he had just uninstalled, and it didn't work. That clearly is broken behavior. If it was there and working fine before, then scrozzled itself, and then reinstalling it made things *worse* instead of getting it back into the pre-scrozzled state, then that's broken.
 

Niels van Klaveren

unread,
Aug 25, 2015, 2:23:01 PM8/25/15
to Clojure
If you had read more attentively, he uninstalled Cursive because he suspected a reinstall might fix an error. However, the error was caused because in Cursive, an extra step is necessary configuring the project to make gen-class work in certain situations, so the unistall was unnecessary.

When reinstalling, he added the wrong update site version when installing the plugin, which is why Cursive didn't work. Fixing the update link fixed Cursive.

So no problems were caused by Cursive or IntelliJ, just two misconfigurations.

William la Forge

unread,
Aug 25, 2015, 2:55:56 PM8/25/15
to clo...@googlegroups.com
Actually what happened is that the cursive plugin continued working even after I upgraded to idea 14.1. Though obviously I could not reinstall the same plugin subsequent to that upgrade after an uninstall. At least, I am pretty sure that that is what happened. :-) 

Can we close this thread please?

--
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 a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/rCfF1_Gc_tg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.

Alan Moore

unread,
Aug 25, 2015, 3:23:58 PM8/25/15
to Clojure
I'll second that motion.

A minor point of clarification re my previous comment: the issues with Eclipse have nothing to do with CCW as it wasn't even installed. My comment was more broadly aimed, lest anyone mistakenly think I was slighting CCW in any way.

Moving on...

Alan
Reply all
Reply to author
Forward
0 new messages