JShell: An Interactive Shell for the Java Platform

Slides:



Advertisements
Similar presentations
Using Microsoft PowerPoint in the Classroom
Advertisements

Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Whats New in Office 2010?. Major Changes in Office 2010 The Office Ribbon, which first made its appearance in Office 2007, now appears in all Office 2010.
MS® PowerPoint.
Step-by-Step: Add a Graphical Hyperlink USE the Special Events Final presentation that is still open from the previous exercise. 1.Go to slide 4, and click.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
COE201 – Computer Proficiency Mr. Hamze Msheik
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Editing Java programs with the BlueJ IDE. Working environments to develop (= write) programs There are 2 ways to develop (write) computer programs: 1.Using.
A Prezi presentation is like creating a mind map. It is created on a blank canvas and you decide where the information goes on this canvas.
Lesson 15 Getting Started with PowerPoint Essentials
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Key Applications Module Lesson 19 — PowerPoint Essentials
Learning Microsoft Power Point Getting Started  There are three features that you should remember as you work within PowerPoint 2007: the Microsoft.
Press Esc to Exit ©2011 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in.
CHAPTER 10 Creating a Word Document. Learning Objectives Enter text Undo and redo actions Create documents based on existing documents Select text Edit.
More PowerPoint. Re-using your slides You can re-use your slides in different presentation. Choose Insert, Slides from Files Browse to locate the presentation.
VBQU149 Create texts of some complexity. Columns Making columns in Microsoft Word Open word and blank page type =rand() Go to page layout, then columns.
Design around your audience:  Keep layouts clean and simple for all audiences. Be consistent.  For professionals, try using a sophisticated template.
Melvin Robinson Utah State Office of Education Technology and Engineering Education For Using and Teaching.
Chapter 5 Using a Template to Create a Resume and Sharing a Finished Document Microsoft Word 2013.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Lambdas & Streams Laboratory
Enterprise Communications
Shelly Cashman: Microsoft Word 2016
June 17, 2009 Office 2007 Tips & Tricks.
Creating a Presentation
Computer Fundamentals 1
Running a Forms Developer Application
Introduction to Microsoft Publisher 2016
Welcome: Hands-On Lab Plug in to the network.
This is a Safe Harbor Front slide, one of two Safe Harbor Statement slides included in this template. One of the Safe Harbor slides must be used if your.
Working in the Forms Developer Environment
Building Regression Tests With PeopleSoft Test Framework
This is a Safe Harbor Front slide, one of two Safe Harbor Statement slides included in this template. One of the Safe Harbor slides must be used if your.
Short presentation title up to 2 lines
Short presentation title up to 2 lines
New Oracle Database Release Model
Oracle JavaOne 2017 – Hands-On Labs (HOL) Get Started on Oracle Cloud: Java Apps with Containers and DevOps Plug in to the network Connect via WiFi. Connect.
Oracle and CERN openlab
Guide To UNIX Using Linux Third Edition
Shelly Cashman: Microsoft PowerPoint 2016
Comprehend. Create. Communicate. Achieve More.
Introducing Microsoft Office 2010
BlackJack Hands-on-lab
Oracle Analytic Views Enhance BI Applications and Simplify Development
Tutorial Introduction to support.ebsco.com.
Multi-host Internet Access Portal (MIAP) Enhancement Guide
Windows Internet Explorer 7-Illustrated Essentials
CMS to G1 - Java GC Vaibhav Choudhary Java Platforms Team
PowerPoint Quick Tips Bad Ischl, Nov
Solutions – Oracle’s Story
Working with Headers and Footers
SAMPLE PRESENTATION Company Name presents PowerPoint Basics
Benchmark Series Microsoft Word 2016 Level 2
Microsoft PowerPoint 2007 – Unit 2
Oracle ZFS Storage Backup Appliance
Introduction to Java Brief history of Java Sample Java Program
Autodesk Inventor Tips and Tricks for New Users
Objectives At the end of this session, students will be able to:
Lesson 13 Editing and Formatting documents
Shelly Cashman: Microsoft Word 2016
Node.js Test Automation using Oracle Developer Cloud- Simplified
How to Become a PowerPoint Wizard
Managing CPQ Performance Proactively
HIBBs is a program of the Global Health Informatics Partnership Learning the Basics of Microsoft Word 2019 and Microsoft office support TFN
Solution Demonstrations
Tutorial Introduction to help.ebsco.com.
Welcome To Microsoft Word 2016
Presentation transcript:

JShell: An Interactive Shell for the Java Platform This is a Title Slide with Picture slide ideal for including a picture with a brief title, subtitle and presenter information. To customize this slide with your own picture: Right-click the slide area and choose Format Background from the pop-up menu. From the Fill menu, click Picture and texture fill. Under Insert from: click File. Locate your new picture and click Insert. To copy the Customized Background from Another Presentation on PC Click New Slide from the Home tab's Slides group and select Reuse Slides. Click Browse in the Reuse Slides panel and select Browse Files. Double-click the PowerPoint presentation that contains the background you wish to copy. Check Keep Source Formatting and click the slide that contains the background you want. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Right-click any selected slide, point to Layout, and click the slide containing the desired layout from the layout gallery. Delete any unwanted slides or duplicates. To copy the Customized Background from Another Presentation on Mac Click New Slide from the Home tab's Slides group and select Insert Slides from Other Presentation… Navigate to the PowerPoint presentation file that contains the background you wish to copy. Double-click or press Insert. This prompts the Slide Finder dialogue box. Make sure Keep design of original slides is unchecked and click the slide(s) that contains the background you want. Hold Shift key to select multiple slides. Apply New Layout (Important): Click Layout from the Home tab's Slides group, and click the slide containing the desired layout from the layout gallery. Robert Field JShell Architect Core Language and Tools Group Oracle Corporation October 4, 2017 Confidential – Oracle Internal/Restricted/Highly Restricted

This is a Safe Harbor Front slide, one of two Safe Harbor Statement slides included in this template. One of the Safe Harbor slides must be used if your presentation covers material affected by Oracle’s Revenue Recognition Policy To learn more about this policy, e-mail: Revrec-americasiebc_us@oracle.com For internal communication, Safe Harbor Statements are not required. However, there is an applicable disclaimer (Exhibit E) that should be used, found in the Oracle Revenue Recognition Policy for Future Product Communications. Copy and paste this link into a web browser, to find out more information. http://my.oracle.com/site/fin/gfo/GlobalProcesses/RevRec/Policies/cnt2321729.pdf For all external communications such as press release, roadmaps, PowerPoint presentations, Safe Harbor Statements are required. You can refer to the link mentioned above to find out additional information/disclaimers required depending on your audience. Confidential – Oracle Internal/Restricted/Highly Restricted

What is JShell? Tool providing a dynamic interaction with the Java™ programming language Read-Evaluate-Print Loop (REPL) for the Java™ platform Type in a snippet of Java code, see the results Deeply integrated with JDK tool-set Stays current and compatible Also, an API for use within other applications Dynamic interaction REPL – as seem, dynamic languages Snippet: expression, statement, or declaration Platform: in / built-on Showing command tool using technology. Encourage other tools built on API.

What is JShell NOT? Not a new language “Snippets” of pure No new syntax Nothing added (except allowing snippets) Nothing removed (except things that don’t make sense…) Not a replacement for the compiler Not an IDE The point: interactive Java – not another language, not a mish-mash. Snippets: Java Language Specification productions For interactive exploration – compiler for programs Slippery slope for any language tool – integrate IDE

Who wants JShell? Exploring a new API or language feature Experiment and instantly see results New to Java, new to programming Start with expressions vs classes Immediate feedback Prototyping Incrementally write complex code Now:: write class declaration, method declaration with access modifiers and array parameters, System.out.println JShell:: expressions & immediate see results We are all newbie – new APIs and language features Prototype seeing results at any granularity

Without JShell: Edit-Compile-Execute Write a full program: Class Imports main method Cycle the whole program to understand if the behavior is correct: Edit Compiler or IDE Execute When want to try things out in Java now, you need it wrapped in main method and that wrapped in a class. You need imports for any libraries you are using. You need an editor of something to write the code, then compile it with command line tool or IDE, then execute it. For a whole program that is fine. For exploration that is slow.

Without JShell % cat Test.java import java.util.List; class Test {   public static void main(String... args) {       List<String> alpha = List.of("Z", "A", "C");       alpha.sort(String::compareTo);       System.out.println( alpha );   } } % javac Test.java % java Test Exception in thread "main" java.lang.UnsupportedOperationException at java.base/java.util.ImmutableCollections.uoe(ImmutableCollections.java:70) at java.base/java.util.ImmutableCollections$AbstractImmutableList.sort(ImmutableCollections.java:85) at Test.main(Test.java:7) % This is a sample Title and Code Layout slide, ideal for displaying codes. To take advantage of the pre-formatted paragraph style: Start typing the code, using the tab key (not space key) to increase and Shift+tab keys to decrease indention levels for each paragraphs. Ignore the bullets at this point. If copy and paste the text from other sources, make sure the text is reset to the defaulted size and formatting by clicking Reset, within the Slides Group. (Or select Reset Layout to Default Settings, located at the bottom of the Layout gallery, for Mac.) Delete extra spaces. Once finish typing, select all text in the body copy block and click the Bullets button, within the Paragraph group to turn off bullets. Confidential – Oracle Internal/Restricted/Highly Restricted

Now in JShell…

Using the JShell tool With JDK 9 installed, type “jshell” at the command line The JShell tool takes two kinds of input: “Snippets” of Java code – declaration and execution JShell commands – information and control Commands are distinguished from snippets by leading slash: / All input can be tab completed, has history, and editing JShell evaluates “snippets” of Java code: an expression, statement, variable definition, method definition, class definition, or import.

Snippets Declarations: Statements: Not allowed: String s = “hello” int twice(int x) { return x + x; } class Pair<T> { T a, b; Pair(… interface Reusable { } import java.nio.file.* Statements: while (mat.find()) { … if (x < 0) … switch (val) { case FMT: { format(); break; … Not allowed: package foo; Top-level modifiers: static final Top-level: break continue return Expressions: twice(12) new Pair<>("red", "blue") transactions.stream() .filter(t -> t.getType() == Transaction.GROCERY) .sorted(comparing(Transaction::getValue).reversed()) .map(Transaction::getId) .collect(toList()) Confidential – Oracle Internal/Restricted/Highly Restricted

Commands Snippet information: Snippet control: Session: History: /list /vars /methods /types /imports Snippet control: /edit /drop /save /open Session: /exit /env /reset /reload History: /history /! /id /-n General: /set /help Confidential – Oracle Internal/Restricted/Highly Restricted

/list jshell> /help /li | | /list | Show the source of snippets, prefaced with the snippet id. | List the currently active snippets of code that you typed or read with /open | /list -start | List the automatically evaluated start-up snippets | /list -all | List all snippets including failed, overwritten, dropped, and start-up | /list <name> | List snippets with the specified name (preference for active snippets) | /list <id> | List the snippet with the specified snippet id Confidential – Oracle Internal/Restricted/Highly Restricted

Completion / Information / Control ▷ -- snippet and command completion ▷ -- method parameters ▷ ▷ -- javadoc ⇧▷v -- expression to variable declaration ⇧▷i -- add import ^C -- interrupt running process or abort line ▷ == tab @ method( ⇧▷ == shift-tab ^C == Ctrl-C Confidential – Oracle Internal/Restricted/Highly Restricted

Line Editing (based on JLine 2.0) Navigation ⏎ -- enters typed or history entry RETURN -- navigate line and history Editing – emacs/readline bindings ^A ^E ^L ^K ◆D ^Y ^R ^X ( … -- move to start of line -- move to end of line -- clear screen -- kill rest of line -- kill word (Meta-D) -- yank: paste last killed text -- search history (reverse) -- begin keyboard macro Confidential – Oracle Internal/Restricted/Highly Restricted

Demo

JShell Guiding Principles Compatibility: current and future Avoid chasing corner-cases Build on the platform (JDK) Easy and natural to use One size does not fit all (API) I've seen language tools that “cleverly” implemented functionality their own way, only to to be continually slightly out of sync, playing catch-up, and eventually falling too far behind. JShell built on and in the platform. API makes functionality available to any tool.

JShell Architecture Compilation: built on Compiler API Execution: standard JVM controlled by Java Platform Debug Architecture All core functionality provided by JShell API. The jshell tool just one possible client. The jshell tool uses the popular jline2 API for command line interaction.

JShell module: JShell APIs, SPI, and library Confidential – Oracle Internal/Restricted/Highly Restricted

JShell API An instance of JShell is the starting point. Doing an eval() of an input string returns SnippetEvents. Which hold several things, like value. But also created Snippets. Queries can be made for information about the Snippet. SourceCodeAnalysis provides information like completion. [API Demo?]

Meta-Demo

JDK 9 Information JShell released with JDK 9! Download now: www.oracle.com/javadownload Documentation: https://docs.oracle.com/javase/9/ Join the OpenJDK mailing lists: openjdk.java.net Follow us on Twitter: @OpenJDK and #Java9 Source code: hg.openjdk.java.net/jdk9/dev/ JShell now in JDK 9

JShell Documentation jshell tool tutorial “User Guide”: https://docs.oracle.com/javase/9/jshell jshell tool Reference: https://docs.oracle.com/javase/9/tools/jshell.htm JShell APIs: https://docs.oracle.com/javase/9/docs/api/jdk.jshell-summary.html JShell now in JDK 9

JShell Information JShell JEP: The Java Shell: http://openjdk.java.net/jeps/222 JShell project / mailing list: http://openjdk.java.net/projects/kulla/ JShell / my Twitter: @JShellRobert JShell now in JDK 9

The Team Engineering OpenJDK Commiters Documentation: Robert Field Jan Lahoda OpenJDK Commiters Shinya Yoshida You? Documentation: Joni Gordon Advisors / Cheerleaders / Reviewers Brian Goetz Maurizio Cimadamore Joe Darcy Paul Sandoz Jonathan Gibbons Michel Trudeau Sundararajan Athijegannathan Rémi Forax Arun Gupta Mani Sarkar Daniel Daugherty Jan and I are the Oracle engineering team. Shinya Yoshida has contributed significantly as an OpenJDK Commiter, as could you, … The project was Brian's inspiration. Many people have advised, reviewed, and cheered us on.

Q & A

Stay connected Join us: DevOps Corner (Developer Lounge – Moscone West) Learn more: openjdk.java.net | wercker.com/java Follow: @OpenJDK, @wercker #JavaOne #DevOps

This is a Safe Harbor Front slide, one of two Safe Harbor Statement slides included in this template. One of the Safe Harbor slides must be used if your presentation covers material affected by Oracle’s Revenue Recognition Policy To learn more about this policy, e-mail: Revrec-americasiebc_us@oracle.com For internal communication, Safe Harbor Statements are not required. However, there is an applicable disclaimer (Exhibit E) that should be used, found in the Oracle Revenue Recognition Policy for Future Product Communications. Copy and paste this link into a web browser, to find out more information. http://my.oracle.com/site/fin/gfo/GlobalProcesses/RevRec/Policies/cnt2321729.pdf For all external communications such as press release, roadmaps, PowerPoint presentations, Safe Harbor Statements are required. You can refer to the link mentioned above to find out additional information/disclaimers required depending on your audience. Confidential – Oracle Internal/Restricted/Highly Restricted