Skip to content

Commit

Permalink
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -16,14 +16,15 @@ public Java7ClassValue(ClassValueCalculator<T> calculator) {
public T get(Class cls) {
// We don't check for null on the WeakReference since the
// value is strongly referenced by proxy's list
return proxy.get(cls).get();
return (T)proxy.get(cls).get();
}

// If we put any objects that reference an org.jruby.Ruby runtime
// (like RubyClass instances) in here we run into a circular
// reference situation that GC isn't handling where they will
// always be strongly referenced and never garbage collected. We
// break that by holding the computed values with a WeakReference.
// This appears to be a bug in OpenJDK. See jruby/jruby#3228.
private final java.lang.ClassValue<WeakReference<T>> proxy = new java.lang.ClassValue<WeakReference<T>>() {
// Strongly reference all computed values so they don't get
// garbage collected until this Java7ClassValue instance goes

0 comments on commit be1d57f

Please sign in to comment.