On Mon, 8 Dec 2025 15:11:08 GMT, Lukasz Kostyra <[email protected]> wrote:
>> This commit fixes the JVM crash caused by bad Clipboard data on Linux. >> >> On Windows the Clipboard is a bit more generic in how it operates - even if >> the MIME type mismatches, the Clipboard will accept any object and then >> return it. GTK is less generic in this regard (at least our Glass >> implementation) so for cases like text it requires us to fetch the String >> contents and set those directly onto the Clipboard. >> >> Moreover, `ClipboardContent` is simply an extension of `HashMap` which >> exposes `put()` and lets us assign whatever object we want to whatever MIME >> type we want. As such, if we follow the example code from the JDK issue, we >> would try to fetch String contents from something that is not a String, >> causing SIGSEGV. >> >> Fix was done by type-checking incoming `ClipboardContent` data. I saw that >> this can also happen in other content types than text, so I guarded those as >> well. If types are not what we expect them to be, the attempt to update the >> System Clipboard is silently discarded and the crash is avoided. According >> to my manual testing, as long as data types are correct everything seems to >> work fine. >> >> As a side-note, this also shows there is discrepancy in how `Clipboard` >> operates between platforms. We should unify that behavior, but that is a >> larger task which will be solved under >> [JDK-8373090](https://bugs.openjdk.org/browse/JDK-8373090). > > Lukasz Kostyra has updated the pull request incrementally with one additional > commit since the last revision: > > Review: Move jstring cast lgtm ------------- Marked as reviewed by arapte (Reviewer). PR Review: https://git.openjdk.org/jfx/pull/1999#pullrequestreview-3565555224
