Nashorn (JavaScript engine)

Last updated
Nashorn
Developer(s) Oracle Corporation, OpenJDK Community
Stable release
15.4 / April 23, 2022;2 years ago (2022-04-23)
Repository
Written in Java
Operating system Cross-platform
Platform Java Virtual Machine
Type JavaScript engine
License GPL with a linking exception

Nashorn is a JavaScript engine developed in the Java programming language originally by Oracle and later by the OpenJDK Community. It relies on the support for dynamically typed languages on the Java Platform (JSR 292) (a concept first realized in the experimental Da Vinci Machine and a standard part of Java 7 and later.) Nashorn was included with Java 8 through JDK 14. [1] [2] [3]

Contents

History

The project was announced first at the JVM language summit in July 2011, [4] [5] and then confirmed at JavaOne in October 2011. [6]

On November 21, 2012, Oracle formally announced the open sourcing of the Nashorn source on the OpenJDK repository. The project aim will be to allow embedding JavaScript in Java applications via JSR-223 and to develop standalone JavaScript applications. [7] On December 21, 2012, Oracle announced Nashorn source was publicly released in the OpenJDK repository. [8]

It provides a 100% support of ECMAScript 5.1. [9] It was the first JavaScript implementation to achieve 100% pass rate on the ECMAScript 5.1 test suite. [10]

With the release of Java 11, Nashorn was deprecated citing challenges to maintenance, and has been removed from JDK 15 onwards. [11] [12]

Nashorn development continues on GitHub as a standalone OpenJDK project and the separate release can be used in Java projects from Java 11 and up.

Name

Nashorn [ˈnaːsˌhɔɐ̯n] ("nahss-horn") is the German translation of rhinoceros, a play on words on Rhino, the name of a JavaScript engine implemented in Java and provided by Mozilla Foundation. The latter gets its name from the animal on the cover of the JavaScript book from O'Reilly Media. [13]

Performance

According to Oracle benchmarks, Nashorn performance is several orders of magnitude faster than the alternative Rhino JavaScript engine. [14]

See also

Related Research Articles

<span class="mw-page-title-main">Java virtual machine</span> Virtual machine that runs Java programs

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation. Having a specification ensures interoperability of Java programs across different implementations so that program authors using the Java Development Kit (JDK) need not worry about idiosyncrasies of the underlying hardware platform.

Rhino is a JavaScript engine written fully in Java and managed by the Mozilla Foundation as open source software. It is separate from the SpiderMonkey engine, which is also developed by Mozilla, but written in C++ and used in Mozilla Firefox.

BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. It runs in the Java Runtime Environment (JRE), dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures, like those in Perl and JavaScript.

javac is the primary Java compiler included in the Java Development Kit (JDK) from Oracle Corporation. Martin Odersky implemented the GJ compiler, and his implementation became the basis for javac.

HotSpot, released as Java HotSpot Performance Engine, is a Java virtual machine for desktop and server computers, developed by Sun Microsystems which was purchased by and became a division of Oracle Corporation in 2010. Its features improved performance via methods such as just-in-time compilation and adaptive optimization. It is the de facto Java Virtual Machine, serving as the reference implementation of the Java programming language.

<span class="mw-page-title-main">Java (software platform)</span> Set of computer software and specifications

Java is a set of computer software and specifications that provides a software platform for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers. Java applets, which are less common than standalone Java applications, were commonly run in secure, sandboxed environments to provide many features of native applications through being embedded in HTML pages.

The Java language has undergone several changes since JDK 1.0 as well as numerous additions of classes and packages to the standard library. Since J2SE 1.4, the evolution of the Java language has been governed by the Java Community Process (JCP), which uses Java Specification Requests (JSRs) to propose and specify additions and changes to the Java platform. The language is specified by the Java Language Specification (JLS); changes to the JLS are managed under JSR 901. In September 2017, Mark Reinhold, chief Architect of the Java Platform, proposed to change the release train to "one feature release every six months" rather than the then-current two-year schedule. This proposal took effect for all following versions, and is still the current release schedule.

OpenJDK is a free and open-source implementation of the Java Platform, Standard Edition. It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GPL-2.0-only with a linking exception. Were it not for the GPL linking exception, components that linked to the Java Class Library would be subject to the terms of the GPL license. OpenJDK is the official reference implementation of Java SE since version 7.

Scripting for the Java Platform is a framework for embedding scripts into Java source code.

<span class="mw-page-title-main">JavaFX</span> Java software platform for GUI

JavaFX is a software platform for creating and delivering desktop applications, as well as rich web applications that can run across a wide variety of devices. JavaFX has support for desktop computers and web browsers on Microsoft Windows, Linux, and macOS, as well as mobile devices running iOS and Android, through Gluon Mobile.

The Java Class Library (JCL) is a set of dynamically loadable libraries that Java Virtual Machine (JVM) languages can call at run time. Because the Java Platform is not dependent on a specific operating system, applications cannot rely on any of the platform-native libraries. Instead, the Java Platform provides a comprehensive set of standard class libraries, containing the functions common to modern operating systems.

The Java Platform Module System specifies a distribution format for collections of Java code and associated resources. It also specifies a repository for storing these collections, or modules, and identifies how they can be discovered, loaded and checked for integrity. It includes features such as namespaces with the aim of fixing some of the shortcomings in the existing JAR format, especially the JAR Hell, which can lead to issues such as classpath and class loading problems.

<span class="mw-page-title-main">Da Vinci Machine</span> Sun Microsystems project

The Da Vinci Machine, also called the Multi Language Virtual Machine, was a Sun Microsystems project aiming to prototype the extension of the Java Virtual Machine (JVM) to add support for dynamic languages.

The Java Development Kit (JDK) is a distribution of Java technology by Oracle Corporation. It implements the Java Language Specification (JLS) and the Java Virtual Machine Specification (JVMS) and provides the Standard Edition (SE) of the Java Application Programming Interface (API). It is derivative of the community driven OpenJDK which Oracle stewards. It provides software for working with Java applications. Examples of included software are the Java virtual machine, a compiler, performance monitoring tools, a debugger, and other utilities that Oracle considers useful for Java programmers.

<span class="mw-page-title-main">Google Closure Tools</span> JavaScript developer toolkit

Google Closure Tools is a set of tools to help developers build rich web applications with JavaScript. It was developed by Google for use in their web applications such as Gmail, Google Docs and Google Maps. As of 2023, the project had over 230K LOCs not counting the embedded Mozilla Rhino compiler.

The JDK Enhancement Proposal is a process drafted by Oracle Corporation for collecting proposals for enhancements to the Java Development Kit and OpenJDK.

<span class="mw-page-title-main">GraalVM</span> Virtual machine software

GraalVM is a Java Development Kit (JDK) written in Java. The open-source distribution of GraalVM is based on OpenJDK, and the enterprise distribution is based on Oracle JDK. As well as just-in-time (JIT) compilation, GraalVM can compile a Java application ahead of time. This allows for faster initialization, greater runtime performance, and decreased resource consumption, but the resulting executable can only run on the platform it was compiled for.

JDK Flight Recorder is an event recorder built into the OpenJDK Java virtual machine. It can be thought of as the software equivalent of a Data Flight Recorder in a commercial aircraft. It captures information about the JVM itself, and the application running in the JVM. There is a wide variety of data captured, for example method profiling, allocation profiling and garbage collection related events. The JDK Flight Recorder was designed to minimize the Observer Effect in the profiled system, and is meant to be always on in production systems. The technology was open sourced in 2018.

References

  1. Laskey, James (July 2011). "Adventures in JSR-292 or How To Be A Duck Without Really Trying" (PDF). Oracle Corporation. Archived from the original (PDF) on 2016-06-03. Retrieved 2011-07-24.
  2. "Proposed new schedule for Java 8". 2013-04-18. Retrieved 2013-04-19.
  3. "JDK 8". OpenJDK. 2013-04-18. Retrieved 2013-04-19.
  4. "JVM Language Summit — Agenda". Oracle Corporation. July 2011. Archived from the original on 2011-08-19. Retrieved 2011-07-24.
  5. Saab, Georges (2011-07-19). "JVM Language Summit: Moving Java Forward, aka 'Pointy haired manager talk'" (PDF). Oracle Corporation. Archived from the original (PDF) on 2012-04-23. Retrieved 2011-07-24.
  6. Krill, Paul (2011-10-05). "Oracle prepping its Nashorn JavaScript engine". InfoWorld . Retrieved 2011-10-08.
  7. Coomes, John (2012-11-21). "CFV: New Project: Nashorn". Oracle Corporation . Retrieved 2012-11-24. I hereby propose the creation of the Nashorn Project with Jim Laskey as the Lead and HotSpot group as the sponsoring Group. In accordance with the OpenJDK guidelines [1], we would like to start a new project to implement a lightweight high-performance JavaScript runtime in Java with a native JVM
  8. Laskey, J (2012-12-21). "Open for business". Oracle Corporation . Retrieved 2012-12-21.
  9. "Java Platform, Standard Edition Java API Reference".
  10. "Tweet showing all ECMAScript 5.1 tests passing on the screen of a Nashorn developers' computer".
  11. "JEP 335: Deprecate the Nashorn JavaScript Engine". 2017-07-17. Retrieved 2018-09-25.
  12. "JEP 372: Remove the Nashorn JavaScript Engine". 2020-01-10. Retrieved 2020-07-22.
  13. "JavaScript: The Definitive Guide, 5th Edition". O'Reilly Media, Inc. Retrieved 2012-01-31.
  14. "Nashorn Architecture and Performance Improvements in the Upcoming JDK 8u40 Release". Oracle Corporation. 2014-12-12. Retrieved 2015-09-06.