Skip to content

fix(java): externalize implicit java.lang bases onto ExternalModule nodes#666

Merged
vitali87 merged 2 commits into
mainfrom
fix/java-lang-base-externalization
Jul 8, 2026
Merged

fix(java): externalize implicit java.lang bases onto ExternalModule nodes#666
vitali87 merged 2 commits into
mainfrom
fix/java-lang-base-externalization

Conversation

@vitali87

@vitali87 vitali87 commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #665. Java implicitly imports java.lang, so a bare extends Exception or implements Runnable names a positively external base with no import statement to map it. The deferred-inherits resolver treated these as unresolvable module-anchored guesses and emitted nothing, losing real inheritance knowledge (class X extends Exception is one of the most common shapes in Java code).

A new JAVA_LANG_CLASS_NAMES table (a superset of the existing JAVA_WRAPPER_TYPES, so wrapper types stay single-sourced) is consulted by _resolve_deferred_parent_qn exactly like JS_GLOBAL_CLASS_NAMES is for JS globals: a bare base in the table resolves to java.lang.<Name> and emits onto an ExternalModule node, the same node an explicit import of it would mint. A bare base NOT in the table still emits nothing; knowledge and guesses are not the same.

Verification

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for implicitly imported java.lang types in Java class ingestion. It defines a set of java.lang class names and updates the deferred parent resolver to externalize these classes (such as Exception or Runnable) to java.lang instead of treating them as unresolvable guesses. New tests are added to verify this behavior. Feedback suggests adding Object to the list of java.lang class names to handle explicit inheritance from Object correctly.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread codebase_rag/constants.py
@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR preserves Java inheritance edges for implicit java.lang bases. The main changes are:

  • Adds a JAVA_LANG_CLASS_NAMES table that reuses existing Java wrapper type constants.
  • Resolves unresolved bare Java bases like Exception, Runnable, and Comparable to java.lang.<Name> ExternalModule nodes.
  • Adds tests for implicit java.lang extends and implements edges, plus an unknown-base negative case.
  • Updates lockfile package metadata.

Confidence Score: 5/5

Safe to merge with minimal risk.

The change is narrowly scoped, reuses existing ExternalModule behavior, and includes positive and negative tests for the updated path.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex ran the initial pytest attempt and captured a dependency setup blocker.
  • The dependency restore step ran without pymgclient, as shown in the uv-sync log.
  • After syncing, the targeted pytest was blocked by the missing mgclient import path.
  • A minimal mgclient.py stub was added to satisfy import-time references without changing Java parser behavior.
  • The targeted pytest for the mgclient stub completed successfully, showing 3 tests passed in 2.86s, and the ty-check reported all checks passed.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
codebase_rag/constants.py Adds a JAVA_LANG_CLASS_NAMES constant that reuses wrapper types and enumerates implicit java.lang bases for externalization.
codebase_rag/parsers/class_ingest/mixin.py Extends deferred inheritance resolution so unresolved bare Java bases in the java.lang table become ExternalModule targets.
codebase_rag/tests/test_java_lang_base_externalization.py Adds tests for implicit java.lang extends/implements external edges and the unknown-base negative case.
uv.lock Updates the editable package lock metadata version to match the project version.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
  participant Parser as Java class parser
  participant Deferred as Deferred inherits queue
  participant Resolver as _resolve_deferred_parent_qn
  participant Constants as JAVA_LANG_CLASS_NAMES
  participant Graph as ExternalModule graph node

  Parser->>Deferred: enqueue bare base guess (Exception/Runnable)
  Deferred->>Resolver: resolve after all classes registered
  Resolver->>Resolver: first-party lookup misses
  Resolver->>Constants: check raw base name
  Constants-->>Resolver: known java.lang type
  Resolver->>Graph: "ensure java.lang.<Name> ExternalModule"
  Resolver-->>Deferred: emit INHERITS/IMPLEMENTS edge
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
  participant Parser as Java class parser
  participant Deferred as Deferred inherits queue
  participant Resolver as _resolve_deferred_parent_qn
  participant Constants as JAVA_LANG_CLASS_NAMES
  participant Graph as ExternalModule graph node

  Parser->>Deferred: enqueue bare base guess (Exception/Runnable)
  Deferred->>Resolver: resolve after all classes registered
  Resolver->>Resolver: first-party lookup misses
  Resolver->>Constants: check raw base name
  Constants-->>Resolver: known java.lang type
  Resolver->>Graph: "ensure java.lang.<Name> ExternalModule"
  Resolver-->>Deferred: emit INHERITS/IMPLEMENTS edge
Loading

Reviews (1): Last reviewed commit: "fix(java): externalize implicit java.lan..." | Re-trigger Greptile

@vitali87
vitali87 merged commit dea4faf into main Jul 8, 2026
20 checks passed
@codecov-commenter

codecov-commenter commented Jul 8, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants