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

java.awt.PageAttributes.*Type.toString() returns wrong string.

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: acR10002 Date: 04/14/2000


      The method
            public String toString()
      of 5 classes:
            java.awt.PageAttributes.ColorType
            java.awt.PageAttributes.MediaType
            java.awt.PageAttributes.OrientationRequestedType
            java.awt.PageAttributes.OriginType
            java.awt.PageAttributes.PrintQualityType
      returns wrong string.
                    
      The docs for all classes says:

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a
      string that "textually represents" this object. The result should be a concise but informative
      representation that is easy for a person to read. It is recommended that all subclasses
      override this method.
      The toString method for class Object returns a string consisting of the name of the class of
      which the object is an instance, the at-sign character `@', and the unsigned hexadecimal
      representation of the hash code of the object. In other words, this method returns a string
      equal to the value of:

       getClass().getName() + '@' + Integer.toHexString(hashCode())
       
      Overrides:
      toString in class Object
      Following copied from class: java.lang.Object
      Returns:
      a string representation of the object.

      the test:
      --------------------------------------------------
      import java.awt.PageAttributes.*;

      public class Test {
          public static void main(String[] args) {
              Object objects[] = {
                  ColorType.MONOCHROME,
                  MediaType.A0,
                  OrientationRequestedType.PORTRAIT,
                  OriginType.PRINTABLE,
                  PrintQualityType.DRAFT,
              };
              for (int i=0; i<objects.length; i++) {
                  System.out.println("Real life: "+objects[i].toString());
                  System.out.println(" Expected:
      "+objects[i].getClass().getName()+"@"+Integer.toHexString(objects[0].hashCode()));
              }
          }
      }

      output:
      --------------------------------------------------
      ] java -version
      java version "1.3.0rc2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc2-Y)
      Java HotSpot(TM) Client VM (build 1.3.0rc2-Y, interpreted mode)

      ] java Test
      Real life: monochrome
       Expected: java.awt.PageAttributes$ColorType@1
      Real life: iso-a0
       Expected: java.awt.PageAttributes$MediaType@1
      Real life: portrait
       Expected: java.awt.PageAttributes$OrientationRequestedType@1
      Real life: printable
       Expected: java.awt.PageAttributes$OriginType@1
      Real life: draft
       Expected: java.awt.PageAttributes$PrintQualityType@1

      --------------------------------------------------
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                uwesunw Uwe Uwe (Inactive)
                Reporter:
                aycsunw Ayc Ayc (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: