System.out.println lead to assert(resolved_method->method_holder()->is_linked()) failed: must be linked
Leslie Zhai
zhaixiang at loongson.cn
Thu Dec 13 08:57:35 UTC 2018
Hi David,
Thanks for your kind response!
在 2018/12/13 上午11:26, David Holmes 写道:
> On 13/12/2018 12:58 pm, Leslie Zhai wrote:
>> Hi Coleen,
>>
>> System.out.println was added on purpose:
>
> You can't do that. You can't put any code in the Object constructor
> (or various other places - static initializers etc) because nothing
> else is initialized yet - including String, System etc etc. The code
> will hit exceptions and try to throw but can't because the Exception
> classes can't be initialized yet.
I will use other way to debug during vm initializing.
>
>
> The assert is what we always see when trying to throw an exception
> before the VM is initialized enough to throw exceptions.
>
> Cheers,
> David
> ----
>
>> diff -r 8449dc3cbebe src/java.base/share/classes/java/lang/Object.java
>> --- a/src/java.base/share/classes/java/lang/Object.java Mon Nov 12
>> 15:34:21 2018 +0800
>> +++ b/src/java.base/share/classes/java/lang/Object.java Thu Dec 13
>> 10:40:33 2018 +0800
>> @@ -47,7 +47,9 @@
>> * Constructs a new object.
>> */
>> @HotSpotIntrinsicCandidate
>> - public Object() {}
>> + public Object() {
>> + System.out.println("DEBUG: on purpose");
>> + }
>>
>> /**
>> * Returns the runtime class of this {@code Object}. The returned
>>
>> ----- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< ---
>>
>> Then it lead to the assertion error, similar as:
>>
>> https://bugs.openjdk.java.net/browse/JDK-8069005
>>
>> $ ./build/linux-x86_64-normal-server-fastdebug/jdk/bin/java -version
>> # To suppress the following error report, specify this argument
>> # after -XX: or in .hotspotrc: SuppressErrorAt=/linkResolver.cpp:1380
>> #
>> # A fatal error has been detected by the Java Runtime Environment:
>> #
>> # Internal Error
>> (/home/zhaixiang/jdk/src/hotspot/share/interpreter/linkResolver.cpp:1380),
>> pid=11090, tid=11091
>> # assert(resolved_method->method_holder()->is_linked()) failed: must
>> be linked
>>
>> ----- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< ---
>>
>> But just add java.lang.Object initialization in bootstrapping the jvm
>> couldn't fix the issue:
>>
>> diff -r 2c5bf37c8f8e src/hotspot/share/runtime/thread.cpp
>> --- a/src/hotspot/share/runtime/thread.cpp Thu Dec 06 20:39:03
>> 2018 +0800
>> +++ b/src/hotspot/share/runtime/thread.cpp Thu Dec 13 10:44:56
>> 2018 +0800
>> @@ -3524,6 +3524,7 @@
>> // Initialize java_lang.System (needed before creating the thread)
>> initialize_class(vmSymbols::java_lang_System(), CHECK);
>> // The VM creates & returns objects of this class. Make sure it's
>> initialized.
>> + initialize_class(vmSymbols::java_lang_Object(), CHECK);
>> initialize_class(vmSymbols::java_lang_Class(), CHECK);
The order of initialize_class give the illusion that java_lang_String,
java_lang_System had been initilized. Sorry for that!
Thanks,
Leslie Zhai
>> initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK);
>> Handle thread_group = create_initial_thread_group(CHECK);
>>
>> Please give me some advice how to fix the issue, thanks a lot!
>>
>> Regards,
>>
>> Leslie Zhai
>>
>>
More information about the hotspot-dev
mailing list