github TNG/ArchUnit v0.23.0
ArchUnit 0.23.0

latest releases: v1.1.1, v1.2.2, v1.3.0...
2 years ago

Breaking Changes

  • As mentioned in Enhancements/Core ArchRules will now by default reject evaluating if the set passed to the should-clause is empty. This will break existing rules that don't check any elements in their should-clause. You can restore the old behavior by setting the ArchUnit property archRule.failOnEmptyShould=false

Bug Fixes

  • Fix wrong origins of JavaCall in case of bridge methods. If a class had two methods with the exact same name and parameter types the origin of a JavaCall was picked randomly from them. It now always picks the non-synthetic method (see #513)
  • Fix non-deterministic return value of JavaCodeUnit.getMethod(). In case of bridge methods there might be more than one method matching the exact same name and parameters. In these cases the result of getMethod() was random. It now always picks the non-synthetic method (see #256)
  • layeredArchitecture() will now allow to combine mayOnlyBeAccessedBy... and mayOnlyAccess.... Previously mayOnlyAccess... would forbid all incoming dependencies (see #739; thanks a lot to @hankem)

Enhancements

Core

  • Members targeted by AccessTarget are now resolved like the Java Reflection API would do it. Previously AccessTarget.resolve() would return a set of matching members, the new replacement AccessTarget.resolveMember() returns an optional member making it a lot easier to handle (see #722)
  • JavaClass now knows its methodReferencesFromSelf (e.g. Object::toString) and constructorReferencesFromSelf (e.g. Object::new) (see #215; thanks a lot to @KorSin)
  • ArchRules will now by default reject evaluating if the set passed to the should-clause is empty. This prevents implementation errors like picking a package in that()... that doesn't even exist and thus composing a rule that doesn't check anything (compare the user guide; see #774; thanks a lot @oberprah)
  • The automatic import dependency resolution now resolves classes missing from the import that are only referenced
    • as class object (e.g. Foo.class)
    • in a throws clause (e.g. someMethod() throws FooException)
    • in an instanceof check (e.g. obj instanceof Foo)
    • as an array component type (e.g. Foo[] array;)
    • as an annotation parameter (e.g. @SomeAnnotation(type = Foo.class))
    • as part of a generic type signature (e.g. List<? extends Foo>)
    • Furthermore, the resolution behavior can now be tweaked to resolve deeper or not resolve at all. Thus, users can decide between resolving additional types and performance (compare the user guide; see #728)
  • New predefined ImportOption to exclude package-info.class files (see #793; thanks a lot to @TomerFi)

Lang

  • Analogously to classes(), there now exists a method members()...should().containNumberOfElements(predicate) (see #179; thanks a lot to @oberprah)

Library

  • PlantUmlArchCondition now rejects files that don't specify any components at all or are of an invalid format (see #735; thanks a lot to @pfichtner)

JUnit

  • Tests can now be run if their classes are loaded by the context ClassLoader instead of the ArchUnit ClassLoader (see #781; thanks a lot to @stuartwdouglas)
  • New method Class<?> FieldSource.getJavaClass() to retrieve the declaring class of the respective field (see #800; thanks a lot to @famod)

Further Acknowledgement

  • thanks a lot to @marknp for improving the Javadoc on ArchConditions (see #725)
  • thanks a lot to @timtebeek for making the ArchUnit build work with JDK 17 (see #779)

Don't miss a new ArchUnit release

NewReleases is sending notifications on new releases.