Skip to content

Commit 1884c1c

Browse files
authored
Merge pull request #21479 from pshipton/sysprops8-0.51
(0.51) Use extensions System.initProperties to help init jdk8 properties
2 parents 9cf2bb1 + e472fd9 commit 1884c1c

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
lines changed

jcl/src/java.base/share/classes/java/lang/System.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -677,20 +677,20 @@ private static void arraycopy(Object[] A1, int offset1, Object[] A2, int offset2
677677
*/
678678
public static native long currentTimeMillis();
679679

680-
/*[IF JAVA_SPEC_VERSION == 11]*/
680+
/*[IF (JAVA_SPEC_VERSION <= 11) & Sidecar18-SE-OpenJ9]*/
681681
private static native Properties initProperties(Properties props);
682-
/*[ENDIF] JAVA_SPEC_VERSION == 11 */
682+
/*[ENDIF] (JAVA_SPEC_VERSION <= 11) & Sidecar18-SE-OpenJ9 */
683683

684684
/**
685685
* If systemProperties is unset, then create a new one based on the values
686686
* provided by the virtual machine.
687687
*/
688688
@SuppressWarnings("nls")
689689
private static void ensureProperties(boolean isInitialization) {
690-
/*[IF JAVA_SPEC_VERSION == 11]*/
690+
/*[IF (JAVA_SPEC_VERSION <= 11) & Sidecar18-SE-OpenJ9]*/
691691
Properties jclProps = new Properties();
692692
initProperties(jclProps);
693-
/*[ENDIF] JAVA_SPEC_VERSION == 11 */
693+
/*[ENDIF] (JAVA_SPEC_VERSION <= 11) & Sidecar18-SE-OpenJ9 */
694694

695695
/*[IF JAVA_SPEC_VERSION > 11]*/
696696
Map<String, String> initializedProperties = new HashMap<>();
@@ -706,13 +706,13 @@ private static void ensureProperties(boolean isInitialization) {
706706
initializedProperties.put("os.encoding", osEncoding); //$NON-NLS-1$
707707
}
708708
initializedProperties.put("ibm.system.encoding", platformEncoding); //$NON-NLS-1$
709-
/*[IF JAVA_SPEC_VERSION == 8]*/
709+
/*[IF !Sidecar18-SE-OpenJ9]*/
710710
/*[PR The launcher apparently needs sun.jnu.encoding property or it does not work]*/
711711
initializedProperties.put("sun.jnu.encoding", platformEncoding); //$NON-NLS-1$
712712
initializedProperties.put("file.encoding.pkg", "sun.io"); //$NON-NLS-1$ //$NON-NLS-2$
713713
/* System property java.specification.vendor is set via VersionProps.init(systemProperties) since JDK12 */
714714
initializedProperties.put("java.specification.vendor", "Oracle Corporation"); //$NON-NLS-1$ //$NON-NLS-2$
715-
/*[ENDIF] JAVA_SPEC_VERSION == 8 */
715+
/*[ENDIF] !Sidecar18-SE-OpenJ9 */
716716
initializedProperties.put("java.specification.name", "Java Platform API Specification"); //$NON-NLS-1$ //$NON-NLS-2$
717717
initializedProperties.put("com.ibm.oti.configuration", "scar"); //$NON-NLS-1$
718718

@@ -743,13 +743,13 @@ private static void ensureProperties(boolean isInitialization) {
743743
}
744744
initializedProperties.put(key, list[i+1]);
745745
}
746-
/*[IF JAVA_SPEC_VERSION == 11]*/
746+
/*[IF Sidecar18-SE-OpenJ9]*/
747747
for (Map.Entry<?, ?> entry : jclProps.entrySet()) {
748748
initializedProperties.putIfAbsent(entry.getKey(), entry.getValue());
749749
}
750-
/*[ELSE] JAVA_SPEC_VERSION == 11 */
750+
/*[ELSE] Sidecar18-SE-OpenJ9 */
751751
initializedProperties.put("file.encoding", fileEncoding); //$NON-NLS-1$
752-
/*[ENDIF] JAVA_SPEC_VERSION == 11 */
752+
/*[ENDIF] Sidecar18-SE-OpenJ9 */
753753
/*[ENDIF] JAVA_SPEC_VERSION >= 17 */
754754

755755
/*[IF (JAVA_SPEC_VERSION >= 21) & (PLATFORM-mz31 | PLATFORM-mz64)]*/

runtime/j9vm/j7vmi.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,14 +1535,10 @@ JVM_IHashCode(JNIEnv *env, jobject obj)
15351535
jobject JNICALL
15361536
JVM_InitProperties(JNIEnv* env, jobject properties)
15371537
{
1538-
/* This JVM method is invoked by JCL native Java_java_lang_System_initProperties
1539-
* only for initialization of platform encoding.
1540-
* This is only required by Java 11 raw builds.
1541-
* This method is not invoked by other Java levels.
1542-
*/
1543-
#if JAVA_SPEC_VERSION < 11
1538+
/* This JVM method is invoked by JCL native Java_java_lang_System_initProperties. */
1539+
#if !defined(OPENJ9_BUILD)
15441540
assert(!"JVM_InitProperties should not be called!");
1545-
#endif /* JAVA_SPEC_VERSION < 11 */
1541+
#endif /* !defined(OPENJ9_BUILD) */
15461542
return properties;
15471543
}
15481544

runtime/vm/vmprops.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,9 +1623,9 @@ getPlatformPropertyList(JNIEnv *env, const char *strings[], int propIndex)
16231623
char userhome[EsMaxPath];
16241624
wchar_t unicodeTemp[EsMaxPath];
16251625
int i = 0;
1626-
#if JAVA_SPEC_VERSION < 11
1626+
#if !defined(OPENJ9_BUILD)
16271627
char userdir[EsMaxPath];
1628-
#endif /* JAVA_SPEC_VERSION < 11 */
1628+
#endif /* !defined(OPENJ9_BUILD) */
16291629
wchar_t unicodeHome[EsMaxPath];
16301630
HANDLE process = 0;
16311631
HANDLE token = 0;
@@ -1634,7 +1634,7 @@ getPlatformPropertyList(JNIEnv *env, const char *strings[], int propIndex)
16341634

16351635
/* Hard coded file/path separators and other values */
16361636

1637-
#if JAVA_SPEC_VERSION < 11
1637+
#if !defined(OPENJ9_BUILD)
16381638
strings[propIndex++] = "file.separator";
16391639
strings[propIndex++] = "\\";
16401640

@@ -1644,7 +1644,7 @@ getPlatformPropertyList(JNIEnv *env, const char *strings[], int propIndex)
16441644
/* Get the Temp Dir name */
16451645
strings[propIndex++] = "java.io.tmpdir";
16461646
strings[propIndex++] = getTmpDir(env, &tempdir);
1647-
#endif /* JAVA_SPEC_VERSION < 11 */
1647+
#endif /* !defined(OPENJ9_BUILD) */
16481648

16491649
strings[propIndex++] = "user.home";
16501650
i = propIndex;
@@ -1711,7 +1711,7 @@ getPlatformPropertyList(JNIEnv *env, const char *strings[], int propIndex)
17111711
}
17121712
}
17131713

1714-
#if JAVA_SPEC_VERSION < 11
1714+
#if !defined(OPENJ9_BUILD)
17151715
/* Get the directory where the executable was started */
17161716
strings[propIndex++] = "user.dir";
17171717
if (0 == GetCurrentDirectoryW(EsMaxPath, unicodeTemp)) {
@@ -1720,7 +1720,7 @@ getPlatformPropertyList(JNIEnv *env, const char *strings[], int propIndex)
17201720
convertToUTF8(PORTLIB, unicodeTemp, userdir, EsMaxPath);
17211721
strings[propIndex++] = userdir;
17221722
}
1723-
#endif /* JAVA_SPEC_VERSION < 11 */
1723+
#endif /* !defined(OPENJ9_BUILD) */
17241724

17251725
result = createSystemPropertyList(env, strings, propIndex);
17261726
j9mem_free_memory(tempdir);
@@ -1737,9 +1737,9 @@ getPlatformPropertyList(JNIEnv *env, const char *strings[], int propIndex)
17371737
char *charResult = NULL;
17381738
char *envSpace = NULL;
17391739
jobject plist = NULL;
1740-
#if JAVA_SPEC_VERSION < 11
1740+
#if !defined(OPENJ9_BUILD)
17411741
char userdir[EsMaxPath] = {0};
1742-
#endif /* JAVA_SPEC_VERSION < 11 */
1742+
#endif /* !defined(OPENJ9_BUILD) */
17431743
char home[EsMaxPath] = {0};
17441744
char *homeAlloc = NULL;
17451745
J9VMThread *currentThread = (J9VMThread*)env;
@@ -1758,7 +1758,7 @@ getPlatformPropertyList(JNIEnv *env, const char *strings[], int propIndex)
17581758
}
17591759
#endif /* defined(J9ZOS390) */
17601760

1761-
#if JAVA_SPEC_VERSION < 11
1761+
#if !defined(OPENJ9_BUILD)
17621762
strings[propIndex++] = "file.separator";
17631763
strings[propIndex++] = "/";
17641764

@@ -1773,7 +1773,7 @@ getPlatformPropertyList(JNIEnv *env, const char *strings[], int propIndex)
17731773
} else {
17741774
strings[propIndex++] = charResult;
17751775
}
1776-
#endif /* JAVA_SPEC_VERSION < 11 */
1776+
#endif /* !defined(OPENJ9_BUILD) */
17771777

17781778
strings[propIndex++] = "user.home";
17791779
charResult = NULL;
@@ -1844,11 +1844,11 @@ getPlatformPropertyList(JNIEnv *env, const char *strings[], int propIndex)
18441844
propIndex += 1;
18451845
}
18461846

1847-
#if JAVA_SPEC_VERSION < 11
1847+
#if !defined(OPENJ9_BUILD)
18481848
/* Get the Temp Dir name */
18491849
strings[propIndex++] = "java.io.tmpdir";
18501850
strings[propIndex++] = getTmpDir(env, &envSpace);
1851-
#endif /* JAVA_SPEC_VERSION < 11 */
1851+
#endif /* !defined(OPENJ9_BUILD) */
18521852

18531853
plist = createSystemPropertyList(env, strings, propIndex);
18541854
if (NULL != envSpace) {
@@ -1876,12 +1876,12 @@ getSystemPropertyList(JNIEnv *env)
18761876
int propIndex = 0;
18771877
jobject propertyList = NULL;
18781878
#define PROPERTY_COUNT 137
1879-
#if JAVA_SPEC_VERSION < 11
1879+
#if !defined(OPENJ9_BUILD)
18801880
char *propertyKey = NULL;
18811881
const char *language = NULL;
18821882
const char *region = NULL;
18831883
const char *variant = NULL;
1884-
#endif /* JAVA_SPEC_VERSION < 11 */
1884+
#endif /* !defined(OPENJ9_BUILD) */
18851885
const char *strings[PROPERTY_COUNT] = {0};
18861886
#define USERNAME_LENGTH 128
18871887
char username[USERNAME_LENGTH] = {0};
@@ -1955,7 +1955,7 @@ getSystemPropertyList(JNIEnv *env)
19551955
strings[propIndex++] = "big";
19561956
#endif /* defined(J9VM_ENV_LITTLE_ENDIAN) */
19571957

1958-
#if JAVA_SPEC_VERSION < 11
1958+
#if !defined(OPENJ9_BUILD)
19591959
strings[propIndex++] = "sun.cpu.endian";
19601960
#if defined(J9VM_ENV_LITTLE_ENDIAN)
19611961
strings[propIndex++] = "little";
@@ -1990,7 +1990,7 @@ getSystemPropertyList(JNIEnv *env)
19901990
/* Get the timezone */
19911991
strings[propIndex++] = "user.timezone";
19921992
strings[propIndex++] = "";
1993-
#endif /* JAVA_SPEC_VERSION < 11 */
1993+
#endif /* !defined(OPENJ9_BUILD) */
19941994

19951995
/* Get the User name */
19961996
strings[propIndex++] = "user.name";

0 commit comments

Comments
 (0)