RFR: Export InitializeEncoding for JVM access

Andrew Leonard andrew_m_leonard at uk.ibm.com
Wed Apr 4 12:17:23 UTC 2018

I would like to propose and find a sponsor for this change please, which 
is is export from libjava the JNU_InitializeEncoding() method, so that a 
JVM can initialize the platform encoding. Currently 
Java_java_lang_System_initProperties initializes the encoding, however for 

a generic JVM that will naturally provide it's own System implementation, 
the JVM needs a way to initialize this encoding directly. We can thus 
simply export it as per the change below.. There is precendence for doing 
this sort of export with Canonicalize().

diff --git a/src/java.base/share/native/libjava/jni_util.c 
--- a/src/java.base/share/native/libjava/jni_util.c
+++ b/src/java.base/share/native/libjava/jni_util.c
@@ -840,6 +840,15 @@
     String_value_ID = (*env)->GetFieldID(env, strClazz, "value", "[B");
+ * Export this method to allow JVM to initialize platform encoding 
+ */
+JNU_InitializeEncoding(JNIEnv *env, const char *encname)
+       InitializeEncoding(env, encname);
 JNIEXPORT jstring
 NewStringPlatform(JNIEnv *env, const char *str)

Andrew Leonard
Java Runtimes Development
IBM Hursley
IBM United Kingdom Ltd
Phone internal: 245913, external: 01962 815913
internet email: andrew_m_leonard at uk.ibm.com 

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

More information about the core-libs-dev mailing list