JShell 코드 조각을 클래스에 배치하지 않고 실행할 수 있는 REPL 도구입니다. 이 도구는 선언을 평가하는 방법을 제공합니다. , 문 , 및 표현식 Java에서 main()을 만들 필요 없음 코드의 일부를 테스트하는 방법입니다.
명령 "/debug "는 디버깅 정보를 표시하는 데 사용할 수 있습니다. JShell 도구 구현을 위해. "/debug"를 입력하면 명령, 디버깅 모드가 켜져 있음 . 디버그 모드를 활성화하고 간단한 덧셈이나 간단한 문자열을 입력하면 아래와 같이 출력됩니다.
예시-1
jshell> /debug
| Debugging on
jshell> 5+3
Compiling: 5+3
Kind: EXPRESSION_STATEMENT -- 5 + 3;
compileAndLoad [Unit($1)]
++setCompilationInfo() Snippet:VariableKey($1)#11-5+3
package REPL;
import java.io.*;import java.math.*;import java.net.*;import java.nio.file.*;import java.util.*;
import java.util.concurrent.*;import java.util.function.*;import java.util.prefs.*;
import java.util.regex.*;import java.util.stream.*;class $JShell
$11 {
public static
int $1;
public static Object do_it$() throws Throwable {
return $1 = 5+3;
}
}
-- diags: []
setStatus() Snippet:VariableKey($1)#11-5+3 - status: VALID
compileAndLoad ins = [Unit($1)] -- legit = [Unit($1)]
Compiler generating class REPL.$JShell$11
compileAndLoad [Unit($1)] -- deps: [] success: true
recordCompilation: Snippet:VariableKey($1)#11-5+3 -- status VALID, unresolved []
$1 ==> 8 예시-2
jshell> /debug
| Debugging on
jshell> String s = "Adithya"
Compiling: String s = "Adithya";
Kind: VARIABLE -- String s = "Adithya"
compileAndLoad [Unit(s)]
++setCompilationInfo() Snippet:VariableKey(s)#12-String s = "Adithya";
package REPL;
import java.io.*;import java.math.*;import java.net.*;import java.nio.file.*;import java.util.*;
import java.util.concurrent.*;import java.util.function.*;import java.util.prefs.*;
import java.util.regex.*;import java.util.stream.*;import static REPL.$JShell$11.$1;
class $JShell$12 {
public static String s;
public static Object do_it$() throws Throwable {
String s_ =
"Adithya";
return s = s_;
}
}
-- diags: []
setStatus() Snippet:VariableKey(s)#12-String s = "Adithya"; - status: VALID
compileAndLoad ins = [Unit(s)] -- legit = [Unit(s)]
Compiler generating class REPL.$JShell$12
compileAndLoad [Unit(s)] -- deps: [] success: true
recordCompilation: Snippet:VariableKey(s)#12-String s = "Adithya"; -- status VALID, unresolved []
s ==> "Adithya"
"꺼짐"하려는 경우 디버깅 모드로 전환한 다음 "/debug" 를 다시 입력합니다. 동일한 세션에 대한 명령입니다.
jshell> /debug | Debugging off