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

Add companion classes to Kotlin reflective hierarchy registration #38062

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Jan 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Comment on lines +269 to +285
// for Kotlin classes, we need to register the nested classes as well because companion classes are very often necessary at runtime
if (capabilities.isPresent(Capability.KOTLIN) && isKotlinClass(info)) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
Class<?>[] declaredClasses = classLoader.loadClass(info.name().toString()).getDeclaredClasses();
for (Class<?> clazz : declaredClasses) {
DotName dotName = DotName.createSimple(clazz.getName());
addClassTypeHierarchy(combinedIndexBuildItem, capabilities, reflectiveHierarchyBuildItem, source,
dotName, dotName,
processedReflectiveHierarchies, unindexedClasses,
finalFieldsWritable, reflectiveClass, visits);
}
} catch (ClassNotFoundException e) {
log.warnf(e, "Failed to load Class %s", info.name().toString());
}

}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move it to the kotlin extension? It feels weird to have this in core

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, the handling of reflection is in the core

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps the kotlin extension may produce additional build items for this step to consume?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way I see it, that's really too much work for almost no gain.
I'm certainly not going to do it, but I won't stop anyone else from taking it up :)

Copy link
Member

Choose a reason for hiding this comment

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

I think we can live with it. We can revisit if one day we move the Kotlin extension outside of the core repository.

Comment on lines +269 to +285
// for Kotlin classes, we need to register the nested classes as well because companion classes are very often necessary at runtime
if (capabilities.isPresent(Capability.KOTLIN) && isKotlinClass(info)) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
Class<?>[] declaredClasses = classLoader.loadClass(info.name().toString()).getDeclaredClasses();
for (Class<?> clazz : declaredClasses) {
DotName dotName = DotName.createSimple(clazz.getName());
addClassTypeHierarchy(combinedIndexBuildItem, capabilities, reflectiveHierarchyBuildItem, source,
dotName, dotName,
processedReflectiveHierarchies, unindexedClasses,
finalFieldsWritable, reflectiveClass, visits);
}
} catch (ClassNotFoundException e) {
log.warnf(e, "Failed to load Class %s", info.name().toString());
}

}
Copy link
Member

Choose a reason for hiding this comment

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

I think we can live with it. We can revisit if one day we move the Kotlin extension outside of the core repository.

Copy link

quarkus-bot bot commented Jan 5, 2024

Failing Jobs - Building e185df8

Status Name Step Failures Logs Raw logs Build scan
✔️ JVM Tests - JDK 17 🔍
JVM Tests - JDK 17 Windows Build Failures Logs Raw logs 🔍
✔️ JVM Tests - JDK 21 🔍

Full information is available in the Build summary check run.
You can consult the Develocity build scans.

Failures

⚙️ JVM Tests - JDK 17 Windows #

- Failing: extensions/smallrye-reactive-messaging-amqp/deployment 
! Skipped: integration-tests/reactive-messaging-amqp integration-tests/virtual-threads/amqp-virtual-threads 

📦 extensions/smallrye-reactive-messaging-amqp/deployment

io.quarkus.smallrye.reactivemessaging.amqp.AnonymousAmqpTest.test line 30 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Condition with io.quarkus.smallrye.reactivemessaging.amqp.AnonymousAmqpTest was not fulfilled within 1 minutes.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)

io.quarkus.smallrye.reactivemessaging.amqp.SecuredAmqpTest.test line 28 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Condition with io.quarkus.smallrye.reactivemessaging.amqp.SecuredAmqpTest was not fulfilled within 10 seconds.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)

io.quarkus.smallrye.reactivemessaging.amqp.devmode.AmqpDevModeTest.testCodeUpdate line 44 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Condition with io.quarkus.smallrye.reactivemessaging.amqp.devmode.AmqpDevModeTest was not fulfilled within 1 minutes.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)

io.quarkus.smallrye.reactivemessaging.amqp.devmode.nohttp.AmqpDevModeNoHttpTest.testConsumerUpdate line 77 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: 
Assertion condition defined as a io.quarkus.smallrye.reactivemessaging.amqp.devmode.nohttp.AmqpDevModeNoHttpTest 
Expecting size of:

io.quarkus.smallrye.reactivemessaging.amqp.devmode.nohttp.AmqpDevModeNoHttpTest.testProducerUpdate line 48 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: 
Assertion condition defined as a io.quarkus.smallrye.reactivemessaging.amqp.devmode.nohttp.AmqpDevModeNoHttpTest 
Expecting size of:

@geoand geoand merged commit a7a835a into quarkusio:main Jan 5, 2024
@quarkus-bot quarkus-bot bot added this to the 3.7 - main milestone Jan 5, 2024
@geoand geoand deleted the #37957 branch January 9, 2024 06:48
@gsmet gsmet modified the milestones: 3.7 - main, 3.6.5 Jan 9, 2024
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.

Serialization failure in native mode when Kotlin companion object used
3 participants