Clojure static inner class 实例化问题(互操作问题)
Clojure static inner class instantiation issues (interop issues)
我正在尝试将 Java 库中的静态内部 class 用于 Clojure。
内class是InMemoryLookupCache.Builder.
我总是得到 ClassNotFoundException
。喜欢:
(import 'org.deeplearning4j.models.word2vec.wordstore.inmemory.InMemoryLookupCache$Builder)
我正在尝试用 Clojure 编写 Java 代码,但没有成功:
new InMemoryLookupCache.Builder().lr(2e-5).vectorLength(100).build();
但是我无法实例化内部 class,即使我认为我使用 $
语法来访问它是正确的。
如果您想尝试,请使用以下项目:
[org.deeplearning4j/deeplearning4j-core "0.0.3.3"]
[org.deeplearning4j/deeplearning4j-nlp "0.0.3.3"]
如果 this 是您正在使用的 class,我没有看到 Builder inner class?
编辑:
这对我有用。将库的版本更改为示例使用的版本。
在project.clj中:
(defproject clojure-scratch "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.deeplearning4j/deeplearning4j-core "0.0.3.2.7"]
[org.deeplearning4j/deeplearning4j-nlp "0.0.3.2.7"]])
在core.clj中:
(ns clojure-scratch.core
(:import (org.deeplearning4j.models.word2vec.wordstore.inmemory
InMemoryLookupCache
InMemoryLookupCache$Builder)))
(println (new InMemoryLookupCache$Builder))
我正在尝试将 Java 库中的静态内部 class 用于 Clojure。
内class是InMemoryLookupCache.Builder.
我总是得到 ClassNotFoundException
。喜欢:
(import 'org.deeplearning4j.models.word2vec.wordstore.inmemory.InMemoryLookupCache$Builder)
我正在尝试用 Clojure 编写 Java 代码,但没有成功:
new InMemoryLookupCache.Builder().lr(2e-5).vectorLength(100).build();
但是我无法实例化内部 class,即使我认为我使用 $
语法来访问它是正确的。
如果您想尝试,请使用以下项目:
[org.deeplearning4j/deeplearning4j-core "0.0.3.3"]
[org.deeplearning4j/deeplearning4j-nlp "0.0.3.3"]
如果 this 是您正在使用的 class,我没有看到 Builder inner class?
编辑: 这对我有用。将库的版本更改为示例使用的版本。
在project.clj中:
(defproject clojure-scratch "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.deeplearning4j/deeplearning4j-core "0.0.3.2.7"]
[org.deeplearning4j/deeplearning4j-nlp "0.0.3.2.7"]])
在core.clj中:
(ns clojure-scratch.core
(:import (org.deeplearning4j.models.word2vec.wordstore.inmemory
InMemoryLookupCache
InMemoryLookupCache$Builder)))
(println (new InMemoryLookupCache$Builder))