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

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/bindex-0.8.1/ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/bindex-0.8.1/ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/bindex-0.8.1/ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java
bindex-0.8.1 ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java
skiptrace-0.8.1 ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java
skiptrace-0.8.0 ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java
bindex-0.8.0 ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java
bindex-0.7.0 ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java
skiptrace-0.7.0 ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java
bindex-0.6.0 ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java
skiptrace-0.6.0 ext/skiptrace/com/gsamokovarov/skiptrace/ThreadContextInternals.java