Skip to content

IGNITE-13286 Support Java records in binary marshaller - #13391

Open
kush2439p wants to merge 2 commits into
apache:ignite-2.17from
kush2439p:codex/ignite-13286-records-hibernate7
Open

IGNITE-13286 Support Java records in binary marshaller#13391
kush2439p wants to merge 2 commits into
apache:ignite-2.17from
kush2439p:codex/ignite-13286-records-hibernate7

Conversation

@kush2439p

@kush2439p kush2439p commented Jul 22, 2026

Copy link
Copy Markdown

SummarynnRoutes Java records through Ignite's optimized Java-serialization path, avoiding Unsafe.objectFieldOffset() on immutable record fields.nn## Root causennHibernate 7 uses a serializable record for QueryResultsCacheImpl.CacheItem. Ignite's reflective binary marshaller attempts to obtain unsafe offsets for record fields, which modern JDKs reject.nn## Changesnn- Detect records without introducing a Java 16 compile-time dependency.n- Use OptimizedMarshaller for records.n- Make the developer warning accurately include records.n- Add a runtime-compiled serializable-record round-trip regression test; it runs on JDK 16+ and skips on older JDKs.nn## Verificationnn- Rebased on current ignite-2.17andgit diff --check passes.n- All 4,531 ignite-core production sources compile successfully on JDK 25.n- Focused test execution is blocked during unrelated full test compilation because JDK 25 removed Thread.suspend()andThread.resume(), which legacy Ignite tests still reference. A supported JDK 17 is not installed locally.n- Existing GitHub check failures are fork checkout-security refusals before code execution, not test failures.nnFixes #13286

@kush2439p

Copy link
Copy Markdown
Author

Fixes the Hibernate 7 query-cache incompatibility caused by Java records.
Hibernate’s QueryResultsCacheImpl.CacheItem is now a record, while Ignite’s reflective binary marshaller calls sun.misc.Unsafe.objectFieldOffset(), which is unsupported for record fields on modern JDKs.
This change detects records without adding a Java 16 compile-time dependency and routes them through Ignite’s optimized Java-serialization path, which supports serializable records.

@kush2439p
kush2439p marked this pull request as ready for review August 13, 2026 15:38
@kush2439p

Copy link
Copy Markdown
Author

Hi maintainers, following up on this PR since it has been open for several weeks without review. The record-handling fix and regression coverage are ready for review, and I am happy to rebase or revise the approach based on feedback. Thank you.

private static boolean isRecord(Class<?> cls) {
Class<?> superCls = cls.getSuperclass();

return superCls != null && "java.lang.Record".equals(superCls.getName());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you avoid to runtime check like : cls.isRecord() here ?

* @throws Exception If failed.
*/
@Test
public void testSerializableRecord() throws Exception {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apache ignite master currently support only 17 java - thus i suppose you can simplify this test and rewrite it like other presented here ? Also you need this PR agains master branch, not against ignite-2.17

@zstan

zstan commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

IGNITE-13286 - is different issue and not related to this activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants