Skip to content

fix: resolve Java wildcard imports from JBang dependencies - #182

Open
maxandersen wants to merge 1 commit into
jbangdev:mainfrom
maxandersen:163-java-synthetic-library
Open

maxandersen wants to merge 1 commit into
jbangdev:mainfrom
maxandersen:163-java-synthetic-library

Conversation

@maxandersen

Copy link
Copy Markdown
Contributor

Fixes #163.

Problem

Java wildcard/on-demand imports (import example.*) did not resolve classes from JBang dependency JARs, while explicit imports and fully-qualified names worked.

Root cause (diagnosed by JetBrains — IDEA-393077)

JBangLibraryProvider exposed the classpath as a plain SyntheticLibrary. Only a JavaSyntheticLibrary contributes its roots to PackageIndex (fileSetsByPackagePrefix); any other SyntheticLibrary gets DummyWorkspaceFileSetData, so JavaFileManagerImpl.findPackage("example") returns null. On-demand imports whose reference resolves to null contribute nothing, leaving wildcard-imported types unresolved. Explicit imports/FQNs keep working because they use JavaFullClassNameIndex, which does not depend on the package-prefix storage.

"Make JBangSyntheticLibrary extend JavaSyntheticLibrary instead of SyntheticLibrary." — Mikhail Pyltsin, JetBrains

Fix

JBangSyntheticLibrary now extends JavaSyntheticLibrary(comparisonId, sourceRoots, binaryRoots, excludedRoots).

Test

JBangLibraryProviderTest.testProviderExposesJavaSyntheticLibraryForPackageIndex asserts the provider returns a JavaSyntheticLibrary — red before the change, green after. Full suite passes.

Changelog

[Unreleased] Fixed entry added.

Expose the JBang classpath as a JavaSyntheticLibrary instead of a plain
SyntheticLibrary so its JAR roots enter PackageIndex. A plain SyntheticLibrary
gets DummyWorkspaceFileSetData, leaving findPackage() null, so Java
wildcard/on-demand imports (import example.*) never resolved while explicit
imports and fully-qualified names did.

Fixes jbangdev#163

Reported-and-diagnosed-by: JetBrains (IDEA-393077)
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ai-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: c394d57e-db61-443d-9f0b-a47e2d18134b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Known limitation: wildcard imports do not resolve JBang dependencies

1 participant