Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8331670: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal #19174

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion make/test/BuildMicrobenchmark.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \
TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
SMALL_JAVA := false, \
CLASSPATH := $(JMH_COMPILE_JARS), \
DISABLED_WARNINGS := restricted this-escape processing rawtypes cast \
DISABLED_WARNINGS := restricted this-escape processing rawtypes removal cast \
serial preview dangling-doc-comments, \
SRC := $(MICROBENCHMARK_SRC), \
BIN := $(MICROBENCHMARK_CLASSES), \
Expand Down
9 changes: 9 additions & 0 deletions src/hotspot/share/runtime/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,15 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
if (res != JNI_OK) {
return res;
}
} else if (match_option(option, "--sun-misc-unsafe-memory-access=", &tail)) {
if (strcmp(tail, "allow") == 0 || strcmp(tail, "warn") == 0 || strcmp(tail, "debug") == 0 || strcmp(tail, "deny") == 0) {
PropertyList_unique_add(&_system_properties, "sun.misc.unsafe.memory.access", tail,
AddProperty, WriteableProperty, InternalProperty);
} else {
jio_fprintf(defaultStream::error_stream(),
"Value specified to --sun-misc-unsafe-memory-access not recognized: '%s'\n", tail);
return JNI_ERR;
}
} else if (match_option(option, "--illegal-access=", &tail)) {
char version[256];
JDK_Version::jdk(17).to_string(version, sizeof(version));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ java.launcher.X.usage=\n\
\ --finalization=<value>\n\
\ controls whether the JVM performs finalization of objects,\n\
\ where <value> is one of "enabled" or "disabled".\n\
\ Finalization is enabled by default.\n\n\
\ Finalization is enabled by default.\n\
\ --sun-misc-unsafe-memory-access=<value>\n\
\ allow or deny usage of unsupported API sun.misc.Unsafe\n\
\ <value> is one of "allow", "warn", "debug", or "deny".\n\
\ The default value is "allow".\n\n\
These extra options are subject to change without notice.\n

# Translators please note do not translate the options themselves
Expand Down
24 changes: 24 additions & 0 deletions src/java.base/share/man/java.1
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,30 @@ or directories.
.TP
\f[V]--source\f[R] \f[I]version\f[R]
Sets the version of the source in source-file mode.
.TP
\f[V]--sun-misc-unsafe-memory-acces=\f[R] \f[I]value\f[R]
Allow or deny usage of unsupported API \f[V]sun.misc.Unsafe\f[R].
\f[I]value\f[R] is one of:
.RS
.TP
\f[V]allow\f[R]
Allow use of the memory-access methods with no warnings at run time.
.TP
\f[V]warn\f[R]
Allow use of the memory-access methods, but issues a warning on the
first occasion that any memory-access method is used.
At most one warning is issued.
.TP
\f[V]debug\f[R]
Allow use of the memory-access methods, but issue a one-line warning and
a stack trace when any memory-access method is used.
.TP
\f[V]deny\f[R]
Disallow use of the memory-access methods by throwing an
\f[V]UnsupportedOperationException\f[R] on every usage.
.PP
The default value when the option is not specified is \f[V]allow\f[R].
.RE
.SH EXTRA OPTIONS FOR MACOS
.PP
The following extra options are macOS specific.
Expand Down
Loading