copilot-setting java.instructions.md

A set of Java 8 coding rules for syntax, exceptions, logging, concurrency, and resource handling.

In plain words
What is it for?
Use it when writing or reviewing .java files, especially code involving collections, strings, optional values, JDBC resources, or logging.
Why use it?
It prevents newer Java features and APIs from being introduced into a Java 8 project, including features that are difficult for the build to catch.

Instructions file for GitHub Copilot

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/zexion7873/copilot-setting/java
Clone the repo
git clone --depth 1 https://github.com/zexion7873/copilot-setting

Made for: GitHub Copilot.

Per session 1,326 This file is loaded in full into every session.
When invoked 1,326 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01326 $0.01326
Opus 5 $0.00663 $0.00663
Sonnet 5 $0.00265 $0.00265
Haiku 4.5 $0.00133 $0.00133

Measured yesterday against content hash e67f462e1e44, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

copilot-setting java.instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/instructions/java.instructions.md · 77 lines

How it starts

The opening of the file, as written. The whole thing — 77 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Java 8 Conventions

This project is Java 8. AI models default to modern Java, and that pull is strong — treat it as a bias to correct, not a preference to follow. A newer-version symbol won't compile, but the convention and correctness rules below fail only at review or runtime — don't lean on the build to catch them. If you are not certain something exists in Java 8, verify against this file before writing it — never guess.

Language Boundary (Java 9+ Forbidden)

  • var, records, sealed classes, text blocks, pattern matching
  • List.of(), Map.of(), Set.of() — use Arrays.asList() / Collections.unmodifiableMap() (note: Arrays.asList is fixed-size but element-mutable and allows nulls, unlike List.of — wrap in Collections.unmodifiableList when true immutability matters)
  • String.isBlank(), String.strip() — use StringUtils or .trim().isEmpty()
  • Optional.ifPresentOrElse(), Optional.stream()
  • Module system (module-info.java)
  • try-with-resources on a pre-declared effectively-final variable (Java 9) — declare the resource inside the try (...) parentheses instead; try-with-resources itself is Java 7 and stays mandatory for JDBC (instructions/sql.instructions.md)

Optional

  • Return type only — never field, parameter, or collection element
  • orElse() for cheap defaults; orElseGet() for expensive computation
  • orElseThrow(SomeException::new) over .get().get() throws cryptic NoSuchElementException. Note: Java 8 requires the supplier form orElseThrow(() -> new ...) — the no-arg orElseThrow() is Java 10+.

Streams

  • One operation per line; break chain at .collect()
  • Never modify external state inside forEach / map / filter
  • Prefer for loop for simple iterations with side effects

Date and Time

  • Use java.time (LocalDate, LocalDateTime, ZonedDateTime, Instant, Duration) for business logic, computation, and internal date handling — a Java 8 feature and the default for new code
  • Two hard exceptions on this stack — Hibernate 4.2 has no java.time support (that arrived in Hibernate 5's hibernate-java8 module) and JSTL 1.2 <fmt:formatDate> accepts only java.util.Date:
    • hbm.xml-mapped entity date fields stay java.util.Date / java.sql.Timestamp — a LocalDateTime field has no Hibernate 4.2 type mapping (fails, or silently persists as a serialized BLOB)
    • dates passed to a JSP for <fmt:formatDate> stay java.util.Date (instructions/jsp.instructions.md)
  • Convert at the service boundary with Date.from(instant) / Date.toInstant() between java.time logic and the persistence / view layers
  • Still avoid java.util.Calendar (mutable, error-prone) in new code

Read the full file on GitHub · 77 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 77 lines · 1,326 tokens per session scan A e67f462e1e44

Subscribe to this mod's changes

copilot-setting java.instructions.md is an instructions file published in the GitHub repository zexion7873/copilot-setting (1 stars, last pushed 28d ago), licensed MIT. It adds 1,326 tokens to every session, about $0.0066 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.