The Java Native InterfaceProgrammer’s Guide and Specification phần 6

xác định các đối tượng lớp hoặc giao diện. Hai lớp hoặc các loại giao diện đều giống nhau chỉ khi họ có cùng tên và cùng một bộ nạp xác định. Ví dụ, trong hình , bộ tải lớp L1 và L2 mỗi định nghĩa một lớp tên là C. Hai lớp học mang tên C là không giống nhau. Thật vậy, họ có hai phương pháp e khác nhau mà có kiểu trả về khác biệt. | OVERVIEW OF THE JNIDESIGN Class Loaders and Native Libraries defines the class or interface object. Two class or interface types are the same only when they have the same name and the same defining loader. For example in Figure class loaders L1 and L2 each define a class named C. These two classes named C are not the same. Indeed they contain two different f methods that have distinct return types. Bootstrap class loader and other system classes Class loader L1 Class loader L2 class C String f class C int f Figure Two classes of the same name loaded by different class loaders The dotted lines in the above figure represent the delegation relationships among class loaders. A class loader may ask another class loader to load a class or an interface on its behalf. For example both L1 and L2 delegate to the bootstrap class loader for loading the system class . Delegation allows system classes to be shared among all class loaders. This is necessary because type safety would be violated if for example application and system code had different notions of what the type was. Class Loaders and Native Libraries Now suppose the method f in both classes C are native methods. The virtual machine locates the native implementation for both methods using the name C_f . To ensure that each C class links with the correct native function each class loader must maintain its own set of native libraries as shown in Figure . 147 Locating Native Libraries OVERVIEW OF THE JNIDESIGN Bootstrap class loader Native libraries associated with system classes Class loader L1 Class loader L2 C_f C_f Native libraries associated with L1 Native libraries associated with L2 Figure Associating native libraries with class loaders Because each class loader maintains a set of native libraries the programmer may use a single library to store all the native methods needed by any number of classes as long as those .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
4    384    1    24-05-2024
Đã 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.