Chapter 2 · Java
Java: What is Artificial Intelligence?
Run this example
Edit and run the java example
Change the source and run it here. Use the output panel to compare your result with the expected highlights below.
Output
Run the code to see output here.
Java - AI System Classifier
Purpose
The Java implementation mirrors the Python contract using records, enums, and explicit validation. It classifies field, method, model family, capability, application, and authority independently.
Contract
SystemProfile contains asserted evidence. validate rejects unsupported or
contradictory assertions, including:
- claiming an LLM without a Deep Learning mechanism,
- using
Generative AIas a model family, - granting decision or execution authority without authorization, escalation, and rollback controls.
Verified Behavior
Four profiles pass and the intentionally invalid automatic-approval profile
reports multiple errors. A successful run must therefore contain both VALID
and ERROR lines.
Architect Extension
Replace string values with versioned domain enums and serialize the profile as JSON attached to an architecture decision record. Add a policy that prevents a release when asserted authority exceeds the controls declared for the workflow.