Skip to content

Commit

Permalink
Merge pull request #5719 from JasonFengJ9/backport-pr5576
Browse files Browse the repository at this point in the history
(v0.14.2-release) Init system property java.vm.specification.version via native
  • Loading branch information
pshipton authored May 9, 2019
2 parents 5efcd78 + 93e4086 commit f3295b8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
2 changes: 0 additions & 2 deletions jcl/src/java.base/share/classes/java/lang/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,6 @@ private static void ensureProperties(boolean isInitialization) {

/*[IF Java12]*/
java.lang.VersionProps.init(initializedProperties);
/* VersionProps.init(systemProperties) above sets java.specification.version value which is used to set java.vm.specification.version. */
initializedProperties.put("java.vm.specification.version", initializedProperties.get("java.specification.version")); //$NON-NLS-1$ //$NON-NLS-2$
/*[ELSE]
/* VersionProps.init requires systemProperties to be set */
systemProperties = initializedProperties;
Expand Down
3 changes: 1 addition & 2 deletions runtime/include/vendor_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#define VENDOR_SHORT_NAME "OpenJ9"

#define JAVA_VM_VENDOR "Eclipse OpenJ9"
#define JAVA_VM_NAME "Eclipse OpenJ9 VM"

#if JAVA_SPEC_VERSION < 12
/* Pre-JDK12 versions use following defines to set system properties
Expand All @@ -60,6 +61,4 @@
#define JAVA_VENDOR_URL "http://www.eclipse.org/openj9"
#endif /* JAVA_SPEC_VERSION < 12 */

#define JAVA_VM_NAME "Eclipse OpenJ9 VM"

#endif /* vendor_version_h */
67 changes: 35 additions & 32 deletions runtime/vm/vmprops.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ initializeSystemProperties(J9JavaVM * vm)
UDATA j2seVersion = J2SE_VERSION(vm);
const char* propValue = NULL;
UDATA rc = J9SYSPROP_ERROR_NONE;
const char *specificationVersion = NULL;

if (omrthread_monitor_init(&(vm->systemPropertiesMutex), 0) != 0) {
return J9SYSPROP_ERROR_OUT_OF_MEMORY;
Expand Down Expand Up @@ -572,49 +573,51 @@ initializeSystemProperties(J9JavaVM * vm)
}
}

if (JAVA_SPEC_VERSION == 8) {
specificationVersion = "1.8";
} else {
#define J9_STR_(x) #x
#define J9_STR(x) J9_STR_(x)
specificationVersion = J9_STR(JAVA_SPEC_VERSION);
}

/* Some properties (*.vm.*) are owned by the VM and need to be set early for all
* versions so they are available to jvmti agents.
* Other java.* properties are owned by the class libraries and setting them can be
* delayed until VersionProps.init() runs.
*/
rc = addSystemProperty(vm, "java.vm.specification.version", specificationVersion, 0);
if (J9SYSPROP_ERROR_NONE != rc) {
goto fail;
}

#if JAVA_SPEC_VERSION < 12
/* Following system properties are defined via java.lang.VersionProps.init(systemProperties) and following settings within System.ensureProperties() */
/* For Java 12, the following properties are defined via java.lang.VersionProps.init(systemProperties) within System.ensureProperties() */
rc = addSystemProperty(vm, "java.specification.version", specificationVersion, 0);
if (J9SYSPROP_ERROR_NONE != rc) {
goto fail;
}
{
const char *classVersion = NULL;
const char *specificationVersion = NULL;

/* Properties that always exist */
switch (j2seVersion) {
case J2SE_18:
if (JAVA_SPEC_VERSION == 8) {
classVersion = "52.0";
specificationVersion = "1.8";
break;
case J2SE_V11:
default:
classVersion = "55.0";
specificationVersion = "11";
break;
} else {
classVersion = "55.0"; /* Java 11 */
}
rc = addSystemProperty(vm, "java.class.version", classVersion, 0);
if (J9SYSPROP_ERROR_NONE != rc) {
goto fail;
}
}

rc = addSystemProperty(vm, "java.specification.version", specificationVersion, 0);
if (J9SYSPROP_ERROR_NONE != rc) {
goto fail;
}

rc = addSystemProperty(vm, "java.vm.specification.version", specificationVersion, 0);
if (J9SYSPROP_ERROR_NONE != rc) {
goto fail;
}

rc = addSystemProperty(vm, "java.vendor", JAVA_VENDOR, 0);
if (J9SYSPROP_ERROR_NONE != rc) {
goto fail;
}

rc = addSystemProperty(vm, "java.vendor.url", JAVA_VENDOR_URL, 0);
if (J9SYSPROP_ERROR_NONE != rc) {
goto fail;
}
rc = addSystemProperty(vm, "java.vendor", JAVA_VENDOR, 0);
if (J9SYSPROP_ERROR_NONE != rc) {
goto fail;
}

rc = addSystemProperty(vm, "java.vendor.url", JAVA_VENDOR_URL, 0);
if (J9SYSPROP_ERROR_NONE != rc) {
goto fail;
}
#endif /* JAVA_SPEC_VERSION < 12 */

Expand Down

0 comments on commit f3295b8

Please sign in to comment.