所以我下载了 JDK 15 - OpenJDK 。
在Intelij中运行以下代码
import jdk.incubator.foreign.MemorySegment; //The problem seems to occur here in this import
public class Application {
public static void main(String[] args){
MemorySegment m = MemorySegment.allocateNative(400L);
}
}
Run Code Online (Sandbox Code Playgroud)
在 inteliJ 中,我转到文件 -> 项目结构 -> 项目 SDK -> 选择 15
在应用程序配置(Intelij运行项目)中,我声明了JRE 15(java版本15.0.2)
我收到以下错误
C:\Users\repositories\java15project\src\main\untitled\src\Application.java:2:21
java: package jdk.incubator.foreign is not visible
(package jdk.incubator.foreign is declared in module jdk.incubator.foreign, which is not in the module graph)
Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗?
And*_*eas 10
使用选项运行--add-modules jdk.incubator.foreign
或者,创建一个module-info.java文件,例如:
module my.module.name.here {
requires jdk.incubator.foreign;
}
Run Code Online (Sandbox Code Playgroud)