380 /**
381 * Return the hash code computed from the package name.
382 * @return the hash code computed from the package name.
383 */
384 @Override
385 public int hashCode(){
386 return packageName().hashCode();
387 }
388
389 /**
390 * Returns the string representation of this Package.
391 * Its value is the string "package " and the package name.
392 * If the package title is defined it is appended.
393 * If the package version is defined it is appended.
394 * @return the string representation of the package.
395 */
396 @Override
397 public String toString() {
398 String spec = versionInfo.specTitle;
399 String ver = versionInfo.specVersion;
400 if (spec != null && spec.length() > 0)
401 spec = ", " + spec;
402 else
403 spec = "";
404 if (ver != null && ver.length() > 0)
405 ver = ", version " + ver;
406 else
407 ver = "";
408 return "package " + packageName() + spec + ver;
409 }
410
411 private Class<?> getPackageInfo() {
412 if (packageInfo == null) {
413 // find package-info.class defined by loader
414 String cn = packageName() + ".package-info";
415 Module module = module();
416 PrivilegedAction<ClassLoader> pa = module::getClassLoader;
417 ClassLoader loader = AccessController.doPrivileged(pa);
418 Class<?> c;
419 if (loader != null) {
420 c = loader.loadClass(module, cn);
421 } else {
422 c = BootLoader.loadClass(module, cn);
423 }
424
|
380 /**
381 * Return the hash code computed from the package name.
382 * @return the hash code computed from the package name.
383 */
384 @Override
385 public int hashCode(){
386 return packageName().hashCode();
387 }
388
389 /**
390 * Returns the string representation of this Package.
391 * Its value is the string "package " and the package name.
392 * If the package title is defined it is appended.
393 * If the package version is defined it is appended.
394 * @return the string representation of the package.
395 */
396 @Override
397 public String toString() {
398 String spec = versionInfo.specTitle;
399 String ver = versionInfo.specVersion;
400 if (spec != null && !spec.isEmpty())
401 spec = ", " + spec;
402 else
403 spec = "";
404 if (ver != null && !ver.isEmpty())
405 ver = ", version " + ver;
406 else
407 ver = "";
408 return "package " + packageName() + spec + ver;
409 }
410
411 private Class<?> getPackageInfo() {
412 if (packageInfo == null) {
413 // find package-info.class defined by loader
414 String cn = packageName() + ".package-info";
415 Module module = module();
416 PrivilegedAction<ClassLoader> pa = module::getClassLoader;
417 ClassLoader loader = AccessController.doPrivileged(pa);
418 Class<?> c;
419 if (loader != null) {
420 c = loader.loadClass(module, cn);
421 } else {
422 c = BootLoader.loadClass(module, cn);
423 }
424
|