Posted on 2009-10-17 17:23
不需要解释 阅读(333)
评论(0) 编辑 收藏 所属分类:
java
有个大师说过一句话,有人的地方就有江湖,有江湖的地方就有斗争。今天在java eys就看到了一场Resourcebundle引起的口角,集体见:
http://www.javaeye.com/topic/6417?page=1.
这个问题在jdk1.6已经不存在
clearCache
public static final void clearCache()
- Removes all resource bundles from the cache that have been loaded using the caller's class loader.
-
- Since:
- 1.6
- See Also:
ResourceBundle.Control.getTimeToLive(String,Locale)
clearCache
public static final void clearCache(ClassLoader loader)
- Removes all resource bundles from the cache that have been loaded using the given class loader.
-
- Parameters:
loader
- the class loader
- Throws:
NullPointerException
- if loader
is null
- Since:
- 1.6
- See Also:
ResourceBundle.Control.getTimeToLive(String,Locale)
在1.5,1.4怎么办呢:
Class klass = ResourceBundle.getBundle("your.Bundle").getClass().getSuperclass();
Field field = klass.getDeclaredField("cacheList");
field.setAccessible(true);
sun.misc.SoftCache cache = (sun.misc.SoftCache)field.get(null);
cache.clear();
field.setAccessible(false);
这样就可以清楚cache.