-
Notifications
You must be signed in to change notification settings - Fork 300
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
Violations not detected by ArchUnit #446
Comments
ArchUnit does currently not handle all the information the bytecode would offer, e.g. the constant pool (compare #131). |
Many thanks for your reply. ArchUnit is an excellent tool, hope can be improved further. |
So far ArchUnit has not been able to detect the pure usage of class objects as dependencies. E.g. the following example would not have detected a dependency on `Evil`, since besides the reference to the class object no further dependency on `Evil` (like a field access or method call) has occurred. ``` class Example { final Map<Class<?>, Object> association = Map.of(Evil.class, anything); } ``` With this PR `JavaClass` now knows its `referencedClassObjects`, including the respective line number. Furthermore class objects are now parts of the `dependencies{From/To}Self` of a `JavaClass`. Resolves: #309 Issue: #446 Resolves: #474 Resolves: #515
So far ArchUnit has not been able to detect the pure usage of class objects as dependencies. E.g. the following example would not have detected a dependency on `Evil`, since besides the reference to the class object no further dependency on `Evil` (like a field access or method call) has occurred. ``` class Example { final Map<Class<?>, Object> association = Map.of(Evil.class, anything); } ``` With this PR `JavaClass` now knows its `referencedClassObjects`, including the respective line number. Furthermore class objects are now parts of the `dependencies{From/To}Self` of a `JavaClass`. Resolves: #309 Issue: #446 Resolves: #474 Resolves: #515
I'm gonna close this for now, since it's a little undirected. (2) has been implemented meanwhile, about (1) I'm not sure, because the compiler might also remove it if it's unused and and unused local variable will also never cause a real maintenance problem. For (3) I have created #710 |
Trying to understand why ArchUnit does not detect the cases below...
(1) I guess this one is because the compiler remove that unused variable at all and nothing is translated to bycode.
(3) Casting is just for the compiler nothing goes into bytecode.
(2) Why is not detected? can this be fixed?
Thanks!!!
The text was updated successfully, but these errors were encountered: