Hello,

Please review these changes to remove the javac lint warnings from the java.lang.ref package:

    8021429 Fix lint warnings in java.lang.ref
    http://cr.openjdk.java.net/~darcy/8021429.0/

Care was taken to not change any signatures of public API elements. After doing a clean build, all the java.lang.ref regression tests pass. Full patch below.

Thanks,

-Joe

--- old/src/share/classes/java/lang/ref/FinalReference.java 2013-07-25 13:29:12.000000000 -0700 +++ new/src/share/classes/java/lang/ref/FinalReference.java 2013-07-25 13:29:12.000000000 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,12 @@

 package java.lang.ref;

-
-/* Final references, used to implement finalization */
-
+/**
+ * Final references, used to implement finalization
+ */
 class FinalReference<T> extends Reference<T> {

     public FinalReference(T referent, ReferenceQueue<? super T> q) {
         super(referent, q);
     }
-
 }
--- old/src/share/classes/java/lang/ref/Finalizer.java 2013-07-25 13:29:13.000000000 -0700 +++ new/src/share/classes/java/lang/ref/Finalizer.java 2013-07-25 13:29:13.000000000 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,16 +29,16 @@
 import java.security.AccessController;


-final class Finalizer extends FinalReference { /* Package-private; must be in - same package as the Reference
-                                                  class */
+final class Finalizer extends FinalReference<Object> { /* Package-private; must be in + same package as the Reference
+                                                        class */

/* A native method that invokes an arbitrary object's finalize method is
        required since the finalize method is protected
      */
     static native void invokeFinalizeMethod(Object o) throws Throwable;

-    private static ReferenceQueue queue = new ReferenceQueue();
+    private static ReferenceQueue<Object> queue = new ReferenceQueue<>();
     private static Finalizer unfinalized = null;
     private static final Object lock = new Object();

--- old/src/share/classes/java/lang/ref/Reference.java 2013-07-25 13:29:14.000000000 -0700 +++ new/src/share/classes/java/lang/ref/Reference.java 2013-07-25 13:29:13.000000000 -0700
@@ -96,6 +96,7 @@
      *    Enqueued:   next reference in queue (or this if last)
      *    Inactive:   this
      */
+    @SuppressWarnings("rawtypes")
     Reference next;

/* When active: next element in a discovered reference list maintained by GC (or this if last)
@@ -119,7 +120,7 @@
      * them.  This list is protected by the above lock object. The
      * list uses the discovered field to link its elements.
      */
-    private static Reference pending = null;
+    private static Reference<Object> pending = null;

     /* High-priority thread to enqueue pending References
      */
@@ -131,7 +132,7 @@

         public void run() {
             for (;;) {
-                Reference r;
+                Reference<Object> r;
                 synchronized (lock) {
                     if (pending != null) {
                         r = pending;
@@ -166,7 +167,7 @@
                     continue;
                 }

-                ReferenceQueue q = r.queue;
+                ReferenceQueue<Object> q = r.queue;
                 if (q != ReferenceQueue.NULL) q.enqueue(r);
             }
         }
--- old/src/share/classes/java/lang/ref/ReferenceQueue.java 2013-07-25 13:29:14.000000000 -0700 +++ new/src/share/classes/java/lang/ref/ReferenceQueue.java 2013-07-25 13:29:14.000000000 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,14 +40,14 @@
      */
     public ReferenceQueue() { }

-    private static class Null extends ReferenceQueue {
-        boolean enqueue(Reference r) {
+    private static class Null<S> extends ReferenceQueue<S> {
+        boolean enqueue(Reference<? extends S> r) {
             return false;
         }
     }

-    static ReferenceQueue NULL = new Null();
-    static ReferenceQueue ENQUEUED = new Null();
+    static ReferenceQueue<Object> NULL = new Null<>();
+    static ReferenceQueue<Object> ENQUEUED = new Null<>();

     static private class Lock { };
     private Lock lock = new Lock();
@@ -58,7 +58,7 @@
         synchronized (lock) {
// Check that since getting the lock this reference hasn't already been
             // enqueued (and even then removed)
-            ReferenceQueue queue = r.queue;
+            ReferenceQueue<?> queue = r.queue;
             if ((queue == NULL) || (queue == ENQUEUED)) {
                 return false;
             }
@@ -75,10 +75,13 @@
         }
     }

+    @SuppressWarnings("unchecked")
private Reference<? extends T> reallyPoll() { /* Must hold lock */
         Reference<? extends T> r = head;
         if (r != null) {
-            head = (r.next == r) ? null : r.next;
+            head = (r.next == r) ?
+                null :
+ r.next; // Unchecked due to the next field having a raw type in Reference
             r.queue = NULL;
             r.next = r;
             queueLength--;

Reply via email to