$ cat Main.java
package main;
import java.lang.foreign.*;
public class Main {
public static void main(String[] args) {
MemorySegment.ofAddress(1234).reinterpret(10);
}
}
$ javac -d classes '-Xlint:restricted' Main.java
Main.java:7: warning: [restricted] MemorySegment.reinterpret(long) is a restricted method.
MemorySegment.ofAddress(1234).reinterpret(10);
^
(Restricted methods are unsafe and, if used incorrectly, might crash the Java runtime or corrupt memory)
1 warning
$ javac -d classes --release 22 '-Xlint:restricted' Main.java
<no output>
The jdk.internal.javac.Restricted is not preserved when creating the symbol files in ./make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java
However, javac needs this annotation to be present in order to detect restricted methods.
A simple fix is to add this annotation to the list of hard-coded annotation that gets preserved (along with e.g. jdk.internal.javac.PreviewFeature)
package main;
import java.lang.foreign.*;
public class Main {
public static void main(String[] args) {
MemorySegment.ofAddress(1234).reinterpret(10);
}
}
$ javac -d classes '-Xlint:restricted' Main.java
Main.java:7: warning: [restricted] MemorySegment.reinterpret(long) is a restricted method.
MemorySegment.ofAddress(1234).reinterpret(10);
^
(Restricted methods are unsafe and, if used incorrectly, might crash the Java runtime or corrupt memory)
1 warning
$ javac -d classes --release 22 '-Xlint:restricted' Main.java
<no output>
The jdk.internal.javac.Restricted is not preserved when creating the symbol files in ./make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java
However, javac needs this annotation to be present in order to detect restricted methods.
A simple fix is to add this annotation to the list of hard-coded annotation that gets preserved (along with e.g. jdk.internal.javac.PreviewFeature)
- relates to
-
JDK-8333563 [lworld] do not strip the @MigratedValueClass annotation when generating ct.sym
-
- Resolved
-