src/share/classes/sun/font/StrikeCache.java

Print this page

        

@@ -63,11 +63,11 @@
 
 public final class StrikeCache {
 
     static final Unsafe unsafe = Unsafe.getUnsafe();
 
-    static ReferenceQueue refQueue = Disposer.getQueue();
+    static ReferenceQueue<Object> refQueue = Disposer.getQueue();
 
     static ArrayList<GlyphDisposedListener> disposeListeners = new ArrayList<GlyphDisposedListener>(1);
 
 
     /* Reference objects may have their referents cleared when GC chooses.

@@ -157,11 +157,11 @@
             throw new InternalError("Unexpected address size for font data: " +
                                     nativeAddressSize);
         }
 
         java.security.AccessController.doPrivileged(
-                                    new java.security.PrivilegedAction() {
+                                    new java.security.PrivilegedAction<Object>() {
             public Object run() {
 
                /* Allow a client to override the reference type used to
                 * cache strikes. The default is "soft" which hints to keep
                 * the strikes around. This property allows the client to

@@ -376,27 +376,27 @@
         for (GlyphDisposedListener listener : disposeListeners) {
             listener.glyphDisposed(glyphs);
         }
     }
 
-    public static Reference getStrikeRef(FontStrike strike) {
+    public static Reference<FontStrike> getStrikeRef(FontStrike strike) {
         return getStrikeRef(strike, cacheRefTypeWeak);
     }
 
-    public static Reference getStrikeRef(FontStrike strike, boolean weak) {
+    public static Reference<FontStrike> getStrikeRef(FontStrike strike, boolean weak) {
         /* Some strikes may have no disposer as there's nothing
          * for them to free, as they allocated no native resource
          * eg, if they did not allocate resources because of a problem,
          * or they never hold native resources. So they create no disposer.
          * But any strike that reaches here that has a null disposer is
          * a potential memory leak.
          */
         if (strike.disposer == null) {
             if (weak) {
-                return new WeakReference(strike);
+                return new WeakReference<>(strike);
             } else {
-                return new SoftReference(strike);
+                return new SoftReference<>(strike);
             }
         }
 
         if (weak) {
             return new WeakDisposerRef(strike);

@@ -408,37 +408,39 @@
     static interface DisposableStrike {
         FontStrikeDisposer getDisposer();
     }
 
     static class SoftDisposerRef
-        extends SoftReference implements DisposableStrike {
+        extends SoftReference<FontStrike> implements DisposableStrike {
 
         private FontStrikeDisposer disposer;
 
         public FontStrikeDisposer getDisposer() {
             return disposer;
         }
 
+        @SuppressWarnings("unchecked")
         SoftDisposerRef(FontStrike strike) {
             super(strike, StrikeCache.refQueue);
             disposer = strike.disposer;
-            Disposer.addReference(this, disposer);
+            Disposer.addReference((Reference<Object>)(Reference)this, disposer);
         }
     }
 
     static class WeakDisposerRef
-        extends WeakReference implements DisposableStrike {
+        extends WeakReference<FontStrike> implements DisposableStrike {
 
         private FontStrikeDisposer disposer;
 
         public FontStrikeDisposer getDisposer() {
             return disposer;
         }
 
+        @SuppressWarnings("unchecked")
         WeakDisposerRef(FontStrike strike) {
             super(strike, StrikeCache.refQueue);
             disposer = strike.disposer;
-            Disposer.addReference(this, disposer);
+            Disposer.addReference((Reference<Object>)(Reference)this, disposer);
         }
     }
 
 }