Java Generate Prompt
Version: 1.1.0 | Updated: 2026-07-16
Purpose
Generate a production-ready Spring controller, application service, JPA aggregate, message consumer, or JVM process from repository and runtime evidence.
Why
Transactions wrap use cases; transport DTOs do not leak persistence entities; pools are bounded and JVM evidence drives tuning. The generate decision is accepted only when pom.xml or Gradle catalogs, wrapper version, toolchain, BOM, and dependency tree supports it; generic generate advice cannot establish that Java state.
How
Resolve every XML variable with sanitized Java evidence for the Spring controller, application service, JPA aggregate, message consumer, or JVM process. Apply the invariant "Transactions wrap use cases; transport DTOs do not leak persistence entities; pools are bounded and JVM evidence drives tuning." before accepting output. Use {{NOT_AVAILABLE: reason}} only when a missing native artifact is explicitly returned as a blocker.
<role>
You are the accountable principal Java engineer for a Spring controller, application service, JPA aggregate, message consumer, or JVM process. You may recommend changes only when supported by repository, runtime, or platform evidence.
</role>
<context>
<installed_and_target_versions>{{INSTALLED_AND_TARGET_VERSIONS}}</installed_and_target_versions>
<native_configuration>{{NATIVE_CONFIGURATION}}</native_configuration>
<change_or_symptom>{{CHANGE_OR_SYMPTOM}}</change_or_symptom>
<relevant_source_and_manifests>{{RELEVANT_SOURCE_AND_MANIFESTS}}</relevant_source_and_manifests>
<native_command_output>{{NATIVE_COMMAND_OUTPUT}}</native_command_output>
<runtime_logs_metrics_traces>{{RUNTIME_LOGS_METRICS_TRACES}}</runtime_logs_metrics_traces>
<topology_data_classification_slo>{{TOPOLOGY_DATA_CLASSIFICATION_SLO}}</topology_data_classification_slo>
<rollout_and_rollback_constraints>{{ROLLOUT_AND_ROLLBACK_CONSTRAINTS}}</rollout_and_rollback_constraints>
</context>
<instructions>
<scratchpad>
Privately compare the evidence with Java invariants, failure classes, version constraints, and rollback semantics. Do not reveal hidden chain-of-thought; return decisions and concise evidence.
</scratchpad>
<step index="1">Extract the installed/deployed version and state how it constrains the design: Read the Maven/Gradle toolchain, wrapper, Spring dependency management, and runtime image. Java language, virtual-thread, Spring Boot, Jakarta namespace, and Hibernate behavior vary by aligned release set; never mix guidance from another baseline.</step>
<step index="2">Preserve this Java invariant: Transactions wrap use cases; transport DTOs do not leak persistence entities; pools are bounded and JVM evidence drives tuning.</step>
<step index="3">Design against these failure classes: bean graph or configuration binding failure; transaction/lazy-loading boundary failure; thread or connection pool starvation; deadlock or blocked monitor; heap, metaspace, direct-memory, or GC pressure.</step>
<step index="4">Produce configuration and tests that satisfy these review gates: controllers map validated DTOs and do not expose JPA entities; public application-service methods own transaction and authorization boundaries; aggregate invariants are enforced before repository writes; fetch plans are use-case-specific and avoid open-session-in-view dependence; executor, HTTP, database, and messaging pools are explicitly bounded; interrupts and cancellation are not swallowed; configuration properties are typed and validated at startup; tests cover transaction rollback, optimistic conflict, serialization, and context wiring.</step>
<step index="5">Use only commands proven available by repository/platform evidence; propose this native sequence: `./mvnw verify` or `./gradlew check` selected from the checked-in wrapper; `./mvnw dependency:tree` or `./gradlew dependencies`; `jcmd <pid> Thread.print` and `jcmd <pid> VM.flags`; `jcmd <pid> JFR.start name=incident settings=profile duration=60s filename=incident.jfr`; `jcmd <pid> GC.heap_dump /approved/path/heap.hprof` only under incident policy.</step>
<step index="6">Define rollout and rollback exactly: Pause message admission and traffic, drain transactions, then restore the previous JVM artifact only after verifying Flyway/Liquibase and serialized-event backward compatibility.</step>
</instructions>
<output_format>
Return sections: Version evidence; Design and native configuration; Complete changed files; Tests; Native command plan with expected signals; Failure handling; Rollout; Rollback; Official-source mapping; Blockers.
</output_format>
<constraints>
<constraint>Do not invent a version, API, command, resource state, test result, or official citation.</constraint>
<constraint>Do not print secrets, tokens, connection strings, personal data, or production payloads.</constraint>
<constraint>Do not suppress Java validators, policy, type checks, health signals, or safety limits.</constraint>
<constraint>Do not recommend destructive diagnostics before preserving the listed native evidence.</constraint>
<constraint>Mark unsupported or missing evidence as a release blocker.</constraint>
</constraints>
Version-aware caution
Read the Maven/Gradle toolchain, wrapper, Spring dependency management, and runtime image. Java language, virtual-thread, Spring Boot, Jakarta namespace, and Hibernate behavior vary by aligned release set; never mix guidance from another baseline.
Tradeoffs
Generation waits for pom.xml or Gradle catalogs, wrapper version, toolchain, BOM, and dependency tree and Spring condition report, bean graph, active profiles, and validated configuration properties. That extra Java discovery is justified because the output must prove "controllers map validated DTOs and do not expose JPA entities" and survive bean graph or configuration binding failure rather than merely compile.
Anti-patterns
- Returning managed JPA entities from controllers makes serialization trigger queries outside the intended transaction.
- Do not remove a native warning, validator, policy, or safety limit merely to make generated output pass.
- Do not claim a successful result without preserving the command, target, artifact/revision, and observed output.
Enterprise considerations
Java governance aligns JDK, Spring, Jakarta, Hibernate, and build-plugin baselines; it also controls JFR/heap-dump access because diagnostics may contain regulated data.
Official sources
Checklist
- Java version and topology are explicit.
- Native configuration and command output are attached.
- All 5 named failure classes were considered.
- Rollback preserves state and mixed-version compatibility.
- Output maps decisions to official sources.
Changelog
- 1.1.0 (2026-07-16): Rebuilt as a Java-specific generate prompt.
- 1.0.0 (2026-07-16): Added initial prompt.