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

javax.print.PrintServiceLookup allows to register null service

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 1.4.0, 9
    • client-libs
    • b36

        Consider the following code:

        ----------------------------------------------------------
        import javax.print.PrintServiceLookup;
        import java.util.Arrays;

        public class PS {

            public static void main(String[] args) {
                final boolean registered = PrintServiceLookup.registerService(null);
                System.out.println("registered? " + registered);
                System.out.println("services = " + Arrays.toString(PrintServiceLookup.lookupPrintServices(null, null)));
            }
        }
        ----------------------------------------------------------

        After running it v.s. JDK8 updates the output will contain

        ----
        registered? true
        ...
        ----

        and the list of services with null among them.

        This doesn't look like conforming to the spec of the methods:

        http://docs.oracle.com/javase/8/docs/api/javax/print/PrintServiceLookup.html#registerService-javax.print.PrintService-
        http://docs.oracle.com/javase/8/docs/api/javax/print/PrintServiceLookup.html#lookupPrintServices-javax.print.DocFlavor-javax.print.attribute.AttributeSet-

        The spec needs to be clarified or behavior corrected.

              prr Philip Race
              dbessono Dmitry Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: