This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-27
Channels
- # announcements (1)
- # aws (17)
- # babashka (2)
- # beginners (14)
- # calva (1)
- # cider (16)
- # clara (1)
- # clj-kondo (68)
- # cljdoc (2)
- # clojure (51)
- # clojure-dev (1)
- # clojure-italy (2)
- # clojure-spec (1)
- # clojure-uk (19)
- # clojurescript (34)
- # cursive (4)
- # fulcro (1)
- # heroku (3)
- # leiningen (36)
- # lumo (28)
- # music (2)
- # off-topic (16)
- # reagent (22)
- # specter (7)
- # sql (7)
I'm stumped on some java interop. The line with the comment is stumping me. Any help?
I'm copying a bunch of code; everything else falls into place nicely, but I can't figure out how to translate that for interop....
I'm having some Java interop trouble. This snippet does not work as expected:
(def watch-service ^java.nio.WatchService (.newWatchService (java.nio.file.FileSystems/getDefault)))
(def path ^java.nio.file.Path (java.nio.file.Paths/get (.toURI ( "resources"))))
(.register
path
watch-service
java.nio.file.StandardWatchEventKinds/ENTRY_MODIFY
java.nio.file.StandardWatchEventKinds/ENTRY_CREATE
java.nio.file.StandardWatchEventKinds/ENTRY_DELETE)
;; => IllegalArgumentException: "No matching method register found taking 4 args for class sun.nio.fs.UnixPath"
java.nio.file.Path
does have this method: register(WatchService watcher, WatchEvent.Kind<?>... events)
if I reduce the number of arguments I instead get this: Cannot cast java.nio.file.StandardWatchEventKinds$StdWatchEventKind to [Ljava.nio.file.WatchEvent$Kind;
@christian767 try
(.register path watch-service
(into-array WatchEvent.Kind [java.nio.file.StandardWatchEventKinds/ENTRY_MODIFY
java.nio.file.StandardWatchEventKinds/ENTRY_CREATE
java.nio.file.StandardWatchEventKinds/ENTRY_DELETE]))
thanks!
I’m trying to run Clojure on a Lego robot that has only 64mb of RAM (for fun). I’m actually able to get into repl using java -jar clojure.jar
but when I try to use clj
I get this nasty error
robot@ev3dev:~$ clj
OpenJDK Client VM warning: INFO: os::commit_memory(0xa9340000, 179044352, 0) failed; error='Not enough space' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 179044352 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/robot/hs_err_pid4931.log
Are there some knobs I could tweak to make clj
work on low-end hardware or should I just forget about it?I installed clj
with the Linux installer script from http://clojure.org. I’m not sure if it’s even supposed to work with ARM processors..?
@valtteri afaik, the default max heap is set to something like 256m. Does running something like clj -J-Xmx32m
help?
setting both Xms
and Xmx
to 32m?
if still not, then its beyond me 😞
clj runs 2 JVMs - one to compute the classpath, one to run your repl/app
There is a min heap fixed for the first one and I suspect it’s too high for you
You could edit the clojure
script and remove the one place with -Xms and see if that works
I almost know how to use slack..
AWESOME! I removed all -Xms 256mb
switches from the script and it got clj
running 👍 Thanks @alexmiller
But now I think I have some kind of an SSL problem which is in the snippet above
Sorry, don’t know what that is
Might be a mismatch in what TLS level is being used on client vs what is allowed by server
There is an https.protocols System property you could look at
Or a cert issue
Someone has an idea why lein fails to download the nrepl:nrepl:jar:0.6.0
, clojure-complete:clojure-complete:jar:0.2.5
and viebel:codox-klipse-theme:jar:0.0.5
dependencies from http://clojars.org while all other deps download fine from clojars? So no network issue.
You can edit posts if you need to!
Long press on mobile or click the 3 dots on desktop/web
Of course! Not everyone knows about it
Solved the issue: The project.clj
was setting the clojars URL to
. explicitly. Changing that to
fixed it, all deps could be found and downloaded.
I created a POM on my laptop using clj -Spom
and now I’m attempting mvn dependency:resolve
. It’s giving warnings about not being able to fetch descriptors but it seems to be downloading the deps anyways. Everything just takes super long with this hardware. 😄
I ended up wrapping clojure and other libs into an uberjar on my mac, shipping it to the robot and running with rlwrap java -jar robo-test-0.1.0.jar
. My guess is that the SSL problems have something to do with the custom JDK13 that I’m using. I’ll try next weekend clj
with JDK12.
Nevertheless, I’m now able to live-code the robot from the REPL and I feel super empowered! 💪
i also had ssl problems on arm when i used adoptjdk's version
if you do the stuff just for fun then you can try azul's zulu jvm , this one worked as expected out of the box
(i ended up going for a 64 bit raspberry linux instead in the end and could use openjdk's official package from ubuntu's repo again, so i don't use zulu anymore)
What is right and common name for situation when you validate data and values depend on each other. For example check if date of birth is lower, than date of graduation or password repeat. I am asking, because I am writing article and right name matter for me 🙂 Not sure which one is the right one. I found Coercion idiomatic here https://stackoverflow.com/questions/45188850/is-use-of-clojure-spec-for-coercion-idiomatic but hmm I don’t feel it is the right one.
It is a constraint, the valid values for date of birth constrain the valid values for date if graduation and vice versa