|
42 | 42 | import org.jruby.runtime.builtin.Variable; |
43 | 43 |
|
44 | 44 | import static org.jruby.api.Convert.asBoolean; |
| 45 | +import static org.jruby.api.Create.newString; |
45 | 46 | import static org.jruby.api.Error.typeError; |
46 | 47 | import static org.jruby.runtime.invokedynamic.MethodNames.INSPECT; |
47 | 48 | import static org.jruby.runtime.Helpers.invokedynamic; |
@@ -198,7 +199,7 @@ public static RubyString convertToString(IRubyObject self) { |
198 | 199 |
|
199 | 200 | public static IRubyObject anyToString(IRubyObject self) { |
200 | 201 | final RubyClass metaClass = getMetaClass(self); |
201 | | - String cname = metaClass.getRealClass().getName(); |
| 202 | + String cname = metaClass.getRealClass().getName(metaClass.getRuntime().getCurrentContext()); |
202 | 203 | /* 6:tags 16:addr 1:eos */ |
203 | 204 | return metaClass.runtime.newString("#<" + cname + ":0x" + Integer.toHexString(System.identityHashCode(self)) + '>'); |
204 | 205 | } |
@@ -230,27 +231,27 @@ public static IRubyObject dup(IRubyObject self) { |
230 | 231 | } |
231 | 232 |
|
232 | 233 | public static IRubyObject inspect(IRubyObject self) { |
233 | | - final Ruby runtime = getRuntime(self); |
| 234 | + var context = getRuntime(self).getCurrentContext();; |
234 | 235 | if (hasVariables(self)) { |
235 | 236 | StringBuilder part = new StringBuilder(); |
236 | | - String cname = getMetaClass(self).getRealClass().getName(); |
| 237 | + String cname = getMetaClass(self).getRealClass().getName(context); |
237 | 238 | part.append("#<").append(cname).append(":0x"); |
238 | 239 | part.append(Integer.toHexString(System.identityHashCode(self))); |
239 | 240 |
|
240 | | - if (runtime.isInspecting(self)) { |
| 241 | + if (context.runtime.isInspecting(self)) { |
241 | 242 | /* 6:tags 16:addr 1:eos */ |
242 | 243 | part.append(" ...>"); |
243 | | - return runtime.newString(part.toString()); |
| 244 | + return newString(context, part.toString()); |
244 | 245 | } |
245 | 246 | try { |
246 | | - runtime.registerInspecting(self); |
247 | | - return runtime.newString(inspectObj(self, part).toString()); |
| 247 | + context.runtime.registerInspecting(self); |
| 248 | + return newString(context, inspectObj(self, part).toString()); |
248 | 249 | } finally { |
249 | | - runtime.unregisterInspecting(self); |
| 250 | + context.runtime.unregisterInspecting(self); |
250 | 251 | } |
251 | 252 | } |
252 | 253 |
|
253 | | - return Helpers.invoke(runtime.getCurrentContext(), self, "to_s"); |
| 254 | + return Helpers.invoke(context, self, "to_s"); |
254 | 255 | } |
255 | 256 |
|
256 | 257 |
|
|
0 commit comments