com.sun.jdi.ThreadGroupReference Java Examples

The following examples show how to use com.sun.jdi.ThreadGroupReference. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectTranslation.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new translated node for given original one.
 *
 * @param o a node to be translated
 * @return a new translated node
 */
private Object createTranslation (Object o) {
    switch (translationID) {
        case THREAD_ID:
            if (o instanceof ThreadReference) {
                return new JPDAThreadImpl ((ThreadReference) o, debugger);
            } else if (o instanceof ThreadGroupReference) {
                return new JPDAThreadGroupImpl ((ThreadGroupReference) o, debugger);
            } else {
                return null;
            }
        case LOCALS_ID:
            if (o instanceof ArrayType) {
                return new JPDAArrayTypeImpl(debugger, (ArrayType) o);
            }
            if (o instanceof ReferenceType) {
                return new JPDAClassTypeImpl(debugger, (ReferenceType) o);
            }
        default:
            throw new IllegalStateException(""+o);
    }
}
 
Example #2
Source File: JPDADebuggerImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public ThreadsCache getThreadsCache() {
    synchronized (threadsCollectorLock) {
        if (threadsCache == null) {
            threadsCache = new ThreadsCache(this);
            threadsCache.addPropertyChangeListener(new PropertyChangeListener() {
                //  Re-fire the changes
                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    String propertyName = evt.getPropertyName();
                    if (ThreadsCache.PROP_THREAD_STARTED.equals(propertyName)) {
                        firePropertyChange(PROP_THREAD_STARTED, null, getThread((ThreadReference) evt.getNewValue()));
                    }
                    if (ThreadsCache.PROP_THREAD_DIED.equals(propertyName)) {
                        firePropertyChange(PROP_THREAD_DIED, getThread((ThreadReference) evt.getOldValue()), null);
                    }
                    if (ThreadsCache.PROP_GROUP_ADDED.equals(propertyName)) {
                        firePropertyChange(PROP_THREAD_GROUP_ADDED, null, getThreadGroup((ThreadGroupReference) evt.getNewValue()));
                    }
                }
            });
        }
        return threadsCache;
    }
}
 
Example #3
Source File: ThreadsCache.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public synchronized List<ThreadGroupReference> getTopLevelThreadGroups() {
    boolean uninitialized;
    if (groupMap == null) {
        groupMap = new HashMap<ThreadGroupReference, List<ThreadGroupReference>>();
        uninitialized = true;
    } else {
        uninitialized = false;
    }
    List<ThreadGroupReference> topGroups = groupMap.get(null);
    if (topGroups == null) {
        if (vm == null) {
            return Collections.emptyList();
        }
        topGroups = new ArrayList<>(VirtualMachineWrapper.topLevelThreadGroups0(vm));
        groupMap.put(null, topGroups);
        if (uninitialized) {
            for (ThreadGroupReference g : topGroups) {
                groupMap.put(g, uninitializedGroupList);
            }
        }
    }
    return Collections.<List<ThreadReference>>unmodifiableList(new ArrayList(topGroups));
}
 
Example #4
Source File: ThreadsCache.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initGroups(ThreadGroupReference group) {
    try {
        List<ThreadGroupReference> groups = new ArrayList<>(ThreadGroupReferenceWrapper.threadGroups0(group));
        List<ThreadReference> threads = new ArrayList<>(ThreadGroupReferenceWrapper.threads0(group));
        filterThreads(threads);
        groupMap.put(group, groups);
        threadMap.put(group, threads);
        for (ThreadGroupReference g : groups) {
            initGroups(g);
        }
    } catch (ObjectCollectedException e) {
    }
}
 
Example #5
Source File: JPDADebuggerImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JPDAThreadGroup[] getTopLevelThreadGroups() {
    ThreadsCache tc = getThreadsCache();
    if (tc == null) {
        return new JPDAThreadGroup[0];
    }
    List<ThreadGroupReference> groupList = tc.getTopLevelThreadGroups();
    JPDAThreadGroup[] groups = new JPDAThreadGroup[groupList.size()];
    for (int i = 0; i < groups.length; i++) {
        groups[i] = getThreadGroup((ThreadGroupReference) groupList.get(i));
    }
    return groups;
}
 
Example #6
Source File: ThreadGroupIterator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static ThreadGroupReference find(String name) {
    ThreadGroupIterator tgi = new ThreadGroupIterator();
    while (tgi.hasNext()) {
        ThreadGroupReference tg = tgi.nextThreadGroup();
        if (tg.name().equals(name)) {
            return tg;
        }
    }
    return null;
}
 
Example #7
Source File: ThreadGroupIterator.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static ThreadGroupReference find(String name) {
    ThreadGroupIterator tgi = new ThreadGroupIterator();
    while (tgi.hasNext()) {
        ThreadGroupReference tg = tgi.nextThreadGroup();
        if (tg.name().equals(name)) {
            return tg;
        }
    }
    return null;
}
 
Example #8
Source File: ThreadInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static ThreadGroupReference group() {
    if (group == null) {
        // Current thread group defaults to the first top level
        // thread group.
        setThreadGroup(Env.vm().topLevelThreadGroups().get(0));
    }
    return group;
}
 
Example #9
Source File: ThreadGroupIterator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The invariant in this class is that the top iterator
 * on the stack has more elements.  If the stack is
 * empty, there is no top.  This method assures
 * this invariant.
 */
private void push(List<ThreadGroupReference> tgl) {
    stack.push(tgl.iterator());
    while (!stack.isEmpty() && !top().hasNext()) {
        stack.pop();
    }
}
 
Example #10
Source File: ThreadGroupIterator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The invariant in this class is that the top iterator
 * on the stack has more elements.  If the stack is
 * empty, there is no top.  This method assures
 * this invariant.
 */
private void push(List<ThreadGroupReference> tgl) {
    stack.push(tgl.iterator());
    while (!stack.isEmpty() && !top().hasNext()) {
        stack.pop();
    }
}
 
Example #11
Source File: ThreadGroupIterator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static ThreadGroupReference find(String name) {
    ThreadGroupIterator tgi = new ThreadGroupIterator();
    while (tgi.hasNext()) {
        ThreadGroupReference tg = tgi.nextThreadGroup();
        if (tg.name().equals(name)) {
            return tg;
        }
    }
    return null;
}
 
Example #12
Source File: JPDAThreadGroupImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JPDAThreadGroupImpl[] getThreadGroups () {
    ThreadsCache tc = debugger.getThreadsCache();
    if (tc == null) {
        return new JPDAThreadGroupImpl[0];
    }
    List<ThreadGroupReference> l = tc.getGroups(tgr);
    int i, k = l.size ();
    JPDAThreadGroupImpl[] ts = new JPDAThreadGroupImpl[k];
    for (i = 0; i < k; i++) {
        ts [i] = (JPDAThreadGroupImpl) debugger.getThreadGroup(l.get (i));
    }
    return ts;
}
 
Example #13
Source File: ThreadGroupIterator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The invariant in this class is that the top iterator
 * on the stack has more elements.  If the stack is
 * empty, there is no top.  This method assures
 * this invariant.
 */
private void push(List<ThreadGroupReference> tgl) {
    stack.push(tgl.iterator());
    while (!stack.isEmpty() && !top().hasNext()) {
        stack.pop();
    }
}
 
Example #14
Source File: ThreadGroupIterator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static ThreadGroupReference find(String name) {
    ThreadGroupIterator tgi = new ThreadGroupIterator();
    while (tgi.hasNext()) {
        ThreadGroupReference tg = tgi.nextThreadGroup();
        if (tg.name().equals(name)) {
            return tg;
        }
    }
    return null;
}
 
Example #15
Source File: ThreadGroupIterator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The invariant in this class is that the top iterator
 * on the stack has more elements.  If the stack is
 * empty, there is no top.  This method assures
 * this invariant.
 */
private void push(List<ThreadGroupReference> tgl) {
    stack.push(tgl.iterator());
    while (!stack.isEmpty() && !top().hasNext()) {
        stack.pop();
    }
}
 
Example #16
Source File: ThreadsCache.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void fillAllGroups(List<ThreadGroupReference> groups, ThreadGroupReference g) {
    List<ThreadGroupReference> gs = groupMap.get(g);
    if (gs != null) {
        if (gs == uninitializedGroupList) {
            gs = new ArrayList<>(ThreadGroupReferenceWrapper.threadGroups0(g));
            groupMap.put(g, gs);
        }
        groups.addAll(gs);
        for (ThreadGroupReference gg : gs) {
            fillAllGroups(groups, gg);
        }
    }
}
 
Example #17
Source File: ThreadGroupIterator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The invariant in this class is that the top iterator
 * on the stack has more elements.  If the stack is
 * empty, there is no top.  This method assures
 * this invariant.
 */
private void push(List<ThreadGroupReference> tgl) {
    stack.push(tgl.iterator());
    while (!stack.isEmpty() && !top().hasNext()) {
        stack.pop();
    }
}
 
Example #18
Source File: ThreadInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static ThreadGroupReference group() {
    if (group == null) {
        // Current thread group defaults to the first top level
        // thread group.
        setThreadGroup(Env.vm().topLevelThreadGroups().get(0));
    }
    return group;
}
 
Example #19
Source File: ThreadGroupIterator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public ThreadGroupReference nextThreadGroup() {
    ThreadGroupReference tg = top().next();
    push(tg.threadGroups());
    return tg;
}
 
Example #20
Source File: ThreadGroupIterator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
ThreadGroupIterator(List<ThreadGroupReference> tgl) {
    push(tgl);
}
 
Example #21
Source File: ThreadGroupIterator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
ThreadGroupIterator(ThreadGroupReference tg) {
    List<ThreadGroupReference> tgl = new ArrayList<ThreadGroupReference>();
    tgl.add(tg);
    push(tgl);
}
 
Example #22
Source File: ThreadGroupIterator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ThreadGroupReference next() {
    return nextThreadGroup();
}
 
Example #23
Source File: JPDADebuggerImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public JPDAThreadGroup getThreadGroup (ThreadGroupReference tgr) {
    return (JPDAThreadGroup) threadsTranslation.translate (tgr);
}
 
Example #24
Source File: ThreadGroupIterator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
ThreadGroupIterator(List<ThreadGroupReference> tgl) {
    push(tgl);
}
 
Example #25
Source File: ThreadGroupIterator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public ThreadGroupIterator(List<ThreadGroupReference> tgl) {
    push(tgl);
}
 
Example #26
Source File: ThreadGroupIterator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public ThreadGroupIterator(List<ThreadGroupReference> tgl) {
    push(tgl);
}
 
Example #27
Source File: ThreadIterator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
ThreadIterator(ThreadGroupReference tg) {
    tgi = new ThreadGroupIterator(tg);
}
 
Example #28
Source File: ThreadGroupIterator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private Iterator<ThreadGroupReference> top() {
    return stack.peek();
}
 
Example #29
Source File: ThreadGroupIterator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ThreadGroupReference next() {
    return nextThreadGroup();
}
 
Example #30
Source File: ThreadIterator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public ThreadIterator(ThreadGroupReference tg) {
    tgi = new ThreadGroupIterator(tg);
}