From b9ff64a7cb9e11af7b440e1693a435142676a2e0 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 27 May 2016 08:52:22 -0700 Subject: [PATCH] 8157986: Runtime support for javac to determine arguments to the runtime environment Reviewed-by: alanb --- jdk/make/mapfiles/libjava/mapfile-vers | 1 + .../share/classes/jdk/internal/misc/VM.java | 17 +++++++++++++++++ .../java.base/share/classes/module-info.java | 1 + jdk/src/java.base/share/native/libjava/VM.c | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/jdk/make/mapfiles/libjava/mapfile-vers b/jdk/make/mapfiles/libjava/mapfile-vers index 693f5a87fb8..8bd1118c1ff 100644 --- a/jdk/make/mapfiles/libjava/mapfile-vers +++ b/jdk/make/mapfiles/libjava/mapfile-vers @@ -267,6 +267,7 @@ SUNWprivate_1.1 { Java_jdk_internal_misc_VM_geteuid; Java_jdk_internal_misc_VM_getgid; Java_jdk_internal_misc_VM_getegid; + Java_jdk_internal_misc_VM_getRuntimeArguments; Java_jdk_internal_misc_VM_initialize; Java_java_lang_reflect_Module_defineModule0; diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java b/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java index af8d3253a22..2a839fdd593 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java @@ -475,6 +475,23 @@ public class VM { */ public static native long getNanoTimeAdjustment(long offsetInSeconds); + /** + * Returns the VM arguments for this runtime environment. + * + * @implNote + * The HotSpot JVM processes the input arguments from multiple sources + * in the following order: + * 1. JAVA_TOOL_OPTIONS environment variable + * 2. Options from JNI Invocation API + * 3. _JAVA_OPTIONS environment variable + * + * If VM options file is specified via -XX:VMOptionsFile, the vm options + * file is read and expanded in place of -XX:VMOptionFile option. + * + * Open issue with -XX:Flags (see JDK-8157979) + */ + public static native String[] getRuntimeArguments(); + static { initialize(); } diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index a1b13336fa2..d21c881ee30 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -165,6 +165,7 @@ module java.base { java.sql, java.xml, jdk.charsets, + jdk.compiler, jdk.jartool, jdk.jlink, jdk.net, diff --git a/jdk/src/java.base/share/native/libjava/VM.c b/jdk/src/java.base/share/native/libjava/VM.c index 53837efc518..9e99528c63d 100644 --- a/jdk/src/java.base/share/native/libjava/VM.c +++ b/jdk/src/java.base/share/native/libjava/VM.c @@ -55,3 +55,8 @@ Java_jdk_internal_misc_VM_initialize(JNIEnv *env, jclass cls) { (*env)->RegisterNatives(env, cls, methods, sizeof(methods)/sizeof(methods[0])); } + +JNIEXPORT jobjectArray JNICALL +Java_jdk_internal_misc_VM_getRuntimeArguments(JNIEnv *env, jclass cls) { + return JVM_GetVmArguments(env); +}