Is FungibleAsset compatible with Java CorDapps?

隐身守侯 提交于 2020-08-10 19:17:19

问题


This has been asked here but I will try to approach the question differently.

A quick review of Corda's code:

interface FungibleState<T : Any> : ContractState {
    val amount: Amount<T>
}

FungibleAsset then extends FungibleState:

interface FungibleAsset<T : Any> : FungibleState<Issued<T>>, OwnableState {
    override val amount: Amount<Issued<T>>
    @get:SerializableCalculatedProperty
    val exitKeys: Collection<PublicKey>
    fun withNewOwnerAndAmount(newAmount: Amount<Issued<T>>, newOwner: AbstractParty): FungibleAsset<T>
}

If I use FungibleAsset in a Java CorDapp:

public class MyFungibleAsset implements FungibleAsset<Currency> {
        
    @NotNull
    @Override
    public Amount<Issued<Currency>> getAmount() {
        return null;
    }
...}

it will raise 2 errors when I build the project (IntelliJ won't highlight any error during editing):

error: MyFungibleAsset is not abstract and does not override abstract method getAmount() in FungibleState

error: getAmount() in MyFungibleAsset cannot implement getAmount() in FungibleState
    public Amount<Issued<Currency>> getAmount() {
                                    ^
  return type Amount<Issued<Currency>> is not compatible with Amount<Issued<? extends Currency>>
  where T is a type-variable:
    T extends Object declared in interface FungibleState

I assume this has something to do with FungibleState's getAmount returning Amount<T> whereas FungibleAsset's getAmount returns Amount<Issued<T>> ? I don't get an error in kotlin.

来源:https://stackoverflow.com/questions/62925386/is-fungibleasset-compatible-with-java-cordapps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!