You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Resolve packages through realm imports and parent - #159
Fixes#126. Package.getPackage(name) resolves through the caller's class loader, and ClassRealm inherited ClassLoader.getPackage, which never consults imports or the parent realm, so JEXL's import pragma dropped imported packages.
getPackage and getPackages now apply the same routing as loadClass: own class path and base loader, then any import that would load a class in the package, whether a package import or a single-class import, then the parent where parent imports allow it. A package is visible exactly where a class in it would load, so a FilteredClassRealm exposes no package its filter hides. Import or parent cycles return null instead of recursing.
Verified: ClassRealmPackageTest fails on master (expected: <package a> but was: <null>) and passes on JDK 8, 21 and 27.
getPackage and getPackages now follow the same import and parent-import
rules as loadClass, so Package.getPackage sees imported packages. Do not
widen this past those rules: a package must never be visible where a
class in it is not.
Exact imports of classes in the unnamed package are omitted here. For an import such as "A", lastIndexOf('.') is -1, so loadClass("A") routes to the imported loader but both getPackage("") and getPackages() ignore that loader even though a loaded default-package class has a Package named "". Treat a non-empty, dotless import as a candidate class name when packageName is empty.
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
bugSomething isn't workingwontfixThis will not be worked on
2 participants
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.
Fixes #126.
Package.getPackage(name)resolves through the caller's class loader, andClassRealminheritedClassLoader.getPackage, which never consults imports or the parent realm, so JEXL'simportpragma dropped imported packages.getPackageandgetPackagesnow apply the same routing asloadClass: own class path and base loader, then any import that would load a class in the package, whether a package import or a single-class import, then the parent where parent imports allow it. A package is visible exactly where a class in it would load, so aFilteredClassRealmexposes no package its filter hides. Import or parent cycles return null instead of recursing.Verified:
ClassRealmPackageTestfails on master (expected: <package a> but was: <null>) and passes on JDK 8, 21 and 27.