Attempting to AOT compile a Clojure namespace with clj -e "(compile 'my-ns.core)" throws an exception when attempting to construct a LocalDate:

Syntax error (IllegalArgumentException) compiling . at (my-project/my-ns-core.clj:5:1).
No matching method ofInstant found taking 2 args for class java.time.LocalDate

Works fine in REPL. Why failing in AOT? Classes are imported.

(ns my-ns.core
  (:require [clojure.alpha.spec.gen :as g])
  (:import (java.time LocalDate))

(LocalDate/ofInstant (Instant/ofEpochMilli 123) (ZoneId/of "UTC"))

I assume this must be related to these classes being included from the AOT build?

1

There are 1 answers

0
Petrus Theron On

GraalVM was in my $PATH which took precedence for calls to java with an older Java version that did not include the Java 8 date classes. Figured it out by running which java.

Solved with:

export JAVA_HOME=/Users/<username>/Library/Java/JavaVirtualMachines/openjdk-15/Contents/Home`

And not including $GRAALVM_HOME in $PATH.