简体   繁体   English

如何获取接口内的方法的签名?

[英]How to get the signature of a method which is inside a Interface?

I have a class named Fruits.我有一个名为 Fruits 的 class。 Inside the class there is a interface named Sour. class 内部有一个名为 Sour 的接口。 Inside the Interface I have a method GetItems();在接口里面我有一个方法 GetItems();

public class Fruits
{
    ----------------
    ----------------
    public interface Sour
    {
        public int GetItems();
    }
}

How to get the signature of the GetItems() method?.如何获取 GetItems() 方法的签名? I want to use this signature in JNI GetMethodID method.我想在 JNI GetMethodID 方法中使用这个签名。

Some class has to first implement that interface.一些 class 必须首先实现该接口。

Once a class has imlpemented an interface then you should be able to get the methodID for the interface method, which is now a member of the class that implemented it.一旦 class 实现了接口,那么您应该能够获取接口方法的 methodID,该方法现在是实现它的 class 的成员。

You can't use JNI without a class implementing your Interface.如果没有实现您的接口的 class,您将无法使用 JNI。 Just use the signature of this implementing class.只需使用此实现 class 的签名即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 给定方法签名,如何获取方法所属的java类? - How to get the java Class to which a method belongs given the method signature? 如何使用实现接口的抽象 class 内部的 return 语句创建一个方法,该接口被子类继承? - How to make a method with a return statement that is inside an abstract class which implements an interface get inherited by a subclass? 通过功能接口方法签名获取 class 构造函数 - Get class constructor by functional interface method signature 如何使用课堂 <Interface> Java中的方法签名 - How to use Class<Interface> in method signature in Java 接口中方法签名的异常 - Exception in method signature in interface 如何创建两个具有相同名称,签名和返回类型的方法的类,就像它们实现相同的接口一样 - How to make two classes which both have method with the same name, signature and return type behave like they would implement the same interface 我可以在没有实现接口的情况下调用接口内部的方法吗? - Can i call a method which is inside an interface without implementing the interface? 如何从接口类型的实现中获取特定方法,而该接口不提供? - How to get a specific method from an implementation of an interface type, which the interface doesn't provide? java接口中未定义的get方法 - Get method which is undefined in interface in java 哪个方法将被接口或类覆盖? - Which Method will get override from interface or class?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM