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

'Never found a JavaCodeUnit' for Kotlin 'groupingBy' in 0.23.0 #807

Closed
pkubowicz opened this issue Feb 21, 2022 · 2 comments
Closed

'Never found a JavaCodeUnit' for Kotlin 'groupingBy' in 0.23.0 #807

pkubowicz opened this issue Feb 21, 2022 · 2 comments

Comments

@pkubowicz
Copy link
Contributor

Using 'groupingBy' in Kotlin:

val duplicatedIso = countries.groupingBy { it.iso }

works in ArchUnit 0.22.0 but crashes 0.23.0:

java.lang.IllegalStateException: Never found a JavaCodeUnit that matches supposed origin
CodeUnit{name='keyOf', descriptor=(Ljava/lang/Object;)Ljava/lang/Object;, declaringClassName='com.example.CountryValidator$failOnDuplicatedIso$$inlined$groupingBy$1'}
	at com.tngtech.archunit.core.importer.AccessRecord$Factory.getOrigin(AccessRecord.java:325)
	at com.tngtech.archunit.core.importer.AccessRecord$Factory.access$1200(AccessRecord.java:67)
	at com.tngtech.archunit.core.importer.AccessRecord$Factory$10.get(AccessRecord.java:314)
	at com.tngtech.archunit.core.importer.AccessRecord$Factory$10.get(AccessRecord.java:311)
	at com.tngtech.archunit.thirdparty.com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:167)
	at com.tngtech.archunit.core.importer.AccessRecord$Factory$RawAccessRecordProcessed.getOrigin(AccessRecord.java:282)
	at com.tngtech.archunit.core.importer.ClassGraphCreator.tryProcess(ClassGraphCreator.java:146)

A project that reproduces the bug: https://github.com/pkubowicz/archunit-accessrecord-bug (see GitHub action result).

@codecholeric
Copy link
Collaborator

Thanks a lot for raising the issue and in particular for taking the effort to provide a sample 😃 This is likely due to the more strict search for matching methods to disambiguate bridge methods from real methods 🤔 I guess in Kotlin there is some compiler magic that doesn't match anymore now, but I'll look into it 👍

@codecholeric
Copy link
Collaborator

I think I found the culprit: It seems to happen if the generic signature of the return type of a method is out of sync with the descriptor 😬 I.e. The descriptor says the return type is Object, but the signature says it's String from the generic context. I'll try to release a fix within the next couple of days...

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

No branches or pull requests

2 participants