You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a method with some complex logic. Deep in the code there is an operation on a field value that I would like to change. I thought of implementing this with an Advice class with a onMethodExit. The problem with that is that then the original code executes and then the modified code executes. This is pretty inefficient because the original code is pretty complex. This is an already loaded class.
protected Set cache = Collections.synchronizedSet(new HashSet());
private boolean updateCache(File jarDir) {
zFile = new ZipFile(jarDir);
Enumeration zipEntry = zFile.entries();
while(zipEntry.hasMoreElements()) {
ZipEntry entry = (ZipEntry)zipEntry.nextElement();
if (!entry.isDirectory()) {
this.cache.add(entry.getName()); // This is the line I would like to change with some alternate logic
}
}
return true;
}
The other option is to use MethodDelegation but then I am not sure how that can refer to the class fields. We use the field cache in this case.
What is the best way to achieve this kind of instrumentation.
The text was updated successfully, but these errors were encountered:
The default value is null, false or 0. It means that if this default value is returned, the method is not skipped, in this case. It's also explained in the javadoc.
I have a method with some complex logic. Deep in the code there is an operation on a field value that I would like to change. I thought of implementing this with an Advice class with a onMethodExit. The problem with that is that then the original code executes and then the modified code executes. This is pretty inefficient because the original code is pretty complex. This is an already loaded class.
The other option is to use MethodDelegation but then I am not sure how that can refer to the class fields. We use the field
cache
in this case.What is the best way to achieve this kind of instrumentation.
The text was updated successfully, but these errors were encountered: