Sha256: 66b303175ff91db16c8a14d84924946f4fb4efa2d983e969090208e8c25b04be
Contents?: true
Size: 1.52 KB
Versions: 11
Compression:
Stored size: 1.52 KB
Contents
package com.gsamokovarov.skiptrace; import java.lang.reflect.Field; import org.jruby.runtime.ThreadContext; import org.jruby.runtime.DynamicScope; import org.jruby.runtime.Frame; import org.jruby.runtime.backtrace.BacktraceElement; import org.jruby.runtime.builtin.IRubyObject; public class ThreadContextInternals { private ThreadContext context; public ThreadContextInternals(ThreadContext context) { this.context = context; } public Frame[] getFrameStack() { return (Frame[]) getPrivateField("frameStack"); } public int getFrameIndex() { return (Integer) getPrivateField("frameIndex"); } public DynamicScope[] getScopeStack() { return (DynamicScope[]) getPrivateField("scopeStack"); } public int getScopeIndex() { return (Integer) getPrivateField("scopeIndex"); } public BacktraceElement[] getBacktrace() { return (BacktraceElement[]) getPrivateField("backtrace"); } public int getBacktraceIndex() { return (Integer) getPrivateField("backtraceIndex"); } private Object getPrivateField(String fieldName) { try { Field field = ThreadContext.class.getDeclaredField(fieldName); field.setAccessible(true); return field.get(context); } catch (NoSuchFieldException exc) { throw new ThreadContextInterfaceException(fieldName, exc); } catch (IllegalAccessException exc) { throw new ThreadContextInterfaceException(fieldName, exc); } } }
Version data entries
11 entries across 11 versions & 4 rubygems