[英]Clojure - No matching method found
Can't figure out why clojure is telling me this function name can't be found. 无法弄清楚为什么clojure告诉我找不到此函数名称。 I'm trying to call the setProperties function on a CloudBlockBlob, which inherits from CloudBlob .
我试图在从CloudBlob 继承的CloudBlockBlob上调用setProperties函数。
(ns my-ns.infra.azure-blob
(:import (com.microsoft.azure.storage.blob
CloudBlob
CloudBlockBlob
CloudBlobClient
CloudBlobContainer
BlobContainerPublicAccessType
BlobRequestOptions BlobProperties CloudBlob BlobContainerProperties)
(com.microsoft.azure.storage
CloudStorageAccount
OperationContext
)))
(def blob (-> "img-manip"
get-container-cached
(.getBlockBlobReference "some-file.txt")))
(def props (-> blob
.getProperties))
How does clojure see the setProperties function? clojure如何看待setProperties函数? Via
clojure.reflect/reflect
-- 通过
clojure.reflect/reflect
#clojure.reflect.Method{:name setProperties,
:return-type void,
:declaring-class com.microsoft.azure.storage.blob.CloudBlob,
:parameter-types [com.microsoft.azure.storage.blob.BlobProperties],
:exception-types [],
:flags #{:final :protected}}
Is blob
cast-able to CloudBlob? blob
是否可以投射到CloudBlob? Yes: 是:
(cast com.microsoft.azure.storage.blob.CloudBlob blob)
=>
#object[com.microsoft.azure.storage.blob.CloudBlockBlob
0x7f613b97
"com.microsoft.azure.storage.blob.CloudBlockBlob@7f613b97"]
Are my properties a BlobProperties
? 我的财产是
BlobProperties
吗? Yes: 是:
(cast com.microsoft.azure.storage.blob.BlobProperties props)
=>
#object[com.microsoft.azure.storage.blob.BlobProperties
0x55cd6938
"com.microsoft.azure.storage.blob.BlobProperties@55cd6938"]
What happens when i call .setProperties? 当我调用.setProperties时会发生什么?
(.setProperties blob props)
java.lang.IllegalArgumentException: No matching method found: setProperties for class com.microsoft.azure.storage.blob.CloudBlockBlob
clojure.lang.Compiler$CompilerException: java.lang.IllegalArgumentException: No matching method found: setProperties for class com.microsoft.azure.storage.blob.CloudBlockBlob, compiling:(/Users/micahsmith/printio/gooten-preview/gooten-preview-api/src/gooten_preview_api/infra/azure_blob.clj:72:1)
I don't understand. 我不明白
setProperties
is a protected
method: setProperties
是一个protected
方法:
protected final void setProperties(final BlobProperties properties) {
this.properties = properties;
}
What you're doing would work if setProperties
were a public
method. 如果
setProperties
是public
方法,则您正在执行的操作将起作用。 You can reproduce this by defining similar classes in your Clojure project: 您可以通过在Clojure项目中定义类似的类来重现此代码:
public abstract class Vehicle {
public final void go(int miles) {
}
}
public class MonsterTruck extends Vehicle { }
And in Clojure: 在Clojure中:
(def truck (MonsterTruck.))
(.go truck 1) ;; resolves base class method, works
But if you change go
to protected final void
you'll see the same error you're getting. 但是,如果你改变
go
到protected final void
,你会看到你得到同样的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.