Fully Transparent Java Objects in Nashorn

Nashorn's JSAdapter is a powerful tool for handling Java objects in JavaScript with full transparency. It can be used to wrap Java objects and add new properties and behaviour. For example: var Date = Java.type('java.time.LocalDate') function wrapDate(d) {     return new JSAdapter() {         __get__: function(name) {             if (name === 'yesterday') {                 return d.minusDays(1)             }             return d[name]         }     } } var now = wrapDate(Date.now()) When...

Thursday, November 5, 2015 | Read More

Flexible JSON with Nashorn Parser API (JDK9)

[Posted by Sundar]  I recently came across Hjson - "the Human JSON - A configuration file format that caters to humans and helps reduce the errors they make". See also: http://hjson.org. I wanted to see if I can use Nashorn Parser API (jdk9) to support similar flexible JSON extension with Nashorn. In the following FlexiJSON.parse implementation, Nashorn Parser API is used to validate that the extendable flexi JSON is "data only" (That is, no executable code) andthen 'eval'uated...

Monday, April 20, 2015 | Personal | Read More

JavaScript Stored Procedures and Node.js Applications with Oracle Database 12c

This is a reposting of an article written by Kuassi Mensah JavaScript Stored Procedures and Node.js Applications with Oracle Database 12c Introduction Node.js and server-side JavaScript are hot and trendy; per the latest “RedMonk Programming Languages Rankings”[1], JavaScript and Java are the top two programming languages. For most developers building modern Web, mobile, and cloud based applications, the ability to use the same language across all tiers (client, middle, and...

Tuesday, February 10, 2015 | Personal | Read More

Using Nashorn with IntelliJ

Hi!  The Nashorn repository already contains a Netbeans project, so that you can seamlessly work with Netbeans as your IDE when using Nashorn. There are some tricks, for example, the IDE needs to build and access the pre-generated Nasgen classes that represent the builtin JavaScript objects: Array, Date, Number, String etc. These are part of the build step, and are generated if you just execute "ant clean jar" from the command line. Nashorn, furthermore, is now a jimage in Java...

Friday, January 9, 2015 | Personal | Read More

Nashorn Architecture and Performance Improvements in the Upcoming JDK 8u40 Release

Hello everyone! We've been bad at blogging here for a while. Apologies for that. I thought it would be prudent to talk a little bit about OpenJDK 8u40 which is now code frozen, and what enhancements we have made for Nashorn. 8u40 includes a total rewrite of the Nashorn code generator, which now contains the optimistic type system. JavaScript, or any dynamic language for that matter, doesn't provide enough compile time information to easily generate performant code. This is why,...

Friday, December 12, 2014 | Personal | Read More

Porting from the Browser to Nashorn/JavaFX (Part I)

During the JavaOne Nashorn: JavaScript for the JVM session, I showed a couple examples of converting JavaScript browser examples to use Nashorn and JavaFX. The first example was using CKEditor, a rich text/HTML editor. This editor is written entirely in JavaScript using the browser DOM interface. In this case, it did not really make sense to convert all the DOM code over to FX. Instead, I used the JavaFX WebView which supports all the DOM needed. So let's start with a simple...

Friday, October 24, 2014 | Personal | Read More

Visit the Oracle Blog


Contact Us


Integrated Cloud Applications & Platform Services