void parseThreads()

in analysis/thread-dump/src/main/java/org/eclipse/jifa/tda/parser/JStackParser.java [416:484]


        void parseThreads() throws Exception {
            String line = input.currentLine();
            do {
                while (StringUtils.isBlank(line)) {
                    line = input.readLine();
                    if (line == null) {
                        return;
                    }
                }

                if (line.startsWith("\"")) {
                    if (!line.endsWith("]")) {
                        // not a java thread
                        break;
                    }
                    RawJavaThread rjt = new RawJavaThread();
                    rjt.contents.add(line);
                    rjt.lineStart = input.lineNumber();

                    while ((line = input.readLine()) != null) {
                        if (StringUtils.isBlank(line)) {
                            continue;
                        }

                        if (line.startsWith("\"")) {
                            break;
                        }

                        if (line.startsWith(MonitorState.ELIMINATED_SCALAR_REPLACED.prefix())) {
                            // this problem is fixed by JDK-8268780(JDK 18)
                            int index = line.indexOf(")");
                            if (index > 0 && line.length() > index + 1) {
                                rjt.contents.add(line.substring(0, index + 1));
                                rjt.contents.add(line.substring(index + 1).trim());
                                continue;
                            }
                        }
                        rjt.contents.add(line);
                        rjt.lineEnd = input.lineNumber();
                    }
                    enroll(rjt);
                } else {
                    break;
                }
            } while (true);

            // other threads
            do {
                while (StringUtils.isBlank(line)) {
                    line = input.readLine();
                    if (line == null) {
                        return;
                    }
                }

                if (line.startsWith("\"")) {
                    parseByElementPattern(Element.NON_JAVA_THREAD, m -> {
                        Thread thread = new Thread();
                        fillThread(thread, m);
                        thread.setLineStart(input.lineNumber());
                        thread.setLineEnd(input.lineNumber());
                        snapshot.getNonJavaThreads().add(thread);
                    }, true);
                } else {
                    break;
                }
                // step in parseByElementPattern
            } while ((line = input.currentLine()) != null);
        }