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

Thật vậy, lệnh phóng tiêu chuẩn (java) trong JDK hoặc Java 2 SDK phát hành là không có nhiều hơn một chương trình C đơn giản liên kết với máy ảo Java. Phóng các phân tích cú pháp các đối số dòng lệnh, tải máy ảo, và chạy các ứng dụng Java thông qua giao diện gọi. | LEVERAGING EXISTING NATIVE LIBRARIES Shared Stubs The CMalloc constructor allocates a memory block of the given size in the C heap. The method releases the memory block. Equipped with the CFunction and CMalloc classes we can reimplement as follows public class Win32 private static CFunction c_CreateFile new CFunction native library name CreateFileA native function JNI calling convention public static int CreateFile String fileName int desiredAccess int shareMode int secAttrs int creationDistribution int flagsAndAttributes int templateFile CMalloc cSecAttrs null if secAttrs null file name access read-write mode share mode security attributes how to create file attributes file with attr. to copy cSecAttrs new CMalloc 4 0 secAttrs 0 try return new Object fileName new Integer desiredAccess new Integer shareMode cSecAttrs new Integer creationDistribution new Integer flagsAndAttributes new Integer templateFile finally if secAttrs null We cache the CFunction object in a static variable. The Win32 API Create-File is exported from as CreateFileA. Another exported entry CreateFileW takes a Unicode string as the file name argument. This function fol 115 One-to-One Mapping versus Shared Stubs LEVERAGING EXISTING NATIVE LIBRARIES lows the JNI calling convention which is the standard Win32 calling convention stdcall . The implementation first allocates a memory block in the C heap that is big enough to hold the security attributes temporarily. It then packages all arguments in an array and invokes the underlying C function Create-FileA through the shared dispatcher. Finally the method frees the C memory block used to hold the security attributes. We call in a finally clause to make sure the temporarily C memory is freed even if the call raises an exception. .

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.