summaryrefslogtreecommitdiff
path: root/java/src/json/ext/GeneratorMethods.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/json/ext/GeneratorMethods.java')
-rw-r--r--java/src/json/ext/GeneratorMethods.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/java/src/json/ext/GeneratorMethods.java b/java/src/json/ext/GeneratorMethods.java
index 28a612d..356f2d0 100644
--- a/java/src/json/ext/GeneratorMethods.java
+++ b/java/src/json/ext/GeneratorMethods.java
@@ -6,6 +6,7 @@
*/
package json.ext;
+import java.lang.ref.WeakReference;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyBoolean;
@@ -45,9 +46,9 @@ class GeneratorMethods {
defineMethods(module, "String", RbString.class);
defineMethods(module, "TrueClass", RbTrue.class);
- info.stringExtendModule = module.defineModuleUnder("String")
- .defineModuleUnder("Extend");
- info.stringExtendModule.defineAnnotatedMethods(StringExtend.class);
+ info.stringExtendModule = new WeakReference<RubyModule>(module.defineModuleUnder("String")
+ .defineModuleUnder("Extend"));
+ info.stringExtendModule.get().defineAnnotatedMethods(StringExtend.class);
}
/**
@@ -140,7 +141,7 @@ class GeneratorMethods {
RubyHash result = RubyHash.newHash(runtime);
IRubyObject createId = RuntimeInfo.forRuntime(runtime)
- .jsonModule.callMethod(context, "create_id");
+ .jsonModule.get().callMethod(context, "create_id");
result.op_aset(context, createId, self.getMetaClass().to_s());
ByteList bl = self.getByteList();
@@ -158,7 +159,7 @@ class GeneratorMethods {
public static IRubyObject included(ThreadContext context,
IRubyObject vSelf, IRubyObject module) {
RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
- return module.callMethod(context, "extend", info.stringExtendModule);
+ return module.callMethod(context, "extend", info.stringExtendModule.get());
}
}