[OpenJDK 2D-Dev] JDK 9 RFR of JDK-8042864 : Fix raw and unchecked warnings in javax.print

Henry Jen henry.jen at oracle.com
Thu May 15 22:46:40 UTC 2014


On 05/15/2014 12:07 PM, Joe Darcy wrote:
> Hello,
>
> Please review these change to fix
>
>      JDK-8042864 : Fix raw and unchecked warnings in javax.print
>      http://cr.openjdk.java.net/~darcy/8042864.0/
>
> Patch below.

Looks good to me, just nit-picking.

>
> --- old/src/share/classes/javax/print/PrintServiceLookup.java 2014-05-15
> 12:04:20.000000000 -0700
> +++ new/src/share/classes/javax/print/PrintServiceLookup.java 2014-05-15
> 12:04:20.000000000 -0700
> @@ -208,7 +207,7 @@
>        */
>       public static boolean registerServiceProvider(PrintServiceLookup
> sp) {
>           synchronized (PrintServiceLookup.class) {
> -            Iterator psIterator = getAllLookupServices().iterator();
> +            Iterator<?> psIterator = getAllLookupServices().iterator();
>               while (psIterator.hasNext()) {
>                   try {
>                       Object lus = psIterator.next();

We know this is Iterator<PrinterServiceLookup>, but this works.

> ---
> old/src/share/classes/javax/print/attribute/AttributeSetUtilities.java
> 2014-05-15 12:04:22.000000000 -0700
> +++
> new/src/share/classes/javax/print/attribute/AttributeSetUtilities.java
> 2014-05-15 12:04:22.000000000 -0700
> @@ -523,7 +523,7 @@
>       public static Class<?>
>           verifyAttributeCategory(Object object, Class<?> interfaceName) {
>
> -        Class result = (Class) object;
> +        Class<?> result = (Class) object;
>           if (interfaceName.isAssignableFrom (result)) {
>               return result;
>           }

Should the cast be (Class<?>) instead of (Class)?

> ---
> old/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java
> 2014-05-15 12:04:24.000000000 -0700
> +++
> new/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java
> 2014-05-15 12:04:23.000000000 -0700
> @@ -110,7 +110,7 @@
>        * @return  Printing attribute class (category), an instance of class
>        *          {@link java.lang.Class java.lang.Class}.
>        */
> -    public final Class getCategory() {
> +    public final Class<DialogTypeSelection> getCategory() {
>           return DialogTypeSelection.class;
>       }
>

Would this be too specific for this public API? <? extends Attribute> is 
defined in interface Attribute.


> ---
> old/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java
> 2014-05-15 12:04:25.000000000 -0700
> +++
> new/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java
> 2014-05-15 12:04:24.000000000 -0700
> @@ -242,16 +242,18 @@
>           extends AbstractSet<PrinterStateReason>
>       {
>           private Severity mySeverity;
> -        private Set myEntrySet;
> +        //
> +        private Set<Map.Entry<PrinterStateReason, Severity>> myEntrySet;
>
> -        public PrinterStateReasonSet(Severity severity, Set entrySet) {
> +        public PrinterStateReasonSet(Severity severity,
> + Set<Map.Entry<PrinterStateReason, Severity>> entrySet) {
>               mySeverity = severity;
>               myEntrySet = entrySet;
>           }
>
>           public int size() {
>               int result = 0;
> -            Iterator iter = iterator();
> +            Iterator<?> iter = iterator();

We know it is Iterator<PrinterStateReason>.

>               while (iter.hasNext()) {
>                   iter.next();
>                   ++ result;

Cheers,
Henry



More information about the 2d-dev mailing list