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

getAttributes().clear() throws UnmodifiableSetException

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      beta2
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: ooR10006 Date: 05/30/2001


      jdk1.4.0beta-b65:
      The spec for interface javax.print.attribute.AttributeSet, method clear()
      declares:
      "Throws:
       IllegalStateException - (unchecked exception) Thrown if this attribute set
       does not support the clear() operation."

      jdk1.4.0beta-b65 method javax.print.event.PrintJobAttributeEvent.getAttributes()
      returns PrintJobAttributeSet which "...may not be modifiable".
      According to this returned set's method clear() should throw IllegalStateException
      but instead throws UnmodifiableSetException.
      Note, AttributeSet's (a superinterface of PrintJobAttributeSet) add/remove methods
      throw UnmodifiableSetException if a set is unmodifiable.
      Looks like there is an error in AttributeSet's clear() specification - clear()
      should be declared to throw UnmodifiableSetException if "...this attribute set
      does not support the clear() operation.".

      The following sample shows the failure:

      import javax.print.*;
      import javax.print.event.*;
      import javax.print.attribute.*;
      import javax.print.attribute.standard.*;

      public class test {

          public static void main(String args[]) {
              MyDocPrintJob pJob = new MyDocPrintJob();
              PrintJobAttribute[] attributes = {Sides.DUPLEX, MediaName.ISO_A4_TRANSPARENT};
              HashPrintJobAttributeSet aSet = new HashPrintJobAttributeSet(attributes);
              PrintJobAttributeEvent prEv = new PrintJobAttributeEvent(pJob, aSet);

              PrintJobAttributeSet set = prEv.getAttributes();
              try {
                  set.clear();
              } catch (IllegalStateException e){
              }
              return;
          }
      }

      class MyDocPrintJob implements javax.print.DocPrintJob {
          public void addPrintJobAttributeListener(PrintJobAttributeListener lsn,
                  PrintJobAttributeSet aSet){
          }
          public void addPrintJobListener(PrintJobListener jLsn){
          }
          public PrintJobAttributeSet getAttributes(){
              return null;
          }
          public PrintService getPrintService(){
              return null;
          }
          public void print(Doc doc, PrintRequestAttributeSet aSet)
              throws javax.print.PrintException {
          }
          public void removePrintJobAttributeListener(PrintJobAttributeListener lsn){
          }
          public void removePrintJobListener(PrintJobListener lsn){
          }
      }


      % jdk1.4.0beta-b65/solsparc/bin/java test
      Exception in thread "main" javax.print.attribute.UnmodifiableSetException
              at javax.print.attribute.AttributeSetUtilities$UnmodifiableAttributeSet.clear
              (AttributeSetUtilities.java:100)
              at test.main(test.java:16)
      %

      Due to this new JCK test fails:
      api/javax_print/event/index.html#PrintJobAttributeEvent[PrintJobAttributeEvent2002]


      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              jgodinez Jennifer Godinez (Inactive)
              Reporter:
              ovosunw Ovo Ovo (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: