Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new SerializationFeature.register API with GraalVM/Mandrel >=21.3 #19520

Merged
merged 1 commit into from
Aug 24, 2021

Conversation

zakkak
Copy link
Contributor

@zakkak zakkak commented Aug 19, 2021

oracle/graal#3050 introduces a number of changes
around the internal APIs that are being used by Quarkus to register
classes for serialization thus breaking serialization support when using
21.3-dev

These changes are:

  1. SerializationRegistry class has been moved from
    com.oracle.svm.core.jdk.serialize to
    com.oracle.svm.reflect.serialize

  2. addReflections method moved from
    com.oracle.svm.reflect.serialize.hosted.SerializationFeature to
    com.oracle.svm.reflect.serialize.hosted.SerializationBuilder and
    became private

oracle/graal#3050 also introduces
SerializationFeature.register(Class<?>... classes) which is available
as a public API (not internal) and can save us from having to keep up
with the internal APIs as new releases come out. This PR leverages the
new API to register classes for serialization when using GraalVM/Mandrel >=21.3.

Closes #19338

@zakkak
Copy link
Contributor Author

zakkak commented Aug 19, 2021

CI run with 21.3-dev: https://github.com/graalvm/mandrel/actions/runs/1148784045 (please don't merge before it completes)

@zakkak zakkak marked this pull request as draft August 20, 2021 09:34
@zakkak
Copy link
Contributor Author

zakkak commented Aug 20, 2021

The tests are looking good, but I am switching this to draft to make it use SerializationFeature.register(Class<?>... classes) with GraalVM >=21.3

@galderz
Copy link
Member

galderz commented Aug 20, 2021

Great work with the fix and thanks for spotting this early on @zakkak! 👏

@zakkak zakkak force-pushed the fix-serialization-support branch 2 times, most recently from e7f1750 to dfedfb2 Compare August 20, 2021 11:51
@zakkak zakkak changed the title SerializationRegistry and addReflections moved in GraalVM 21.3-dev Use new SerializationFeature.register API with GraalVM/Mandrel >=21.3 Aug 20, 2021
@zakkak
Copy link
Contributor Author

zakkak commented Aug 20, 2021

New CI run to test branch with 21.3: https://github.com/graalvm/mandrel/actions/runs/1150563667

@zakkak zakkak marked this pull request as ready for review August 20, 2021 11:53
@gsmet
Copy link
Member

gsmet commented Aug 20, 2021

Yeah, thanks @zakkak ! I'll have a look early next week.

@quarkus-bot
Copy link

quarkus-bot bot commented Aug 20, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building dfedfb2

Status Name Step Test failures Logs Raw logs
Gradle Tests - JDK 11 Windows Build Test failures Logs Raw logs
JVM Tests - JDK 11 Build Test failures Logs Raw logs
✔️ JVM Tests - JDK 16

Full information is available in the Build summary check run.

Test Failures

⚙️ Gradle Tests - JDK 11 Windows #

📦 integration-tests/gradle

io.quarkus.gradle.devmode.DotEnvQuarkusDevModeConfigurationTest.main line 13 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Condition with lambda expression in io.quarkus.test.devmode.util.DevModeTestUtils that uses java.util.function.Supplier, java.util.function.Supplierjava.util.concurrent.atomic.AtomicReference, java.util.concurrent.atomic.AtomicReferencejava.lang.String, java.lang.Stringboolean was not fulfilled within 1 minutes.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:166)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:26)
	at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:939)
	at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:908)
	at io.quarkus.test.devmode.util.DevModeTestUtils.getHttpResponse(DevModeTestUtils.java:130)
	at io.quarkus.gradle.devmode.QuarkusDevGradleTestBase.getHttpResponse(QuarkusDevGradleTestBase.java:126)
	at io.quarkus.gradle.devmode.QuarkusDevGradleTestBase.getHttpRes...

⚙️ JVM Tests - JDK 11 #

📦 integration-tests/hibernate-reactive-panache

io.quarkus.it.panache.reactive.PanacheFunctionalityTest.testPanacheFunctionality line 49 - More details - Source on GitHub

java.net.SocketTimeoutException: Read timed out
	at java.base/java.net.SocketInputStream.socketRead0(Native Method)
	at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
	at java.base/java.net.SocketInputStream.read(SocketInputStream.java:168)
	at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
	at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:161)
	at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:82)
	at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:276)
	at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
	at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
	at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
	at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeade...

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

Spotted a small typo and added a question.

@zakkak I suppose we want this in 2.2?

ofMethod("com.oracle.svm.reflect.serialize.hosted.SerializationFeature", "addReflections", void.class,
Class.class, Class.class),
clazz, objectClass);
ResultHandle addRedlectionsArgs2 = tc.newArray(Class.class, tc.load(2));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ResultHandle addRedlectionsArgs2 = tc.newArray(Class.class, tc.load(2));
ResultHandle addReflectionsArgs2 = tc.newArray(Class.class, tc.load(2));

ResultHandle addRedlectionsArgs2 = tc.newArray(Class.class, tc.load(2));
tc.writeArrayValue(addRedlectionsArgs2, 0, clazz);
tc.writeArrayValue(addRedlectionsArgs2, 1, objectClass);
tc.invokeVirtualMethod(invokeMethodDescriptor, addReflectionsLookupMethod, tc.loadNull(), addRedlectionsArgs2);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
tc.invokeVirtualMethod(invokeMethodDescriptor, addReflectionsLookupMethod, tc.loadNull(), addRedlectionsArgs2);
tc.invokeVirtualMethod(invokeMethodDescriptor, addReflectionsLookupMethod, tc.loadNull(), addReflectionsArgs2);

ResultHandle addRedlectionsArgs2 = tc.newArray(Class.class, tc.load(2));
tc.writeArrayValue(addRedlectionsArgs2, 0, clazz);
tc.writeArrayValue(addRedlectionsArgs2, 1, objectClass);
tc.invokeVirtualMethod(invokeMethodDescriptor, addReflectionsLookupMethod, tc.loadNull(), addRedlectionsArgs2);
Copy link
Member

Choose a reason for hiding this comment

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

What is the tc.loadNull() supposed to be?

Copy link
Contributor Author

@zakkak zakkak Aug 23, 2021

Choose a reason for hiding this comment

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

invoke's first argument is the this object to invoke the method on, so since this is a static method I am passing null as the first argument.

If the underlying method is static, then the specified obj argument is ignored. It may be null.
See https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/reflect/Method.html#invoke(java.lang.Object,java.lang.Object...)

oracle/graal#3050 introduces a number of changes
around the internal APIs that are being used by Quarkus to register
classes for serialization thus breaking serialization support when using
21.3-dev

These changes are:

1. `SerializationRegistry` class has been moved from
   `com.oracle.svm.core.jdk.serialize` to
   `com.oracle.svm.reflect.serialize`

2. `addReflections` method moved from
   `com.oracle.svm.reflect.serialize.hosted.SerializationFeature` to
   `com.oracle.svm.reflect.serialize.hosted.SerializationBuilder` and
   became `private`

oracle/graal#3050 also introduces
`SerializationFeature.register(Class<?>... classes)` which is available
as a public API (not internal) and can save us from having to keep up
with the internal APIs as new releases come out. This PR leverages the
new API to register classes for serialization when using GraalVM/Mandrel
>=21.3.

Closes quarkusio#19338
@zakkak zakkak force-pushed the fix-serialization-support branch from dfedfb2 to 4921b9f Compare August 23, 2021 18:57
@zakkak
Copy link
Contributor Author

zakkak commented Aug 23, 2021

Spotted a small typo and added a question.

Good catch! Fixed and answered respectively :)

@zakkak I suppose we want this in 2.2?

Yes we will eventually need it in 2.2.

@gsmet gsmet merged commit 77e8f88 into quarkusio:main Aug 24, 2021
@quarkus-bot quarkus-bot bot added this to the 2.3 - main milestone Aug 24, 2021
@gsmet
Copy link
Member

gsmet commented Aug 24, 2021

Thanks, nice work!

@zakkak zakkak deleted the fix-serialization-support branch August 24, 2021 11:49
@gsmet gsmet modified the milestones: 2.3 - main, 2.2.0.Final Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CoreSerializationInGraalITCase of integration test Main fails with latest GraalVM
3 participants