[英]How to check if a class has overriden a default method from an interface using Reflection in Kotlin or Java?
[英]how to use reflection to determine whether an Interface has a default method?
我想弄清楚接口中的哪些方法具有默认方法。
例如,在 java.util.Collection 中, stream()
有一个默认方法。 一个 go 如何以编程方式找到它
您可以从接口的Class<?>.getMethods()
获取所有方法: myInterface.getMethods()
。
这些Method
对象中的每一个都有一个 function isDefault()
: thisMethod.isDefault()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.