

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the different status states of REPL in Java 9?
REPL stands for Read-Evaluate-Print-Loop. It holds some states, and each statement in JShell has a state. This state denies the execution status of snippets and variables. It can be determined by the results of the eval() method of JShell instance, which evaluates the code.
There are seven different status states listed below.
- DROPPED: The snippet is inactive.
- NONEXISTENT: The snippet is inactive because it does not yet exist.
- OVERWRITTEN: The snippet is inactive because it has been replaced by a new snippet.
- RECOVERABLE_DEFINED: The snippet is a declaration snippet with potentially recoverable unresolved references or other issues in its body.
- RECOVERABLE_NOT_DEFINED: The snippet is a declaration snippet with potentially recoverable unresolved references or other issues.
- REJECTED: The snippet is inactive because the compilation failed upon initial evaluation and it is not capable of becoming valid with further changes to the JShell state.
- VALID: The snippet is a valid snippet.
Example
import java.util.List; import jdk.jshell.*; import jdk.jshell.Snippet.Status; public class JShellTest { public static void main(String args[]) { JShell shell = JShell.create(); List<SnippetEvent> events = shell.eval("int a, b, sum; " + "a = 12; b = 11; sum = a + b; " + "System.out.println(sum);" ); for(SnippetEvent event : events) { Snippet snippet = event.snippet(); Snippet.Status snippetstatus = shell.status(snippet); if(snippetstatus == Status.VALID) { System.out.println("Successfully executed"); } } } }
Output
Successfully executed Successfully executed Successfully executed
- Related Questions & Answers
- What is the importance of REPL in Java 9?
- What are the different states of a Process?
- What are the different types of process states and queues?
- What are the different module types in Java 9?
- What are the different compilation modes of a module in Java 9?
- What are the different shortcut keys in JShell in Java 9?
- What are the different feedback modes in JShell in Java 9?
- What are the different startup scripts in JShell in Java 9?
- What are the different Http/2 Client classes in Java 9?
- What are the states of transaction in DBMS?
- What are the different "/types" commands in JShell in Java 9?
- What are the different "/edit" commands in JShell in Java 9?
- What are the different "/vars" commands in JShell in Java 9?
- What are process states?
- What are the advantages of Modules in Java 9?
Advertisements