This is an automated email from the ASF dual-hosted git repository.
jshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new ee33ac6406 [MINOR] docs: clarify Java import guidance in AGENTS.md
(#10566)
ee33ac6406 is described below
commit ee33ac64065e62b7cdf806fc874b624ba4a6a9e4
Author: FANNG <[email protected]>
AuthorDate: Mon Mar 30 11:51:59 2026 +0800
[MINOR] docs: clarify Java import guidance in AGENTS.md (#10566)
### What changes were proposed in this pull request?
Clarify the Java import guidance in `AGENTS.md` by making the existing
rule more explicit:
- require normal `import` statements instead of inline fully qualified
class names when possible
- add concrete examples for disallowed inline usages such as
`java.nio.file.Paths`
- document the preferred handling when two classes share the same simple
name
### Why are the changes needed?
The previous wording only said to prioritize imports over fully
qualified class names, which was too weak and still allowed agents to
generate Java code with unnecessary inline FQNs. This update makes the
expectation explicit and reduces that behavior.
Fix: #10537
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Documentation only change. Verified the updated wording in `AGENTS.md`.
Co-authored-by: fanng <[email protected]>
---
AGENTS.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/AGENTS.md b/AGENTS.md
index 1f3c67d945..cae35a7b23 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -22,9 +22,11 @@
## General Coding Standards
- **Language**: Use English for all code, comments, and documentation.
- **Style**: Follow rigid Google Java Style. Run `./gradlew spotlessApply` to
format.
-- **Imports**: prioritizing standard imports over Fully Qualified Class Names
(FQN).
+- **Imports**: Always use normal `import` statements instead of Fully
Qualified Class Names (FQN) in Java code whenever possible.
- **Bad**: `org.apache.gravitino.rel.Table table = ...;`
- **Good**: `Table table = ...;` (with `import
org.apache.gravitino.rel.Table;`)
+ - Do not write inline types like `java.nio.file.Paths` or
`org.apache.xxx.Table` unless there is a real class name conflict that cannot
be resolved cleanly.
+ - If two classes share the same simple name, prefer imports plus small
refactors over keeping FQNs throughout the code.
- **Safety**: Use `@Nullable` annotations. Handle resources with
try-with-resources.
- **Logging**: Use SLF4J. No `System.out.println`.
- **Testing**:
@@ -65,4 +67,3 @@
- When hitting a problem, search memory first for known solutions before
debugging from scratch.
- After completing a task, save key findings and solutions to claude-mem for
future reference.
- Use multiple keyword combinations when searching (e.g., module name + issue
type, class name + error).
-