Permalink
Browse files

Don't let Finalizer hold a reference to associated object and use pro…

…per logic for getting an ID to use.
  • Loading branch information...
1 parent eff3e42 commit 4568b4fa132f9d0fb32fcedfcc1f0dc5af7e342c @headius headius committed May 2, 2010
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/org/jruby/RubyBasicObject.java
@@ -1088,7 +1088,7 @@ public boolean eql(IRubyObject other) {
public void addFinalizer(IRubyObject f) {
Finalizer finalizer = (Finalizer)fastGetInternalVariable("__finalizer__");
if (finalizer == null) {
- finalizer = new Finalizer(getRuntime().getObjectSpace().idOf(this));
+ finalizer = new Finalizer((RubyFixnum)id());
fastSetInternalVariable("__finalizer__", finalizer);
getRuntime().addFinalizer(finalizer);
}
@@ -1514,13 +1514,13 @@ public boolean isBuiltin(String methodName) {
* Class that keeps track of the finalizers for the object under
* operation.
*/
- public class Finalizer implements Finalizable {
- private long id;
+ public static class Finalizer implements Finalizable {
+ private RubyFixnum id;
private IRubyObject firstFinalizer;
private List<IRubyObject> finalizers;
private AtomicBoolean finalized;
- public Finalizer(long id) {
+ public Finalizer(RubyFixnum id) {
this.id = id;
this.finalized = new AtomicBoolean(false);
}
@@ -1554,7 +1554,7 @@ public void finalize() {
private void callFinalizer(IRubyObject finalizer) {
RuntimeHelpers.invoke(
finalizer.getRuntime().getCurrentContext(),
- finalizer, "call", RubyBasicObject.this.id());
+ finalizer, "call", id);
}
}
}

0 comments on commit 4568b4f

Please sign in to comment.