src/share/classes/sun/io/Converters.java

Print this page
rev 3186 : 6880112: Project Coin: Port JDK core library code to use diamond operator


 103         SoftReference<Object[]>[] srs = classCache[type];
 104         for (int i = 0; i < CACHE_SIZE; i++) {
 105             SoftReference<Object[]> sr = srs[i];
 106             if (sr == null)
 107                 continue;
 108             Object[] oa = sr.get();
 109             if (oa == null) {
 110                 srs[i] = null;
 111                 continue;
 112             }
 113             if (oa[1].equals(encoding)) {
 114                 moveToFront(srs, i);
 115                 return (Class<?>)oa[0];
 116             }
 117         }
 118         return null;
 119     }
 120 
 121     private static Class<?> cache(int type, Object encoding, Class<?> c) {
 122         SoftReference<Object[]>[] srs = classCache[type];
 123         srs[CACHE_SIZE - 1] = new SoftReference<Object[]>(new Object[] { c, encoding });
 124         moveToFront(srs, CACHE_SIZE - 1);
 125         return c;
 126     }
 127 
 128     /* Used to avoid doing expensive charset lookups for charsets that are not
 129      * yet directly supported by NIO.
 130      */
 131     public static boolean isCached(int type, String encoding) {
 132         synchronized (lock) {
 133             SoftReference<Object[]>[] srs = classCache[type];
 134             for (int i = 0; i < CACHE_SIZE; i++) {
 135                 SoftReference<Object[]> sr = srs[i];
 136                 if (sr == null)
 137                     continue;
 138                 Object[] oa = sr.get();
 139                 if (oa == null) {
 140                     srs[i] = null;
 141                     continue;
 142                 }
 143                 if (oa[1].equals(encoding))




 103         SoftReference<Object[]>[] srs = classCache[type];
 104         for (int i = 0; i < CACHE_SIZE; i++) {
 105             SoftReference<Object[]> sr = srs[i];
 106             if (sr == null)
 107                 continue;
 108             Object[] oa = sr.get();
 109             if (oa == null) {
 110                 srs[i] = null;
 111                 continue;
 112             }
 113             if (oa[1].equals(encoding)) {
 114                 moveToFront(srs, i);
 115                 return (Class<?>)oa[0];
 116             }
 117         }
 118         return null;
 119     }
 120 
 121     private static Class<?> cache(int type, Object encoding, Class<?> c) {
 122         SoftReference<Object[]>[] srs = classCache[type];
 123         srs[CACHE_SIZE - 1] = new SoftReference<>(new Object[] { c, encoding });
 124         moveToFront(srs, CACHE_SIZE - 1);
 125         return c;
 126     }
 127 
 128     /* Used to avoid doing expensive charset lookups for charsets that are not
 129      * yet directly supported by NIO.
 130      */
 131     public static boolean isCached(int type, String encoding) {
 132         synchronized (lock) {
 133             SoftReference<Object[]>[] srs = classCache[type];
 134             for (int i = 0; i < CACHE_SIZE; i++) {
 135                 SoftReference<Object[]> sr = srs[i];
 136                 if (sr == null)
 137                     continue;
 138                 Object[] oa = sr.get();
 139                 if (oa == null) {
 140                     srs[i] = null;
 141                     continue;
 142                 }
 143                 if (oa[1].equals(encoding))