< prev index next >

src/java.base/share/classes/java/lang/Package.java

Print this page




 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 
 425             if (c != null) {
 426                 packageInfo = c;
 427             } else {
 428                 // store a proxy for the package info that has no annotations
 429                 class PackageInfoProxy {}
 430                 packageInfo = PackageInfoProxy.class;
 431             }
 432         }
 433         return packageInfo;
 434     }
 435 
 436     /**




 437      * @throws NullPointerException {@inheritDoc}
 438      * @since 1.5
 439      */

 440     public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
 441         return getPackageInfo().getAnnotation(annotationClass);
 442     }
 443 
 444     /**
 445      * {@inheritDoc}
 446      * @throws NullPointerException {@inheritDoc}
 447      * @since 1.5
 448      */
 449     @Override
 450     public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
 451         return AnnotatedElement.super.isAnnotationPresent(annotationClass);
 452     }
 453 
 454     /**




 455      * @throws NullPointerException {@inheritDoc}
 456      * @since 1.8
 457      */
 458     @Override
 459     public  <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationClass) {
 460         return getPackageInfo().getAnnotationsByType(annotationClass);
 461     }
 462 
 463     /**



 464      * @since 1.5
 465      */

 466     public Annotation[] getAnnotations() {
 467         return getPackageInfo().getAnnotations();
 468     }
 469 
 470     /**




 471      * @throws NullPointerException {@inheritDoc}
 472      * @since 1.8
 473      */
 474     @Override
 475     public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass) {
 476         return getPackageInfo().getDeclaredAnnotation(annotationClass);
 477     }
 478 
 479     /**
 480      * @throws NullPointerException {@inheritDoc}
 481      * @since 1.8
 482      */
 483     @Override
 484     public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationClass) {
 485         return getPackageInfo().getDeclaredAnnotationsByType(annotationClass);
 486     }
 487 
 488     /**



 489      * @since 1.5
 490      */

 491     public Annotation[] getDeclaredAnnotations()  {
 492         return getPackageInfo().getDeclaredAnnotations();
 493     }
 494 
 495     /**
 496      * Construct a package instance for an unnamed module
 497      * with the specified version information.
 498      *
 499      * @apiNote
 500      * This method should not be called to define a Package for named module.
 501      *
 502      * @param name the name of the package
 503      * @param spectitle the title of the specification
 504      * @param specversion the version of the specification
 505      * @param specvendor the organization that maintains the specification
 506      * @param impltitle the title of the implementation
 507      * @param implversion the version of the implementation
 508      * @param implvendor the organization that maintains the implementation
 509      * @param sealbase code source where this Package comes from
 510      * @param loader defining class loader




 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 
 425             if (c != null) {
 426                 packageInfo = c;
 427             } else {
 428                 // store a proxy for the package info that has no annotations
 429                 class PackageInfoProxy {}
 430                 packageInfo = PackageInfoProxy.class;
 431             }
 432         }
 433         return packageInfo;
 434     }
 435 
 436     /**
 437      * {@inheritDoc}
 438      * <p>Note that any annotation returned by this method is a
 439      * declaration annotation.
 440      *
 441      * @throws NullPointerException {@inheritDoc}
 442      * @since 1.5
 443      */
 444     @Override
 445     public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
 446         return getPackageInfo().getAnnotation(annotationClass);
 447     }
 448 
 449     /**
 450      * {@inheritDoc}
 451      * @throws NullPointerException {@inheritDoc}
 452      * @since 1.5
 453      */
 454     @Override
 455     public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
 456         return AnnotatedElement.super.isAnnotationPresent(annotationClass);
 457     }
 458 
 459     /**
 460      * {@inheritDoc}
 461      * <p>Note that any annotations returned by this method are
 462      * declaration annotations.
 463      *
 464      * @throws NullPointerException {@inheritDoc}
 465      * @since 1.8
 466      */
 467     @Override
 468     public  <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationClass) {
 469         return getPackageInfo().getAnnotationsByType(annotationClass);
 470     }
 471 
 472     /**
 473      * {@inheritDoc}
 474      * <p>Note that any annotations returned by this method are
 475      * declaration annotations.
 476      * @since 1.5
 477      */
 478     @Override
 479     public Annotation[] getAnnotations() {
 480         return getPackageInfo().getAnnotations();
 481     }
 482 
 483     /**
 484      * {@inheritDoc}
 485      * <p>Note that any annotation returned by this method is a
 486      * declaration annotation.
 487      *
 488      * @throws NullPointerException {@inheritDoc}
 489      * @since 1.8
 490      */
 491     @Override
 492     public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass) {
 493         return getPackageInfo().getDeclaredAnnotation(annotationClass);
 494     }
 495 
 496     /**
 497      * @throws NullPointerException {@inheritDoc}
 498      * @since 1.8
 499      */
 500     @Override
 501     public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationClass) {
 502         return getPackageInfo().getDeclaredAnnotationsByType(annotationClass);
 503     }
 504 
 505     /**
 506      * {@inheritDoc}
 507      * <p>Note that any annotations returned by this method are
 508      * declaration annotations.
 509      * @since 1.5
 510      */
 511     @Override
 512     public Annotation[] getDeclaredAnnotations()  {
 513         return getPackageInfo().getDeclaredAnnotations();
 514     }
 515 
 516     /**
 517      * Construct a package instance for an unnamed module
 518      * with the specified version information.
 519      *
 520      * @apiNote
 521      * This method should not be called to define a Package for named module.
 522      *
 523      * @param name the name of the package
 524      * @param spectitle the title of the specification
 525      * @param specversion the version of the specification
 526      * @param specvendor the organization that maintains the specification
 527      * @param impltitle the title of the implementation
 528      * @param implversion the version of the implementation
 529      * @param implvendor the organization that maintains the implementation
 530      * @param sealbase code source where this Package comes from
 531      * @param loader defining class loader


< prev index next >