-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache proxies of newly constructed Java objects #3581
Conversation
Revert changes to construction_spec.rb
Nice! I'll review tonight. |
🌲 👍 |
Cache proxies of newly constructed Java objects
Finally getting back to this now. |
Ok, this isn't quite right. This will unconditionally cache objects coming from all constructor calls whether the proxy cache is on or the class has been set to persistent. If you look at InstanceMethodInvoker and trace through method.invokeDirect, after a long chain of calls (@kares we need to reduce this) it eventually gets back to Java.getInstance() which checks those flags and decides to cache or not. |
This might be ok if we modify setAndCacheProxyObject to check those same flags. |
@headius thanks for taking a look! Sorry I didn't look deeply enough into the InstanceMethodInvoker path! I'll take another pass and see if I can fix these problems, along with some more tests. |
@headius I'm wondering about something like this: private void setAndCacheProxyObject(ThreadContext context, JavaProxy proxy, Object object) {
proxy.setObject(object);
if (Java.OBJECT_PROXY_CACHE || Java.getProxyClassForObject(context.runtime, object).getCacheProxy()) {
context.runtime.getJavaSupport().getObjectProxyCache().put(object, proxy);
}
} However, I notice there is a |
right, did not realize. will fix it unless @smellsblue spins up another PR. |
@smellsblue I believe that |
@kares @headius I just created a new PR to both fix the bug and add some specs around proxy caching: #3602 @headius using the |
This fixes #3576
I added a few related specs while I was at it (only the constructor one failed before my changes though).
I noticed the warning at
spec/READ_ME_FIRST.txt
, but wasn't sure if that applied to thejava_integration
specs, so if I should have added my spec elsewhere, please let me know.