关于 JDK 22 / Jextract 及其当前状态的问题

问题描述 投票:0回答:1

我注意到 4 月 30 日版本不再像之前的版本那样有“已知问题”部分。

以前的已知问题部分

但由于不支持位字段和其他 C 结构,我在尝试编译某些 Vulkan 标头时似乎仍然遇到问题。有人知道 Jextract 的状况吗?

WARNING: Skipping VkAccelerationStructureSRTMotionInstanceNV.flags (bitfields are not supported)

WARNING: Skipping VkMicromapEXT_T (type Declared(VkMicromapEXT_T) is not supported)

WARNING: Skipping VkOpticalFlowSessionNV_T (type Declared(VkOpticalFlowSessionNV_T) is not supported)

WARNING: Skipping VkShaderEXT_T (type Declared(VkShaderEXT_T) is not supported)

错误消息看起来像这样。

我期待 Jextract 能够正常工作,因为他们删除了新发行说明中的已知问题部分。

更新:GLFW3 的一些实验和结果

 import java.lang.foreign.*;
 import org.glfw3.java.*;


class GLFW_Java {

    public static void main(String[] args) {
        System.loadLibrary("glfw3");
        System.out.print("Start");
        glfw3_h.glfwInit();
        try (Arena arena = Arena.ofConfined()) {
        String window_name_javaString = "Simple Example";
        MemorySegment window_name_C = arena.allocateFrom(window_name_javaString);
        MemorySegment window = (MemorySegment) 
        glfw3_h.glfwCreateWindow(640, 480, window_name_C, null, null);
        if (window != null) {
                System.out.print(window);
            }
        }
    }
}

错误信息:

Exception in thread "main" java.lang.AssertionError: should not reach here
    at org.glfw3.java.glfw3_h.glfwCreateWindow(glfw3_h.java:4721)
    at GLFW_Java.main(GLFW_Java.java:14)
Caused by: java.lang.NullPointerException
    at org.glfw3.java.glfw3_h.glfwCreateWindow(glfw3_h.java:4719)
java-22 jextract
1个回答
0
投票

感谢乔恩维尼。问题解决了。 GLFW3 现在可以与 JDK22 和 Jextract 顺利配合。下面的示例代码。 1.根据Jextract官方指南编译GLFW3。 2.然后使用“-I”标志运行Java以包含.dll/.dylib应该可以顺利运行。

import java.lang.foreign.*;
import org.glfw3.java.*;


class GLFW_Java {

    public static void main(String[] args) {
        System.loadLibrary("glfw3");
        System.out.print("Start");
        glfw3_h.glfwInit();
        try (Arena arena = Arena.ofConfined()) {
            String window_name_javaString = "Simple Example";
            MemorySegment window_name_C = arena.allocateFrom(window_name_javaString);
            MemorySegment window = (MemorySegment) glfw3_h.glfwCreateWindow(640, 480, window_name_C, MemorySegment.NULL, MemorySegment.NULL);
            if (window != null) {
                System.out.print(window);
            }

            glfw3_h.glfwMakeContextCurrent(window);

            while (glfw3_h.glfwWindowShouldClose(window) == 0) {
                glfw3_h.glfwSwapBuffers(window);
                glfw3_h.glfwPollEvents();
            }

            glfw3_h.glfwDestroyWindow(window);
            glfw3_h.glfwTerminate();

        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.