TAILIEUCHUNG - The Java Native InterfaceProgrammer’s Guide and Specification phần 3

CallNonvirtualBooleanMethod, và như vậy. Đó là tương đối hiếm hoi mà bạn sẽ cần phải gọi các phương pháp thể hiện của một lớp cha. Cơ sở này là tương tự như gọi một phương thức ghi đè lớp cha, f, bằng cách sử dụng xây dựng trong các ngôn ngữ lập trình Java sau đây: | FIELDS AND METHODS Invoking Constructors Calling Instance Methods of a Superclass You can call instance methods which were defined in a superclass but that have been overridden in the class to which the object belongs. The JNI provides a set of CallNonvirtual Type Method functions for this purpose. To call a instance method defined in a superclass you do the following Obtain the method ID from a reference to the superclass using GetMethodID as opposed to GetStaticMethodID. Pass the object superclass method ID and arguments to one of the family of nonvirtual invocation functions such as CallNonvirtualVoidMethod CallNonvirtualBooleanMethod and so on. It is relatively rare that you will need to invoke the instance methods of a superclass. This facility is similar to calling an overridden superclass method say f using the following construct in the Java programming language CallNonvirtualVoidMethod can also be used to invoke constructors as the next section will illustrate. Invoking Constructors In the JNI constructors may be invoked following steps similar to those used for calling instance methods. To obtain the method ID of a constructor pass init as the method name and V as the return type in the method descriptor. You can then invoke the constructor by passing the method ID to JNI functions such as NewObject. The following code implements the equivalent functionality of the JNI function NewString which constructs a object from the Unicode characters stored in a C buffer jstring MyNewStringJNIEnv env jchar chars jint len jclass stringClass jmethodID cid jcharArray elemArr jstring result stringClass env - FindClass env java lang String if stringClass NULL return NULL exception thrown 51 Invoking Constructors FIELDS AND METHODS Get the method ID for the String char constructor cid env - GetMethodID env stringClass init C V if cid NULL return NULL exception thrown Create a char that holds the string characters elemArr env - .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.