Skip to content

Fix IllegalAccessError analyzing Java compiled with --add-exports (#837)#1714

Merged
eed3si9n merged 2 commits into
sbt:developfrom
jozanek:fix/issue-837-inner-class-illegalaccess
Jun 20, 2026
Merged

Fix IllegalAccessError analyzing Java compiled with --add-exports (#837)#1714
eed3si9n merged 2 commits into
sbt:developfrom
jozanek:fix/issue-837-inner-class-illegalaccess

Conversation

@jozanek

@jozanek jozanek commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #837.

The crash is ClassToAPI reflectively loading an inner class whose superclass is inaccessible (a module-internal type reached via --add-exports); the IllegalAccessError propagated out and aborted the whole compile.

  • ClassToAPI.loadInnerClass now catches IllegalAccessError alongside ClassNotFoundException/NoClassDefFoundError, so an inner class that can't be linked in the analysis classloader is logged and skipped instead of crashing. Structural errors (VerifyError/ClassFormatError/…) are intentionally left to propagate as genuine classfile problems.
  • JavaAnalyze no longer silently drops a class that fails reflective loading: it records the product, member-ref dependencies, and direct inheritance dependencies (superclass + interfaces) for it, derived from the classfile. Canonical names are reconstructed from the InnerClasses attribute.
  • module-info.class is explicitly excluded from that fallback (it is deliberately not analyzed as a class).

Known limitation / follow-up

The un-loadable class still gets no api.ClassLike recorded (API extraction is reflection-based and the class can't be loaded), so name-hashing can miss dependents when that class's own public shape changes. Pre-existing and shared with the NoClassDefFoundError case (sbt/sbt#117). The complete fix — classfile-based Java API extraction — would also resolve #151 and #1697 and is best done separately.

@jozanek

jozanek commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Follow up PR: jozanek#1

@jozanek

jozanek commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

And here's phase 3: jozanek#2

P.S. I already signed CLA, feel free to rerun the last failing step in workflow.

@eed3si9n eed3si9n left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@eed3si9n eed3si9n merged commit a8581c1 into sbt:develop Jun 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants