Java9 With JShell

Although most of the programming languages tend to come and go, Java is one that’s here to stay. As one of the most popular and widely adopted languages with a high performance, scalable runtime and innovations towards the JDK, it has a large impact on the world’s computing infrastructure.

The motive for evaluating Java9 is to make JDK more modular and to make Java more scalable for smaller computing devices, secure, performant, and to improve developer productivity. With the boom of the Internet of Things (IoT), enabling Java to run on the smaller devices is instrumental for continued growth.

Among the most popular web protocols, HTTP has been getting its own upgrade to HTTP/2, boasting significant network performance gains. API implementing HTTP/2 and WebSocket to replace the effect of HttpURLConnection, which predates HTTP/1.1 has various limitations such as the one thread per request/ response behavior. Using HTTP/2 in Java 9, applications will have better performance and scalability with memory usage on par or lower than HttpURLConnection, Apache HttpClient, and Netty. Hence, Java 9 will get its own HTTP client.

JDK9 users will get the shell (called JShell which is combination of Java and REPL (Read-Eval-Print-Loop)) like interface to interactively evaluate declarations, statements, and expressions in Java which is similar to Python or Ruby interpreters or other JVM languages like Scala and Groovy. Now Java users will be able to run Java code without any need of wrapping in classes or methods, allowing for a much easier, faster learning & experimentation.

Why JShell in java?

JShell Java Enhancement Proposal (JEP) for the project indicated that the new feature is the result of academic feedback. Schools are adopting languages that have REPL (Read-Eval-Print-Loop) functionality because it lowers down the initial learning curve of programming. Interactively REPL tool gives rapid evaluation of code to young developers.

For example:

jshell> void myJShell() { System.out.println("I am working in  JShell"); }
|  created method myJShell()
 
jshell> myJShell();
I am working in  JShell
 
jshell> void myJShell() { System.out.println("wow, I replaced a  method"); }
|  modified method myJShell()
|    update overwrote method myJShell()

Functionality:

The JShell API will provide all of JShell’s evaluation functionality. The code fragments that are input to the API are referred to as “snippets”. JShell tool will also use the JShell completion API to determine when input is incomplete (and the user must be prompted for more) or would be complete if a semicolon were added (in which case the tool will append the semicolon). The tool will have a set of commands for query, saving and restoring work, and configurations. Commands will be distinguished from snippets by a leading slash in the command.

Java Interaction of Java with Operating System:

So far there has been a limited ability for controlling and managing the operating system processes with Java. For example, in order to do something as simple as getting your process process ID in earlier versions of Java, you would need to either access the native code or use some sort of a magical workaround. However, it would require a different implementation for each platform to guarantee that you are getting the expected result.

Now Java has the ability to interact with the operating system: New direct API’s to handle PIDs, process names and states, and ability to enumerate JVMs and processes and more.

Performance:

The JVM Code Cache is critical to application performance and can be set at startup time using the following flag: -XX:InitialCodeCacheSize=32m.When the code cache memory is fully utilized, the JVM losses JIT and goes into interpreted mode, significantly affecting application runtime performance. In Java 9, this section of memory is getting divided into the following three distinct heap segments in order to improve performance .

  1. JVM internal (non-method) code.
  2. Profiled code.
  3. Non-profiled code.

[Tweet “Java9 With Jshell ~ via @CalsoftInc”]

 
Share:

Related Posts

Product Lifecycle Management in Software Development using Large Language Models

Product Lifecycle Management in Software Development using Large Language Models

The data of any organization is of extreme value. But what happens when that data is not trustworthy and accessible to your teams? You will face challenges…

Share:

Generative AI and the changing face of Software Development Lifecycle

Explore how Generative AI is transforming the Software Development Lifecycle, boosting efficiency, accuracy, and innovation across all stages.

Share:
Kubernetes Introduction and Architecture Overview

Kubernetes: Introduction and Architecture Overview

Containers are taking over and have become one of the most promising methods for developing applications as they provide the end-to-end packages necessary to run your applications….

Share:
How to Perform Hardware and Firmware Testing of Storage Box

How to Perform Hardware and Firmware Testing of Storage Box

In this blog will discuss about how to do the Hardware and firmware testing, techniques used, then the scope of testing for both. To speed up your testing you can use tools mentioned end of this blog, all those tools are available on internet. Knowing about the Hardware/Firmware and how to test all these will help you for upgrade testing of a product which involve firmware

Share:
How to Choose the Right Partner for Outsourcing Product Development Services

How to Choose the Right Partner for Outsourcing Product Development Services

Learn how to choose the right partner for outsourcing product development services and discover the benefits and strategies for successful collaboration.

Share:
Cloud Application Development

Challenges of Cloud Application Development

Explore the challenges and solutions of cloud application development, including benefits, performance issues, and overcoming vendor lock-in for seamless cloud integration.

Share: