ArchUnit icon indicating copy to clipboard operation
ArchUnit copied to clipboard

Exception in thread "main" java.lang.IllegalStateException

Open junsignal opened this issue 3 years ago • 9 comments

Exception in thread "main" java.lang.IllegalStateException: Never found a JavaCodeUnit that matches supposed caller CodeUnit{name='zze', descriptor=(Ljava/lang/Iterable;)Lcom/google/android/gms/internal/firebase-perf/zzdn$zzb;, declaringClassName='com.google.android.gms.internal.firebase_perf.zzdn$zzb'} at com.tngtech.archunit.core.importer.AccessRecord$Factory.getCaller(AccessRecord.java:273) at com.tngtech.archunit.core.importer.AccessRecord$Factory.access$400(AccessRecord.java:61) at com.tngtech.archunit.core.importer.AccessRecord$Factory$4.get(AccessRecord.java:262) at com.tngtech.archunit.core.importer.AccessRecord$Factory$4.get(AccessRecord.java:259) at com.tngtech.archunit.thirdparty.com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:167) at com.tngtech.archunit.core.importer.AccessRecord$Factory$RawFieldAccessRecordProcessed.getCaller(AccessRecord.java:222) at com.tngtech.archunit.core.importer.ClassGraphCreator.tryProcess(ClassGraphCreator.java:206) at com.tngtech.archunit.core.importer.ClassGraphCreator.completeAccesses(ClassGraphCreator.java:165) at com.tngtech.archunit.core.importer.ClassGraphCreator.complete(ClassGraphCreator.java:119) at com.tngtech.archunit.core.importer.ClassFileProcessor.process(ClassFileProcessor.java:64) at com.tngtech.archunit.core.importer.ClassFileImporter.importLocations(ClassFileImporter.java:336) at com.transsion.utils.FileUtil.collectJavaClasses(FileUtil.java:214) at com.transsion.utils.FileUtil.collectJavaClasses(FileUtil.java:190) at com.transsion.App.runOnceBeforeClass(App.java:73) at com.transsion.App.main(App.java:36)

junsignal avatar Jan 05 '22 10:01 junsignal

Thanks for reporting this, can you provide some way to reproduce this? Which classes were you trying to import? Are you trying to import classes obfuscated by Proguard by any chance?

codecholeric avatar Jan 06 '22 09:01 codecholeric

Thanks for you answer, I can't upload apk. This apk is obfuscated by Porguard, but I don't have source code. I will try to analyze this apk and find the class file. then upload class file

junsignal avatar Jan 06 '22 11:01 junsignal

If these classes are irrelevant to your tests you could also think about just not importing them? Seems unlikely that this class is relevant for your architecture tests? How are you importing classes? With your app root package? Or just the classpath?

codecholeric avatar Jan 06 '22 14:01 codecholeric

But it would still be good to know how the class looks like that causes the exception :wink:

codecholeric avatar Jan 06 '22 14:01 codecholeric

the attachment is the class, please help me to debug this issue, zzdn$zzb.zip thank you

junsignal avatar Jan 10 '22 01:01 junsignal

A brief intermediate result: The exception didn't occurr with ArchUnit 0.22.0, but only since 29dccfe3249ae4a45b2d4e824d7b033a0f67155c.

hankem avatar Jan 10 '22 07:01 hankem

A brief intermediate result: The exception didn't occurr with ArchUnit 0.22.0, but only since 29dccfe.

i use the latest code, but still have the same problem. You test this class is ok?

junsignal avatar Jan 12 '22 06:01 junsignal

i use the latest code, but still have the same problem.

If I understand correctly, you don't still have the problem, but you only have it because you're using the lastet code. This exception only occurs since commit 29dccfe3249ae4a45b2d4e824d7b033a0f67155c, which is after the ArchUnit 0.22.0 release, but unfortunately before a11085a28a2656a93dd59545f260182d48a703f2, which you probably want to have because of https://github.com/TNG/ArchUnit/issues/754#issuecomment-1004343766.

So this is a summary of issues with ProGuard-modified classes in a timeline / git history:

Release / commit Issues with ProGuard-modified classes
(older) ?
ArchUnit 0.22.0 ProGuard-modified classes suffer from #754
29dccfe3249ae4a45b2d4e824d7b033a0f67155c ProGuard-modified classes suffer from #754 & #765 & #770
a11085a28a2656a93dd59545f260182d48a703f2 ProGuard-modified classes suffer from #765 & #770
(newer) ?

As a quick workaround, before we get things sorted (if we can at all, cf. https://github.com/TNG/ArchUnit/issues/754#issuecomment-1003529722): Could you test branch workaround-for-#765-and-#770, which is based on ArchUnit 0.22.0, but with a11085a28a2656a93dd59545f260182d48a703f2 cherry-picked? (That's commit d505c9005133283f7036add02ea3f20a72c1dae0, if that helps.)

hankem avatar Jan 12 '22 07:01 hankem

i use the latest code, but still have the same problem.

If I understand correctly, you don't still have the problem, but you only have it because you're using the lastet code. This exception only occurs since commit 29dccfe, which is after the ArchUnit 0.22.0 release, but unfortunately before a11085a, which you probably want to have because of #754 (comment).

So this is a summary of issues with ProGuard-modified classes in a timeline / git history:

Release / commit Issues with ProGuard-modified classes (older) ? ArchUnit 0.22.0 ProGuard-modified classes suffer from #754 29dccfe ProGuard-modified classes suffer from #754 & #765 & #770 a11085a ProGuard-modified classes suffer from #765 & #770 (newer) ? As a quick workaround, before we get things sorted (if we can at all, cf. #754 (comment)): Could you test branch workaround-for-#765-and-#770, which is based on ArchUnit 0.22.0, but with a11085a cherry-picked? (That's commit d505c90, if that helps.)

Thank you for you explain!

junsignal avatar Jan 12 '22 10:01 junsignal