Record classfile-derived API for un-loadable Java classes (#837)#1
Closed
jozanek wants to merge 15 commits into
Closed
Record classfile-derived API for un-loadable Java classes (#837)#1jozanek wants to merge 15 commits into
jozanek wants to merge 15 commits into
Conversation
[2.x] ci: sbt 2.0.0-RC16
ci: sbt-scalafmt 2.6.1
[2.x] Update contraband to 0.9.0
Co-authored-by: eugene yokota <eed3si9n@gmail.com>
…lity (sbt#1720) Co-authored-by: Jozef Koval <jozef.koval@beone.com>
…exports (sbt#1714) 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 --------- Co-authored-by: Jozef Koval <jozef.koval@beone.com>
eec8263 to
f587ec7
Compare
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on the sbt#837 crash-fix branch (upstream PR sbt#1714); the diff here is Phase 2 only. To be retargeted to
developfor upstream once sbt#1714 merges.sbt#1714 stops the crash and records products + member-ref + inheritance deps for Java classes that can't be reflectively loaded (e.g. compiled with
--add-exports), but records noapi.ClassLikefor them — so name-hashing can miss dependents when such a class's own public shape changes.This adds
ClassfileToAPI, which builds the class+moduleapi.ClassLikepair directly from the classfile (no reflection) for un-loadable classes, wired intoJavaAnalyzevia areadClassfileAPIcallback (no-op default; production wires it inAnalyzingJavaCompiler).Conservative fold — deterministic, and only needs to change when the class's public shape changes (need not match the reflection hash byte-for-byte):
static finalconstant values (Singleton encoding, likeClassToAPI)Signature(raw), checked exceptions (throws), declared annotation types — folded into a synthetic annotationmainOut of scope (Phase 3 full classfile-API parser): generic parsing vs raw folding, annotation element values, enum-children modeling.
Tests in
ClassfileToAPISpecification(deterministic + shape-sensitive hash, fullJavaAnalyzepath, static/instance split, malformed-descriptor degradation, main detection).