【发布时间】:2018-02-04 13:13:52
【问题描述】:
我在 sre.plan.dsl.constraint 命名空间中有一个名为 ConstraintLookup 的 defrecord。
我想在gen-class 方法中使用其生成的类,该方法位于sre.plan.compiler 命名空间中:
(ns sre.plan.compiler
(:require
[sre.plan.dsl.constraint :as constraint])
(:import (sre.plan.dsl.constraint ConstraintLookup))
(:gen-class
:name sre.plan.Compiler
:methods [^:static [makeConstraintLookupFromTargetsAndBounds
[Iterable Iterable] ConstraintLookup]]))
我正在使用 nebula-clojure 插件和 Gradle 进行 AOT 编译。编译器遇到 ns 声明时会发出错误:
> Task :sre:compileClojure
Exception in thread "main" java.lang.ClassNotFoundException: java.lang.ConstraintLookup, compiling:(sre/plan/compiler.clj:1:1)
类似地,在我得到的方法声明中使用完全限定的sre.plan.dsl.constraint.Constraint:
Exception in thread "main" java.lang.ClassNotFoundException: sre.plan.dsl.constraint.ConstraintLookup, compiling:(sre/plan/compiler.clj:1:1)
这里有什么问题?我迷路了。
更新:
引用的 ns 如下所示:
(ns sre.plan.dsl.constraint
(:require [clojure.set :refer :all]
[clojure.algo.generic.functor :refer :all]))
(defrecord ConstraintLookup [free bound])
更新:
在我看来,在 gen-class 中无论如何你都必须使用完全限定的类名。但是我仍然不明白为什么具有完全限定名称的版本不起作用。
【问题讨论】:
-
您能否创建一个示例项目来重现此错误?
标签: clojure clojure-java-interop