langtools/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java
changeset 22163 3651128c74eb
parent 16796 53060909017b
child 24897 655b72d7b96e
equal deleted inserted replaced
22162:3b3e23e67329 22163:3651128c74eb
   120             try {
   120             try {
   121                 Class<? extends ClassLoader> loader =
   121                 Class<? extends ClassLoader> loader =
   122                         Class.forName(classLoaderClass).asSubclass(ClassLoader.class);
   122                         Class.forName(classLoaderClass).asSubclass(ClassLoader.class);
   123                 Class<?>[] constrArgTypes = { URL[].class, ClassLoader.class };
   123                 Class<?>[] constrArgTypes = { URL[].class, ClassLoader.class };
   124                 Constructor<? extends ClassLoader> constr = loader.getConstructor(constrArgTypes);
   124                 Constructor<? extends ClassLoader> constr = loader.getConstructor(constrArgTypes);
   125                 return constr.newInstance(new Object[] { urls, thisClassLoader });
   125                 return constr.newInstance(urls, thisClassLoader);
   126             } catch (Throwable t) {
   126             } catch (Throwable t) {
   127                 // ignore errors loading user-provided class loader, fall through
   127                 // ignore errors loading user-provided class loader, fall through
   128             }
   128             }
   129         }
   129         }
   130         return new URLClassLoader(urls, thisClassLoader);
   130         return new URLClassLoader(urls, thisClassLoader);
   354 
   354 
   355     public void flushCache(JavaFileObject file) {
   355     public void flushCache(JavaFileObject file) {
   356         contentCache.remove(file);
   356         contentCache.remove(file);
   357     }
   357     }
   358 
   358 
   359     protected final Map<JavaFileObject, ContentCacheEntry> contentCache
   359     protected final Map<JavaFileObject, ContentCacheEntry> contentCache = new HashMap<>();
   360             = new HashMap<JavaFileObject, ContentCacheEntry>();
       
   361 
   360 
   362     protected static class ContentCacheEntry {
   361     protected static class ContentCacheEntry {
   363         final long timestamp;
   362         final long timestamp;
   364         final SoftReference<CharBuffer> ref;
   363         final SoftReference<CharBuffer> ref;
   365 
   364 
   366         ContentCacheEntry(JavaFileObject file, CharBuffer cb) {
   365         ContentCacheEntry(JavaFileObject file, CharBuffer cb) {
   367             this.timestamp = file.getLastModified();
   366             this.timestamp = file.getLastModified();
   368             this.ref = new SoftReference<CharBuffer>(cb);
   367             this.ref = new SoftReference<>(cb);
   369         }
   368         }
   370 
   369 
   371         boolean isValid(JavaFileObject file) {
   370         boolean isValid(JavaFileObject file) {
   372             return timestamp == file.getLastModified();
   371             return timestamp == file.getLastModified();
   373         }
   372         }