On Fri, 25 Jun 2021 13:40:54 GMT, Yi Yang <yy...@openjdk.org> wrote:

> Prefer using ByteOrder to compute byte order for StringUTF16 to determining 
> byte order by native method StringUTF16.isBigEndian.

Hi Aleksey, do you have a concrete issue/discussion about bootstrapping 
problems? I don't see it because I can build JDK and passes tier1 tests w/o 
problems. But I admit this may cause potential problems. In order to reduce 
potential risks, how about changing the class initialization orders, i.e. 
initialize UUnsafeConstants_klas earlier, which seems reasonable:


void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
  TraceTime timer("Initialize java.lang classes", TRACETIME_LOG(Info, 
startuptime));

  if (EagerXrunInit && Arguments::init_libraries_at_startup()) {
    create_vm_init_libraries();
  }

+#ifdef ASSERT
+  InstanceKlass *k = vmClasses::UnsafeConstants_klass();
+  assert(k->is_not_initialized(), "UnsafeConstants should not already be 
initialized");
+#endif
+
+  // initialize the hardware-specific constants needed by Unsafe
+  initialize_class(vmSymbols::jdk_internal_misc_UnsafeConstants(), CHECK);
+  jdk_internal_misc_UnsafeConstants::set_unsafe_constants();

  initialize_class(vmSymbols::java_lang_String(), CHECK);

  // Inject CompactStrings value after the static initializers for String ran.
  java_lang_String::set_compact_strings(CompactStrings);
  ...

-------------

PR: https://git.openjdk.java.net/jdk/pull/4596

Reply via email to