[jdk11u-dev] RFR: 8269661: JNI_GetStringCritical does not lock char array [v2]

Aleksey Shipilev shade at openjdk.java.net
Wed Jul 14 08:21:24 UTC 2021


On Thu, 8 Jul 2021 19:13:19 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:

>> I would like to backport this patch to openjdk11u.
>> 
>> This patch mainly impacts Shenandoah GC, which is the only GC that supports object pinning and string deduplication.
>> 
>> The original patch does not apply cleanly, because it uses new string deduplication API introduced in jdk17. openjdk11u cannot prevent a string from being deduplicated, so it risks the possibility that string deduplication modifies string value while string critical session is in progress.
>> 
>> I purpose to take an alternative approach in openjdk11u: return a copy of string value when object pinning + string deduplication is enabled.
>> 
>> Test:
>> - [x] tier1 with UseShenandoahGC + UseStringDeduplication on Linux x86_64.
>
> Zhengyu Gu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Aleksey's comment

This looks good to me, but I still think we need to wait for more testing of these patches upstream.

src/hotspot/share/prims/jni.cpp line 3223:

> 3221:     // unpinning the wrong object.
> 3222:     (Universe::heap()->supports_object_pinning() &&
> 3223:      StringDedup::is_enabled());

This could be on the same line, I think.

src/hotspot/share/prims/jni.cpp line 3251:

> 3249:   oop s = JNIHandles::resolve_non_null(string);
> 3250:   jchar* ret;
> 3251:   if (!should_copy_string_value(s)) {

Can probably swap the branches to avoid `!` here? This would also be consistent with release.

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

Marked as reviewed by shade (Reviewer).

PR: https://git.openjdk.java.net/jdk11u-dev/pull/109


More information about the jdk-updates-dev mailing list