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

Aleksey Shipilev shade at openjdk.java.net
Thu Jul 8 15:27:53 UTC 2021


On Wed, 7 Jul 2021 18:09:53 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.

This looks okay to me, modulo minor comments. But I also think we need to wait for upstream to test the patches first.

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

> 3215: 
> 3216: // If a copy of string value should be returned instead
> 3217: static bool copy_string_value(oop str) {

I propose we call this `should_copy_string_value`.

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

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

The indenting here is odd, should probably be 2 spaces?

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

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


More information about the jdk-updates-dev mailing list