-
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
Fail to detect cycles when the depending variable is final
or in interface
#298
Comments
beFreeOfCycles()
fail to detect cycle when the depending variable is final
or in interfacefinal
or in interface
ArchUnit currently does not detect such a dependency because it is not (so directly) present in the bytecode: a When I change your example constants to this bytecode
(Likewise for So In #168, it was argued that such a dependency is not the most harmful one. When I however change public static final Object TEST = new Object();
Could you confirm that your ArchUnit test would catch such a case as you'd expect? |
FYI: The dependency is actually present in
So ArchUnit could, in principle, be extended to even catch those dependencies at some point. |
I tried this and it still doesn't treat it as a cycle. Once I removed both of the
|
That's a good thing to hear! |
Sorry for being not explicit enough! 😉 If you don't use To maybe illustrate this even better, consider the following example: class Dependency {
static final int INLINABLE_CONSTANT = 42; // primitive
static final Integer NON_INLINABLE_CONSTANT = 42; // Object
}
class ClassWithOnlyCompileTimeDependency {
public static void main(String...args) {
System.out.println(Dependency.INLINABLE_CONSTANT);
}
}
class ClassWithCompileAndRuntimeDependency {
public static void main(String...args) {
System.out.println(Dependency.NON_INLINABLE_CONSTANT);
}
} If you compile those and delete
|
Thanks Manfred! |
I've opened #309 with the gist of this issue 😉 |
I'm at
0.13.0
.When I have 2 class:
The
slices().matching("pkg.(**)..").should().beFreeOfCycles();
won't report any violations.Is this a bug or you guys made the decision intentionally?
The text was updated successfully, but these errors were encountered: