-
Notifications
You must be signed in to change notification settings - Fork 321
Description
For a big GWT-based application I am defining an architecture check to prevent that our junior programmers accidentally reference classes that are not GWT-serializable and the resulting objects then can not make it "over the wire" (which then throws exceptions at runtime).
For this I am using a layer-check like so:
@ArchTest
void checkGWTAccess(JavaClasses classes) {
LayeredArchitecture layers = Architectures.layeredArchitecture()
.layer("Client").definedBy("..client..")
.layer("Shared").definedBy("..shared..")
... <many entries omitted here> ...
;
ArchRule rule = layers
.whereLayer("Client").mayOnlyAccessLayers("Shared", "DomDtos", "DomBase", "DomConfig",
... <many entries omitted here> ...
);
;
rule.check(classes);
"In principle" this works ok EXCEPT that I am still getting errors for all fields that are arrays of basic types or collections of basic types (i.e. e.g. int[] digits;
, char[] buffer;
, List<Integer> allowedValues;
) as well as methods returning such arrays or collections (i.e. e.g. int[] methodA(...) {...}
, String[] methodB(...) {...}
, List<Character> methodC(...) {...}
, etc.).
These error read e.g.:
Field <com.example.client.ui.components.converter.TimeFieldConverter.timeNumberDigits> has type <[I> in (TimeFieldConverter.java:0)
IMHO this is a bug in ArchUnit. I can not fancy any reason arrays of basic types should possibly violate any layer-check rule.
In case this is NOT a bug:
How can one exclude these types from a <layer>.mayOnlyAccessLayers(...)
-check?
Or - alternatively - can one include these types to the list of allowed layers (if it's possible to identify the and/or declare them as "layer")?
The purpose is simply, to avoid getting any rule violations for these references, so that the tests run green.