1- # ArchUnitJava Codex proving repository
1+ # ArchUnitJava
22
3- This is a private, clean-room architecture-testing experiment for Java and a
4- proving ground for the ArchUnitDev2 coding workflow. It is inspired by the
5- ArchUnitEverything family and by the idea of testing architecture as ordinary
6- unit tests. It does not copy the upstream ArchUnit implementation and must not
7- be represented as the official ArchUnit project.
3+ Architecture testing for Java.
84
9- ## Goal
5+ ArchUnitJava is the Java member of the ArchUnitEverything family, alongside
6+ [ ArchUnitRuby] ( https://github.com/LukasNiessen/ArchUnitRuby ) ,
7+ [ ArchUnitPython] ( https://github.com/LukasNiessen/ArchUnitPython ) , and
8+ [ ArchUnitTS] ( https://github.com/LukasNiessen/ArchUnitTS ) . It turns compiled Java
9+ code into a dependency model and lets teams express architectural constraints
10+ as ordinary JUnit tests.
1011
11- Build a Java-native library that:
12+ > ** Status:** under active development. The build and product roadmap are in
13+ > place, but no architecture-analysis API or published artifact is available
14+ > yet.
1215
13- - imports compiled Java bytecode without loading or executing target classes;
14- - models packages, types, members, dependencies, and JPMS modules as immutable
15- deterministic values;
16- - exposes readable architecture rules usable from JUnit;
17- - reports every violation with bytecode and source evidence where available;
18- - remains useful both issue-by-issue and through a guarded coding campaign.
16+ ## Intended use
1917
20- The repository begins with 69 dependency-ordered issues. Each issue has a
21- human-readable specification under ` docs/issues/ ` and a machine-readable task
22- specification under ` .archunitdev/tasks/ ` . An issue is not campaign-ready until
23- a separate protected executable contract overlay exists. The issue list is the
24- product plan; generated files are review aids, not authority to weaken tests or
25- expand scope.
18+ The public API will make architecture rules read like sentences. The following
19+ illustrates the intended direction; it is not implemented yet:
2620
27- ## Technical baseline
21+ ``` java
22+ var rule = projectClasses()
23+ .inPackage(" com.example.api.." )
24+ .shouldNot()
25+ .dependOnClasses()
26+ .inPackage(" com.example.persistence.." );
2827
29- - JDK 25
30- - Java's standard ` java.lang.classfile ` API (provisional ADR)
31- - Maven Wrapper
32- - JUnit 6 for this repository's tests
33- - no runtime dependencies in the initial core
28+ assertPasses(rule);
29+ ```
30+
31+ The library is planned to cover:
3432
35- JDK 25 is an intentional proving-project choice. It gives the extractor the
36- standard Class-File API introduced in JDK 24, at the cost of not running on
37- older Java installations. That trade-off is recorded in
38- ` docs/adr/0001-bytecode-backend.md ` and must be reassessed before a public
39- release.
33+ - package, class, interface, annotation, record, sealed-type, and member rules;
34+ - dependencies from declarations, generic signatures, bytecode instructions,
35+ annotations, exceptions, lambdas, and method references;
36+ - cycle, layer, slice, public-interface, inheritance, annotation, and JPMS
37+ module policies;
38+ - JUnit integration, command-line checks, graph reports, CI result formats,
39+ baselines, and architecture metrics.
4040
41- ## Pipeline
41+ ## How it works
4242
4343``` text
44- CLASS FILES / JARS
45- |
46- v
47- EXTRACT -> immutable Java model + dependency evidence
48- |
49- v
50- PROJECT -> packages, slices, layers, modules, members
51- |
52- v
53- ASSERT -> typed violations
54- |
55- v
56- REPORT -> JUnit, CLI, SARIF, JSON, diagrams
44+ CLASS DIRECTORIES / JARS / MODULES
45+ |
46+ v
47+ EXTRACT
48+ |
49+ v
50+ PROJECT
51+ |
52+ v
53+ ASSERT
54+ |
55+ v
56+ REPORT
5757```
5858
59- Target bytecode is treated as untrusted input. Analysis must never load target
60- classes, execute build scripts, initialize classes, or invoke target code.
59+ ArchUnitJava analyzes compiled class files without loading or executing target
60+ classes. The initial implementation targets JDK 25 and uses the standard
61+ ` java.lang.classfile ` API. This keeps bytecode parsing on the Java platform,
62+ while the library's own immutable model remains independent of that parser.
63+
64+ Java-specific concerns are product semantics rather than incidental parser
65+ details. In particular, the implementation must account for:
66+
67+ - erased descriptors and optional generic ` Signature ` attributes;
68+ - visible, invisible, parameter, type-use, package, and default annotations;
69+ - bridge and synthetic members, nested types, anonymous types, and nestmates;
70+ - records and permitted subclasses of sealed types;
71+ - bytecode calls, field access, method handles, dynamic constants, and
72+ ` invokedynamic ` ;
73+ - classpath and module-path precedence, duplicate classes, external types,
74+ ordinary JARs, modular JARs, and multi-release JARs;
75+ - JPMS readability, exports, opens, service uses, and service providers.
76+
77+ ## Design principles
78+
79+ - The pipeline is ` EXTRACT -> PROJECT -> ASSERT -> REPORT ` .
80+ - Rules are immutable values; constructing a rule performs no I/O.
81+ - Projection and assertion are deterministic in-memory operations.
82+ - Violations retain structured evidence. Renderers own formatting and escaping.
83+ - Empty selections fail by default so misspelled scopes cannot silently pass.
84+ - Analysis never executes target builds, classes, annotation processors,
85+ bootstrap methods, or static initializers.
86+ - Unsupported or incomplete semantics are reported explicitly rather than
87+ guessed.
6188
62- ## Repository map
89+ ## Build
6390
64- - ` src/main/java/dev/archunitjava/ ` — product code
65- - ` src/test/java/dev/archunitjava/ ` — executable contracts
66- - ` docs/RESEARCH.md ` — Java and sibling-repository comparison
67- - ` docs/BACKLOG.md ` — dependency-ordered issue map
68- - ` docs/issues/ ` — GitHub issue bodies
69- - ` .archunitdev/tasks/ ` — machine-readable task specifications
70- - ` .archunitdev/contracts/ ` — operator-authored executable overlays (created
71- only when a task is ready to implement)
72- - ` .archunitdev/profile.toml ` — guarded build profile
73- - ` scripts/generate_backlog_assets.py ` — canonical backlog generator
91+ Requirements:
7492
75- ## Build
93+ - JDK 25
94+ - no separate Maven installation; the Maven Wrapper is included
95+
96+ On Linux or macOS:
7697
7798``` shell
7899./mvnw verify
@@ -84,10 +105,19 @@ On Windows:
84105.\mvnw.cmd verify
85106```
86107
87- The wrapper and a JDK 25 installation are required. CI is the portability
88- authority; local Java 8 installations are not sufficient.
108+ CI verifies the build on Windows and Linux.
109+
110+ ## Roadmap
111+
112+ The complete dependency-ordered product backlog is maintained in
113+ [ GitHub Issues] ( https://github.com/TristanKruse/ArchUnitJava/issues ) . The local
114+ [ backlog] ( docs/BACKLOG.md ) , [ Java research] ( docs/RESEARCH.md ) , and
115+ [ bytecode-backend decision] ( docs/adr/0001-bytecode-backend.md ) provide the
116+ technical context behind those issues.
89117
90- ## Current status
118+ ## Relationship to ArchUnit
91119
92- Repository and backlog scaffolding only. No architecture-analysis capability is
93- claimed yet.
120+ The original [ ArchUnit] ( https://www.archunit.org/ ) is the established Java
121+ architecture-testing library. ArchUnitJava is an independent implementation in
122+ the ArchUnitEverything family. The project does not copy ArchUnit's source code
123+ or claim drop-in API compatibility.
0 commit comments