Question:
I have some performance problem in my app - and the bottleneck is sun.awt.image.ImageFetcher.run
, and I canno't get any (more) meaningfull info from profiler. So I figured that it would be nice to look at jobs that ImageFetcher is doing.
I couldn't get access to FetcherInfo
class, that holds all ImageFetcher
jobs. To obtain FetcherInfo
instance I have to call FetcherInfo.getFetcherInfo()
.
I created class in package sun.awt.image
(just in my project, i didnt tinker with rt.jar).
To get FetcherInfo
i use:
try{
for(Method method : FetcherInfo.class.getDeclaredMethods()){
method.setAccessible(true);
if(method.getName().equals("getFetcherInfo")){
m = method;
}
}
}catch (Exception e){
e.printStackTrace();
}
FetcherInfo info = null;
try {
info = (FetcherInfo) m.invoke(null);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
And I get exception: Exception in thread "IMAGE-FETCHER-WATCHER" java.lang.IllegalAccessError: tried to access class sun.awt.image.FetcherInfo from class sun.awt.image.FetcherDebug
And the stack trace points to:
for(Method method : FetcherInfo.class.getDeclaredMethods()){
The same exception was raised by:
FetcherInfo.class.getMethod("getFetcherInfo");
So anyone has any ideas how to either:
- Obtain ImageFetcher instance
- Find out what images are getting loaded
SOLUTION
The problem was that i've put my class into sun.java.awt
package to get access to package protected members, without putting it into rt.jar
, and exception was thrown hen calling ImageFetcher.class
.