Skip to content

Fix #887: use module-info.java directly #888

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 34 commits into from
Apr 12, 2025
Merged

Conversation

cowtowncoder
Copy link
Member

So, fix #887 by adding 2 module-info.javas like for other modules.

@cowtowncoder
Copy link
Member Author

Not quite working yet: seems like build is working, but test build has an issue: odd failure

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.9.25:test-compile (test-compile) on project jackson-module-kotlin: Compilation failure
[ERROR] Module junit cannot be found in the module graph

given that junit is for JUnit 4 which is not used by Kotlin module (JUnit 5, jupiter, is).

Hopefully can figure it out and this is done.

...
...

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…ackson-module-kotlin into tatu/3.0/887-use-module-info

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@cowtowncoder
Copy link
Member Author

Ok. So, no matter what I do, it looks like only "regular" module-info.java from src/main/java/ takes effect: one from src/test/java (for tests not so much). All the instructions I have seen suggest adding it under java dirs (not kotlin). I have tried adding source directory config for Maven plug-ins and all, in vain. Almost ready to give up...

...

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
...

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
...

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…bind as of 3.0.0-rc3)
@cowtowncoder cowtowncoder marked this pull request as ready for review April 12, 2025 00:46
@cowtowncoder cowtowncoder changed the title (WIP) Fix #887: use module-info.java directly Fix #887: use module-info.java directly Apr 12, 2025
@cowtowncoder cowtowncoder merged commit 70d8a3a into 3.x Apr 12, 2025
9 checks passed
@cowtowncoder cowtowncoder deleted the tatu/3.0/887-use-module-info branch April 12, 2025 01:42
@cowtowncoder
Copy link
Member Author

cc @k163377 -- was able to finally make module work with JPMS without Moditect. I hope this won't cause issues with IDEs (I've noticed support for JPMS still bit immature by IDEs).

@k163377 k163377 mentioned this pull request Apr 13, 2025
@k163377
Copy link
Contributor

k163377 commented Apr 13, 2025

@cowtowncoder
Hmmm, I tried but something might be broken.
For the following commit, the error occurs only when executed with Intellij's JUnit.
c138d61

It seems that all setAccess() fails.
For example, the following stack trace is output

tools.jackson.databind.exc.InvalidDefinitionException: Failed to call `setAccess()` on Method 'creator-n6I9qnQ' (of class `tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator.HandledByJacksonTest$NullableObjectMiltiParamCreator`) due to `java.lang.reflect.InaccessibleObjectException`, problem: Unable to make public static final tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator.HandledByJacksonTest$NullableObjectMiltiParamCreator tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator.HandledByJacksonTest$NullableObjectMiltiParamCreator.creator-n6I9qnQ(int,int) accessible: module tools.jackson.module.kotlin does not "exports tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator" to module tools.jackson.databind
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); byte offset: #UNKNOWN]

	at [email protected]/tools.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:60)
	at [email protected]/tools.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:263)
	at [email protected]/tools.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:151)
	at [email protected]/tools.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:414)
	at [email protected]/tools.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:360)
	at [email protected]/tools.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:265)
	at [email protected]/tools.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
	at [email protected]/tools.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:158)
	at [email protected]/tools.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:712)
	at [email protected]/tools.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:2809)
	at [email protected]/tools.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2627)
	at [email protected]/tools.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1600)
	at tools.jackson.module.kotlin/tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator.HandledByJacksonTest.nullableObjectNullableCreatorTest(HandledByJacksonTest.kt:60)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.IllegalArgumentException: Failed to call `setAccess()` on Method 'creator-n6I9qnQ' (of class `tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator.HandledByJacksonTest$NullableObjectMiltiParamCreator`) due to `java.lang.reflect.InaccessibleObjectException`, problem: Unable to make public static final tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator.HandledByJacksonTest$NullableObjectMiltiParamCreator tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator.HandledByJacksonTest$NullableObjectMiltiParamCreator.creator-n6I9qnQ(int,int) accessible: module tools.jackson.module.kotlin does not "exports tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator" to module tools.jackson.databind
	at [email protected]/tools.jackson.databind.util.ClassUtil.checkAndFixAccess(ClassUtil.java:857)
	at [email protected]/tools.jackson.databind.deser.bean.CreatorCollector._fixAccess(CreatorCollector.java:268)
	at [email protected]/tools.jackson.databind.deser.bean.CreatorCollector.verifyNonDup(CreatorCollector.java:344)
	at [email protected]/tools.jackson.databind.deser.bean.CreatorCollector.addPropertyCreator(CreatorCollector.java:169)
	at [email protected]/tools.jackson.databind.deser.BasicDeserializerFactory._addSelectedPropertiesBasedCreator(BasicDeserializerFactory.java:503)
	at [email protected]/tools.jackson.databind.deser.BasicDeserializerFactory._constructDefaultValueInstantiator(BasicDeserializerFactory.java:221)
	at [email protected]/tools.jackson.databind.deser.BasicDeserializerFactory.findValueInstantiator(BasicDeserializerFactory.java:171)
	at [email protected]/tools.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:256)
	... 14 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public static final tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator.HandledByJacksonTest$NullableObjectMiltiParamCreator tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator.HandledByJacksonTest$NullableObjectMiltiParamCreator.creator-n6I9qnQ(int,int) accessible: module tools.jackson.module.kotlin does not "exports tools.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator" to module tools.jackson.databind
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:200)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:194)
	at [email protected]/tools.jackson.databind.util.ClassUtil.checkAndFixAccess(ClassUtil.java:843)
	... 21 more

I will check some more as it may be due to local settings, but do you know anything about this?

@cowtowncoder
Copy link
Member Author

Not directly, but I think disabling use of module system (JPMS) for Junit is probably needed.
In pom.xml it's this line:

<useModulePath>false</useModulePath>

but I wonder if IDEA has some similar setting?

@k163377
Copy link
Contributor

k163377 commented Apr 14, 2025

@cowtowncoder
Thanks, this seemed to be a bug caused by Intellij.
https://youtrack.jetbrains.com/issue/IDEA-290669

I will try the workaround shown in the link during the holidays.

@cowtowncoder
Copy link
Member Author

Good luck @k163377 !

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.

None yet

2 participants