Skip to content

DefaultMethodHandler to use the same class loader as the method`s dec… #471

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

Merged
merged 1 commit into from
Jan 18, 2023

Conversation

brohacz
Copy link

@brohacz brohacz commented Jan 12, 2023

When using spring-boot-devtools, the application is using two class loaders: Classes that don’t change (for example, those from third-party jars) are loaded into a base classloader. Classes that are under development are loaded into a restart classloader.

DefaultMethodHandler is loaded by the base classloader while the user classes are loaded via restart classloader. When DefaultMethdHandler tries to load the user class (using base classloader) if cannot find it and it results in NoSuchMethodException:

Caused by: java.lang.NoSuchMethodException: com.model.MyEntity$DefaultImpls.toDomain(com.model.MyEntity, org.ktorm.database.Database)
	at java.base/java.lang.Class.getMethod(Class.java:2108)
	at org.ktorm.entity.DefaultMethodHandler$Companion.forMethod$lambda-0(DefaultMethodHandler.kt:119)
	at java.base/java.util.Map.computeIfAbsent(Map.java:1003)
	at java.base/java.util.Collections$SynchronizedMap.computeIfAbsent(Collections.java:2682)
	at org.ktorm.entity.DefaultMethodHandler$Companion.forMethod(DefaultMethodHandler.kt:113)
	at org.ktorm.entity.EntityImplementation.handleMethodCall(EntityImplementation.kt:94)
	at org.ktorm.entity.EntityImplementation.invoke(EntityImplementation.kt:67)
	... 165 more

PR to fix DefaultMethodHandler to load the class using the same classloader as method's declaring class.

@vincentlauvlwj vincentlauvlwj merged commit 1442539 into kotlin-orm:v3.6.x Jan 18, 2023
@vincentlauvlwj
Copy link
Member

Thank you.

@brohacz brohacz deleted the classloader_fix branch February 2, 2023 09:58
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