Lazy Java
Translate a compact pseudocode language into Java while preserving explicit behavior. The pseudocode is a small, typed intermediate language: it reduces Java syntax overhead but keeps decisions that materially affect behavior visible. Do not treat vague prose as a complete specification.
Workflow
- Identify the requested deliverable: pseudocode, Java, or both. If the user supplies pseudocode, translate it. If they give prose, derive a concise pseudocode block first, then translate it unless they asked for Java only.
- Resolve the target Java version, project conventions, existing types, and build context from the repository when available. Follow the project's established style and APIs.
- Make behavior explicit in the pseudocode: inputs and types, return type, nullability, state changes, ordering, error cases, and boundary behavior where relevant. Consult references/language.md for syntax and translation rules.
- Translate each construct directly. Keep the pseudocode-to-Java mapping one-to-one where possible. Do not add behavior, dependencies, validation, persistence, concurrency, or error handling that the pseudocode does not specify.
- If an ambiguity can change observable behavior, ask a focused question or mark the exact unresolved choice before emitting implementation. For independent, low-impact details, choose a conventional Java default and state it briefly.
- Return Java in the requested form: complete file(s) when the user wants implementation, or focused snippets when they ask for an example. Include the pseudocode when it helps review the translation. Preserve comments that carry requirements; omit mechanical pseudocode narration.
Translation guarantees
- Preserve declared types, control flow, evaluation order, and collection ordering. Infer omitted generic arguments only when surrounding declarations or usage determine one unambiguous type; never copy pseudocode's
<>into a Java type declaration. - Map
Option<T>toOptional<T>only at API boundaries where that fits the surrounding code; otherwise use the project's established nullable-value convention. Never silently convert nullable values into unchecked assumptions. - Treat
requiresandensuresas contracts to implement or document. Do not claim runtime enforcement unless generated code actually enforces them. - Use Java standard-library types by default. Introduce a new class or dependency only when required by the requested design.
- Keep names and public visibility as stated. When omitted, choose the narrowest visibility that allows the requested use.
- For invalid or incomplete input, do not fabricate a “precise” implementation. Show the unresolved item and a proposed default, then proceed only when the choice is non-semantic or the user has authorized defaults.
Output
For a normal conversion, present the pseudocode (if derived from prose), then the Java. Add a short mapping note only for non-obvious decisions or assumptions. Do not claim the code compiles unless it was checked in the user's project or the claim is limited to a clearly self-contained snippet.