【发布时间】:2016-08-06 10:42:24
【问题描述】:
在一个 Scala 项目中,我使用的是 Java livrary (bouncycastle)。
我在使用需要实现泛型类型的对象的方法时遇到编译问题。
这是Java中的接口:
public interface Selector<T> extends Cloneable
{
boolean match(T obj);
Object clone();
}
这是一段无法编译的代码:
def verify(data: File): Boolean = {
val signedData = new CMSSignedData(new CMSProcessableFile(data), Base64.decode(this.value))
val certStore = signedData.getCertificates
val signers = signedData.getSignerInfos.getSigners
val signer = signers.iterator.next
val certs = certStore.getMatches(signer.getSID)
val cert = certs.iterator.next.asInstanceOf[X509CertificateHolder]
signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert))
}
当我编译代码时,我得到以下错误:
[error] found : org.bouncycastle.cms.SignerId
[error] required: org.bouncycastle.util.Selector[?0]
[error] val certs = certStore.getMatches(signer.getSID)
我尝试过强制转换,但没有编译。
你能帮忙吗?
问候,
【问题讨论】:
-
getMatches的签名是什么?
标签: scala generics interface compiler-errors