Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5037531

(metadata)package annotation has System.out.println()

XMLWordPrintable

    • b51
    • x86, sparc
    • solaris_2.1, windows_xp

      A System.out.println statement beeing executed when isAnnotationPresent(java.lang.Class) method was executed.

      The following is the code which shows, message on console.
      <console>
      viswadeep:/home/vv145429/tiger/bugs/metadata/pa 211 % java -version
      java version "1.5.0-auto-tiger"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-auto-tiger-112a)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b47, mixed mode)
      viswadeep:/home/vv145429/tiger/bugs/metadata/pa 212 % cat Attr1.java
      package pa;
      import static java.lang.annotation.ElementType.*;
      import java.lang.annotation.*;
      public @Retention(RetentionPolicy.RUNTIME) @interface Attr1 {
           String name();
           int version();;
      }
      viswadeep:/home/vv145429/tiger/bugs/metadata/pa 213 % cat package-info.java
      @Attr1(name="Viswadeep", version=10)
      package pa;
      viswadeep:/home/vv145429/tiger/bugs/metadata/pa 214 % cat Test1.java
      package pa;
      public class Test1 {
              public static void main(String[] arg) {
              Package pkg = pa.Test1.class.getPackage();
              pkg.isAnnotationPresent(pa.Attr1.class);
              pkg.getAnnotation(pa.Attr1.class);
              pkg.getAnnotations();
              pkg.getDeclaredAnnotations();
              }
        
      }
      viswadeep:/home/vv145429/tiger/bugs/metadata/pa 215 % javac *.java
      viswadeep:/home/vv145429/tiger/bugs/metadata/pa 216 % cd ..
      viswadeep:/home/vv145429/tiger/bugs/metadata 217 % java pa.Test1
      interface pa.package-info
      viswadeep:/home/vv145429/tiger/bugs/metadata 218 %
      </console>


      ###@###.### 2004-05-12

      J2SE Version (please include all output from java -version flag):

         java version "1.5.0-beta2"
         Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b50)
         Java HotSpot(TM) Client VM (build 1.5.0-beta2-b50, mixed mode, sharing)

      Does this problem occur on J2SE 1.4 or 1.4.1 or 1.4.2? Yes / No (pick one)

         n/a

      Operating System Configuration Information (be specific):

         Windows XP Professional Version 2002 Service Pack 1

      Hardware Configuration Information (be specific):

          Intel Pentium 4 2.66GHz 512M RAM

      Bug Description:

        Unnecessary System.out code remains in Package method getPackageInfo

      Steps to Reproduce (be specific):

        In an instance method on any class, code:
            Package pkg = this.getClass().getPackage();
            pkg.getAnnotation(TestPackage.class);
        You will see information print on the console.

        The source file for java.lang.Package includes this code:
            private Class getPackageInfo() {
              if (packageInfo == null) {
                  try {
                      packageInfo = Class.forName(pkgName + ".package-info",
      false, loader);
                      System.out.println(packageInfo);
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
              return packageInfo;
          }

            gafter Neal Gafter (Inactive)
            vvegurusunw Viswadeep Veguru (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: