-
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
Dependency do not support constant #515
Comments
I believe that the statement from #298 (comment) is unfortunately still true:
Somebody needs to find some time to implement #309. |
I just played around a little and I think it will work to inspect |
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
Did you resolve this issue? I find the problem still exist in com.tngtech.archunit:archunit:0.17.0 |
Are you sure? Can you show me an example? AFAIS something like this should now be detected, right?
What is your concrete case? |
Like class One {
public static final String TAG = "Hello";
}
class Two {
private String tag = One.TAG;
} If I try to get |
There is some confusion: Since ArchUnit 0.16.0, The bytecode for your example
initializes
That's why the usage of the primitive constant |
Thanks for your detailed explanation! Hope that you can implement this soon. :) |
I tried to scan a class's dependency using
JavaClass.directDependenciesToSelf
but I found the constant in the class which is using by another class was not in the dependency list.What should I do?
The text was updated successfully, but these errors were encountered: