Skip to content

Error: "Failed to evaluate. Reason: Cannot evaluate because the thread is resumed" #109

@shiuchunming

Description

@shiuchunming

Get error message "Failed to evaluate. Reason: Cannot evaluate because the thread is resumed" after getting input from vscode debug console using BufferedReader in Java.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class demo {
    public static void main(String args[]) throws IOException {
        int input;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
           input = br.read();
        }
        catch(IOException e) {
            e.printStackTrace();
        }
        if(br != null) br.close();
        System.out.println("123"); // would not execute using debug console in vscode.
    }
}

Here is the launch.json, which is basically a default one.

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "type": "java",
        "name": "compile",
        "mainClass": "demo",
        "request": "launch",
        "args": ""
    }

]
}

error

Environment
  • Operating System: Elementary OS 0.4.1 Loki Built on "Ubuntu 16.04.3 LTS"
  • JDK version: java 9.0.1
  • Visual Studio Code version: 1.18.0
  • Java extension version: 0.14.0
Steps To Reproduce
  1. A console Java program getting user input with BufferedReader.
  2. start debugging on debug console
Current Result
Expected Result
Additional Informations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions