public abstract class ObjectProxyCache<T,A> extends Object
Note that both Java objects and their proxies are held by weak/soft references; because proxies (currently) keep strong references to their Java objects, if we kept strong references to them the Java objects would never be gc'ed. This presents a problem in the case where a user passes a Rubified Java object out to Java but keeps no reference in Ruby to the proxy; if the object is returned to Ruby after its proxy has been gc'ed, a new (and possibly very wrong, in the case of JRuby-defined subclasses) proxy will be created. Use of soft references may help reduce the likelihood of this occurring; users may be advised to keep Ruby-side references to prevent it occurring altogether.
| Modifier and Type | Class and Description | 
|---|---|
| static class  | ObjectProxyCache.ReferenceType | 
| Constructor and Description | 
|---|
| ObjectProxyCache() | 
| ObjectProxyCache(int numSegments,
                int initialSegCapacity,
                ObjectProxyCache.ReferenceType refType) | 
| ObjectProxyCache(ObjectProxyCache.ReferenceType refType) | 
| Modifier and Type | Method and Description | 
|---|---|
| abstract T | allocateProxy(Object javaObject,
             A allocator) | 
| T | get(Object javaObject) | 
| T | getOrCreate(Object javaObject,
           A allocator) | 
| void | put(Object javaObject,
   T proxy) | 
| int | size()Returns the approximate size (elements in use) of the cache. | 
| String | stats() | 
public ObjectProxyCache()
public ObjectProxyCache(ObjectProxyCache.ReferenceType refType)
public ObjectProxyCache(int numSegments,
                int initialSegCapacity,
                ObjectProxyCache.ReferenceType refType)
public int size()
public String stats()
Copyright © 2001-2015 JRuby. All Rights Reserved.