Skip to content
This repository was archived by the owner on Nov 9, 2026. It is now read-only.

Commit 6fef3cf

Browse files
wzekinclaude
andcommitted
fix(java): make JavaSpec.NameSpace nil-safe when file is unknown
JavaSpec.NameSpace dereferenced `file.Package` on the in-repo branch without a nil check; callers that pass `c.files[file]` can legitimately return nil for files the collector hasn't registered (e.g. recursive exportSymbol on a symbol whose URI wasn't scanned). Guard the deref so NameSpace returns an empty PkgPath in that case instead of panicking. Fixes TestJavaIPC_InterfaceKindAndImplements on this branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5ec9265 commit 6fef3cf

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎lang/java/spec.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ func (c *JavaSpec) NameSpace(path string, file *uniast.File) (string, string, er
117117
if modInfo != nil {
118118
modName = modInfo.Coordinates
119119
}
120-
return modName, file.Package, nil
120+
var pkg uniast.PkgPath
121+
if file != nil {
122+
pkg = file.Package
123+
}
124+
return modName, pkg, nil
121125
}
122126

123127
func (c *JavaSpec) ShouldSkip(path string) bool {

0 commit comments

Comments
 (0)