/** * Answer a package, that is a member named <em>packageName</em> of the parent package * named <em>parentPackageName</em>. * Considers all packages that are visible to the current module, * i.e., we consider locally declared packages and packages in all modules * read by the current module. * Accessibility (via package exports) is <strong>not</strong> checked. */ public PackageBinding getPackage(char[][] parentPackageName, char[] packageName) { // Returns a package binding if there exists such a package in the context of this module and it is observable // A package is observable if it is declared in this module or it is exported by some required module if (parentPackageName == null || parentPackageName.length == 0) { return getVisiblePackage(null, packageName, true); } PackageBinding binding = null; PackageBinding parent = getVisiblePackage(parentPackageName); if (parent != null && parent != LookupEnvironment.TheNotFoundPackage) { binding = getVisiblePackage(parent, packageName, true); } if (binding != null) return addPackage(binding, false); return null; }
/** * Answer a package, that is a member named <em>packageName</em> of the parent package * named <em>parentPackageName</em>. * Considers all packages that are visible to the current module, * i.e., we consider locally declared packages and packages in all modules * read by the current module. * Accessibility (via package exports) is <strong>not</strong> checked. */ public PackageBinding getPackage(char[][] parentPackageName, char[] packageName) { // Returns a package binding if there exists such a package in the context of this module and it is observable // A package is observable if it is declared in this module or it is exported by some required module if (parentPackageName == null || parentPackageName.length == 0) { return getVisiblePackage(null, packageName); } PackageBinding binding = null; PackageBinding parent = getVisiblePackage(parentPackageName); if (parent != null && parent != LookupEnvironment.TheNotFoundPackage) { binding = getVisiblePackage(parent, packageName); } if (binding != null) return addPackage(binding, false); return null; }
/** * Return a package binding if there exists a package named name in this module's context and it can be seen by this module. * A package can be seen by this module if it is declared in this module or any other module read by this module * (JLS 7.4.3 for packages based on JLS 7.3 for compilation units). * Package exports are not considered for visibility check (only when checking "uniquely visible" (JLS 7.4.3)). * <p> * The returned package may be a {@link SplitPackageBinding}, if more than one package of the given name is visible. * </p> * <p> * When asked via the unnamed module or an automatic module all other named modules are considered visible. * </p> */ public PackageBinding getTopLevelPackage(char[] name) { // check caches: PackageBinding binding = this.declaredPackages.get(name); if (binding != null) return binding; binding = this.environment.getPackage0(name); if (binding != null) return binding; binding = getVisiblePackage(null, name, true); // remember: if (binding != null) { this.environment.knownPackages.put(name, binding); binding = addPackage(binding, false); } else { this.environment.knownPackages.put(name, LookupEnvironment.TheNotFoundPackage); } return binding; }
/** * Return a package binding if there exists a package named name in this module's context and it can be seen by this module. * A package can be seen by this module if it is declared in this module or any other module read by this module * (JLS 7.4.3 for packages based on JLS 7.3 for compilation units). * Package exports are not considered for visibility check (only when checking "uniquely visible" (JLS 7.4.3)). * <p> * The returned package may be a {@link SplitPackageBinding}, if more than one package of the given name is visible. * </p> * <p> * When asked via the unnamed module or an automatic module all other named modules are considered visible. * </p> */ public PackageBinding getTopLevelPackage(char[] name) { // check caches: PackageBinding binding = this.declaredPackages.get(name); if (binding != null) return binding; binding = this.environment.getPackage0(name); if (binding != null) return binding; binding = getVisiblePackage(null, name); // remember: if (binding != null) { this.environment.knownPackages.put(name, binding); binding = addPackage(binding, false); } else { this.environment.knownPackages.put(name, LookupEnvironment.TheNotFoundPackage); } return binding; }
return null; else return addPackage(pkg, false); else if (parent != null) binding = parent.addPackage(binding, this, false); return addPackage(binding, false);
return null; else return addPackage(pkg, false); else if (parent != null) binding = parent.addPackage(binding, this, false); return addPackage(binding, false);
this.knownPackages.put(compoundName[0], packageBinding); if (this.module != null) { packageBinding = this.module.addPackage(packageBinding, true); this.knownPackages.put(compoundName[0], packageBinding); // update in case of split package
this.knownPackages.put(compoundName[0], packageBinding); if (this.module != null) { packageBinding = this.module.addPackage(packageBinding, true); this.knownPackages.put(compoundName[0], packageBinding); // update in case of split package