Jigsaw encapsulation: Running NetLogo 6.0 with Java 9

NetLogo is a multi-agent programmable modeling environment that runs on Java. Recently NetLogo 6.0 has been released. I wanted to try NetLogo 6.0 with a recent Java 9 (local) build. Running NetLogo 6.0 with Java 9 I installed NetLogo 6.0 and ran it with the following Java command line: $ ~/src/jdk9-dev/build/macosx-x86_64-normal-server-release/images/jdk/bin/java -jar Java/netlogo-6.0.0.jar Exception - stack trace Just after showing NetLogo splash screen, the above Java...

Monday, December 26, 2016 | Java | Read More

Java source name pattern checker with a nashorn script

Ken Fogel recently tweeted: a,b,c,d,e,f,g,h,I,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y & z are not identifiers. IDE should show an error when an identifier is less than 3 char. While I don't have any IDE solution here, the following Nashorn script may be customized to check class, method and variable name patterns in Java sources. This script uses Javac Tree API to parse java sources. Then it uses a TreeScanner subclass in script to call checkXYZ methods to check class, method and...

Tuesday, June 21, 2016 | Nashorn | Read More

Extracting a single .class file from java9 platform jimage modules file

We can use java FileSystem API from Nashorn JavaScript to extract a single .class file from java9 platform jimage modules file. The following simple Nashorn script extracts .class of the given class name: File: jextract.js // This script extracts .class for a single class// from the platform jimage ($JDK9/lib/modules) file.// Specify module/class like java.base/java.util.Vectorif (arguments.length == 0) { print("Usage: jjs jextract -- <module>/<classname>") exit(1)}//...

Friday, April 15, 2016 | Nashorn | Read More

Accessing Python objects from Nashorn JavaScript

Dynamic linker API for the Java platform (JEP 276) in JDK 9 Early Access defines dynamic linker API for the Java platform. Using this API, different language runtimes implemented for the Java platform can interoperate with each other. Nashorn JavaScript engine has been a part of JDK platform since JDK 8. Jython is an implementation of the Python programming language designed to run on the Java platform. In this blog entry, I'll demonstrateseamless access of Python objects from...

Friday, January 29, 2016 | Java | Read More

Printing parse trees using nashorn directive prologues

ECMAScript specification allows for "directive prologues" (http://www.ecma-international.org/ecma-262/5.1/#sec-14.1). A directive prologue in an instruction to the ECMAScript engine. Apart from the standard specified "use strict" directive (which makes the particular program or function "strict"), ECMAScript specification allows implementation defined directive prologues as well. Implementations may define implementation specific meanings for ExpressionStatement productions...

Tuesday, January 5, 2016 | Nashorn | Read More

Writing a pluggable dynalink linker and using it with Nashorn

JEP-276 (JEP 276: Dynamic Linking of Language-Defined Object Models) adds a facility for linking high-level operations on objects such as "read a property", "write a property", "invoke a callable object", etc., expressed as names in INVOKEDYNAMIC call sites. Nashorn JavaScript engine in OpenJDK uses dynalink for linking script and other objects. JEP 276 allows user written ("pluggable") linkers to be loaded via service loader mechanism. Because of Dynalink, Nashorn...

Monday, November 30, 2015 | Java | Read More

Using Dynalink API with invokedynamic - a Java assembler example

Dynalink API JEP-276 Dynalink API (http://openjdk.java.net/jeps/276) provides a facility for linking high-level operations on objects such as "read a property", "write a property", "invoke a callable object", etc., expressed as names in INVOKEDYNAMIC call sites. Dynalink also provides a default linker for the usual semantics of these operations on plain Java objects (Java POJO "beans" linker), as well as a facility for installing your own language-specific linkers. Dynalink has...

Friday, November 27, 2015 | Java | Read More

Remote debugging of nashorn scripts with NetBeans IDE using "debugger" statements

You can debug nashorn scripts - even if you do not create any NetBeans project or even open the JavaScript files in NetBeans! You just need to connect NetBeans debugger to a remote Java process that evaluates Nashorn scripts! You can use ECMAScript debugger statements to stop the script execution at the places of interest. Start the process running your script with debugger agent I'm using "jjs" tool to run a sample script - but you may use any java application that evaluates...

Wednesday, November 25, 2015 | Nashorn | Read More

Dynamic linker API for the Java platform (JEP 276)

JEP 276 defines dynamic linker API for Java. This JEP provides "facility for linking high-level operations on objects such as "read a property", "write a property", "invoke a callable object", etc., expressed as names in INVOKEDYNAMIC call sites. Provide a default linker for the usual semantics of these operations on plain Java objects, as well as a facility for installing language-specific linkers. Nashorn JavaScript engine already uses "dynalink" library for linking...

Tuesday, November 10, 2015 | Java | Read More

Underscore is a keyword in Java 9, use this script to check your code!

Underscore ("_") is a keyword in Java 9. If you use "_" as an identifier, javac of JDK 8+ issues a warning. javac of JDK 9, issues an error! To check and migrate your Java code to avoid using "_" as an identifier, you can use the following Nashorn script with jjs tool. This script just parses each .java file and reports "_" variables with filename, line and column numbers. This script uses Javac Tool API and Compiler Tree API. File: find_underscore.js // Usage: jjs...

Wednesday, October 28, 2015 | Java | Read More

Nashorn js extension for NetLogo - implementing NetLogo commands, reporters in scripts!

Earlier I blogged about playing with NetLogo using Nashorn. NetLogo, as you'd recall, is a multi-agent programmable modeling environment for the Java platform. In addition to supporting NetLogo programming language, NetLogo supports extensions written in JVM languages such as Java, Scala. To write extensions, NetLogo supports an Extensions API. Writing a NetLogo extension in Java or Scala or any compiled JVM language means that you've to compile and make a jar to...

Saturday, October 10, 2015 | Nashorn | Read More

Fun with NetLogo using Nashorn JavaScript engine

NetLogo is a multi-agent programmable modeling environment running for the Java platform. In addition to being a GUI program to edit and run NetLogo models, NetLogo supports Controlling API so that NetLogo can be invoked and controlled by a program running on JVM. The "controlling api" supports both GUI and 'headless' mode. I used Nashorn javascript engine to use NetLogo "controlling API" from a script. I ran the bundled Maxwell's demon model in "headless mode" using the...

Thursday, October 8, 2015 | Nashorn | Read More

Standalone JavaFX FXML app with nashorn scripts for event handling - no java code!

In nashorn openjdk repository http://hg.openjdk.java.net/jdk9/dev/nashorn, there is a script called "fxmlrunner.js" in the "samples" directory. This script can accept any FXML file as command line argument and "run it". If that FXML file has event handlers written in (nashorn) javascript, then we can have complete runnable application without having to write any Java code! When I came across this FXML example https://github.com/halcat0x15a/calculator/blob/master/src/calculator...

Saturday, October 3, 2015 | JavaFX | Read More

Playing with Java (java9) REPL - an example that uses nashorn engine in REPL

I love "Exploratory Programming" (https://en.wikipedia.org/wiki/Exploratory_programming) tools. If you've not already played with "Java REPL" project, you may want to do so! Check out Kulla project. Clone kulla forest @ http://hg.openjdk.java.net/kulla and build using these commands:hg clone http://hg.openjdk.java.net/kulla/dev kulla-dev cd kulla-dev sh get_sources.sh sh configure --with-boot-jdk=/path/to/jdk1.8.0 make clean images make install Once build finishes, you can use the...

Wednesday, September 30, 2015 | Java | Read More

Playing with Nerdamer symbolic math JS library with Nashorn jjs

I was searching for a self-contained, simple JS library for symbolic math to check homework solutions of my son. On googling "symbolic math javascript", the first hit I got was http://www.nerdamer.com/ I git cloned the source from the git repo: $ cd ~/src$ git clone https://github.com/jiggzson/nerdamer$ cd nerdamer There is a nice documentation for nerdamer @ http://www.nerdamer.com/documentation I started Nashorn jjs shell. The following is from my jjs session with nerdamer. $...

Tuesday, September 22, 2015 | Nashorn | Read More

Graphs, GXL, dot and Graphviz

Sometimes you may want to quickly generate graphs programmatically and view/analyze those. Examples include, inheritance/type relation diagrams of an object oriented program, function call graphs and any other domain specific graphs (reporting chain of your organization chart for example). I find GXL very useful for this. GXL stands for Graph eXchange Language. It is a simple XML format to specify graphs. A simple graph stating that "JavaFX" language is related to "Java"...

Saturday, December 12, 2009 | General | Read More

Look Ma, javac tells me I am overriding static method wrongly!!

// File: SuperClass.javapublic class SuperClass { public static int func() { return 0; }} // File: SubClass.javapublic class SubClass extends SuperClass { public static boolean func() { return false; }} $ javac -fullversionjavac full version "1.6.0_15-b03-226"javac SuperClass.java SubClass.java SubClass.java:2: func() in SubClass cannot override func() in SuperClass; attempting to use incompatible return typefound : booleanrequired: int public...

Tuesday, October 20, 2009 | Java | Read More

"helloworld" with Maxine JVM on Mac

Last night, I listened to this nice podcast on Maxine JVM from Software Engineering Radio. Maxine is a Java Virtual Machine implemented in the Java programming language. I wanted to try out Maxine on my MacBook Pro running Mac OS X 10.5.8. I followed these steps to try it out: Get the Maxine sources hg clone https://kenai.com/hg/maxine~maxine maxine Setup the environment export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home export...

Wednesday, September 16, 2009 | Books | Read More

java.lang.NoClassDefFoundError: com/sun/javafx/runtime/FXBase

I created a simple JavaFX applet and compiled it with "javafxc" and created a jar "HelloApplet.jar". Then, I created a simple HTML file as follows: <script src="http://dl.javafx.com/dtfx.js"></script><script> javafx( { archive: "HelloApplet.jar", draggable: true, width: 150, height: 100, code: "hello.HelloApplet", name: "HelloApplet" } );</script> When viewing...

Wednesday, September 2, 2009 | JavaFX | Read More

My twitter updates..

In the past, I blogged about Cricket (the sport and not the insect!) in this space. Once angry reader questioned me why I was writing that here. I guess people read my Sun blogs only tech. stuff. That is fine. So, I've revived my twitter login. I'll be posting my one liners (tech as well as non-tech) there. Longer posts on tech. (mostly Java, JavaFX) topics will continue here.

Monday, July 27, 2009 | General | Read More

Teaching programming to kids

I've been experimenting/playing with programming tools for kids. I've two kids - 8 and 5 year old. Scratch Great multimedia rich introduction to programming for kids. My son keeps playing with it! If you are after ease-of-use, this is probably the best choice. Available for download on Mac and Windows. If you haveSqueak installed, you can get Scratch running on Linux as well (possibly with some audio problems). It is possibleto export your Scratch projects as applets from...

Tuesday, July 21, 2009 | education | Read More

BTrace "unsafe" mode

We kept saying BTrace is a safe, dynamic tracing tool for Java. To ensure safety, BTrace does not permit many constructs of Java language and also allows calls only to BTraceUtils class.But, not everyone likes safety -- sometimes developers want "unsafe" facility ("I know what I am doing"-style). We have got comments of this nature about BTrace - for example here and here. We have added "unsafe" mode to BTrace - you can edit "btrace" script to change -Dcom.sun.btrace.unsafe=...

Tuesday, July 14, 2009 | Java | Read More

javafxdoc-style docs for Java code

You may have browsed JavaFX API docs generated by javafxdoc tool. javafxdoc tool is implemented as a doclet. It is possible to use javafxdoc's doclet to generate API docs for Java code. Note: The XMLDoclet implemented as part of javafxdoc tool is an implementation detail and not part of official JavaFX/tool API and so please do not depend on this. This is more for fun/learning/personal use!) I generated javadoc for BTrace source using the following command: javadoc -docletpath...

Sunday, July 12, 2009 | JavaFX | Read More

BTrace project moved to kenai.com

We have recently moved BTrace project to kenai.com. If you are interested in BTrace, please continue to use it and help develop it from kenai.com.

Monday, July 6, 2009 | Java | Read More

JavaFX interactive shell

JavaFX compiler has a built-in script shell - Per Bothner has implemented a read-eval-print loop facility for JavaFX. The script shell class is com.sun.tools.javafx.script.ScriptShell.Note:This is in the openjfx-compiler repository and not in the JavaFX 1.0 binary. A sample JavaFX session is as follows: $ java -cp dist/lib/shared/javafxc.jar com.sun.tools.javafx.script.ScriptShell /\*fx1\*/ "hello"hello/\*fx2\*/ 2 + 46/\*fx3\*/ function greet (name) { println("Hello, {name}") }/...

Sunday, February 22, 2009 | JavaFX | Read More

A JavaFX compiler debug trick

There is an unsupported (read - can be removed in future without notice!) command line option with JavaFX compiler. If you run javafxc as javafxc -XDdumpjava Test.fx the compiler generates intermediate Java code for your JavaFX program in "./dumpjava" directory (compiler expects you to create ./dumpjava directory before invoking javafxc). This is meant to be a debugging option for JavaFX compiler developers. But, you can look at generated Java code to see what happens...

Thursday, February 19, 2009 | JavaFX | Read More

JavaFX for Java, JavaScript programmers

I missed attending and speaking at Sun Tech Days at Hyderabad due to a personal reason :-( In fact, I prepared slides for a talk titled "JavaFX for Java, JavaScript programmers". This is much like my earlier language comparison blog entries such as Java, JavaScript and Jython, Java, Groovy and JRuby etc. The idea is to learn a language by language comparison - and not to conclude "better"/"worse" language and so on. So, no politics please :-) Although I could not attend Sun...

Thursday, February 19, 2009 | JavaFX | Read More

Installed Ubuntu 8.10 on my PS3

Ubuntu on PS3 I wanted to install Ubuntu on my PlayStation 3. My Setup PS3 is NTSC 60 GB hard disk version - updated with firmware version 2.42. PS3 is connected to 32 inch 720p Sony LCD TV via HDMI. PS3 is connected to wireless network. Stuff needed in addition to the above USB keyboard. USB mouse. CD burned with Ubuntu powerpc iso (ubuntu-8.10-alternate-powerpc+ps3.iso). Preparing PS3 Backup your PS3 hard disk using [Settings] -> [System Settings] -> [Backup Utility] menu.I didn't...

Tuesday, December 23, 2008 | General | Read More

Debugging option for javac and javafxc

I work on JavaFX compiler these days. The command line (debugging) option that I often use is -doe ("dump on error"). This option prints stack trace of the compiler when error message is printed. NOTE: This is an internal option and can be removed any time without notice! But, it is useful for debugging. This option works for javac as well as javafxc. When I misspelled "class" as "clas" and run compiler with -doe option, I got the stack trace below: $ javac -doe t.javat.java:1:...

Wednesday, December 17, 2008 | Java | Read More

Yet another reason for using VirtualBox

I bought a laptop from ELCOT for my sons. It came with SUSE Linux Enterprise Desktop 10 SP2. Kids wanted to see how it is like playing games in the "old" days. Nothing better than seeing and really playing! And so VirtualBox :-) Also, having access to more than one OS without having to partition does not hurt -- even for a kid's laptop! We can run OLPC, OpenSolaris, Puppy Linux, or anything else!

Wednesday, December 10, 2008 | education | Read More

Playing with Alice and PhET

These days, my son is playing with these (apart from usual game sites): Alice Alice is a 3D programming environment. He likes it as much as he likes Scratch. PhET Interactive simulation tool for physical phenomena from University of Colorado. He kept trying to soft land "on the moon" :-) I guess Chandrayaan I has impressed him a lot! What is the common between Alice and PhET apart from being great education tools? It is Java! With the advent of JavaFX, we can expect that such...

Thursday, December 4, 2008 | education | Read More

Scriptifying BTrace?

One of the issues reported with BTrace is that the trace authors have to write "verbose" code [some people say Java is "verbose"!]. In BTrace, we have to repeat the same set of imports, annotations in every btrace file and all methods have to be "public static void" and so on. Instead of inventing a new scripting language, I've added a simple C preprocessor like step in BTrace compilation. This preprocessor is based on the one in the GlueGen project. Thanks to Ken Russell for...

Friday, August 8, 2008 | Java | Read More

Playing with JSqueak

Squeak is a open source implementation of Smalltalk. What is JSqueak? JSqueak is a Squeak interpreter written in Java. You can download JSqueak source code and play with it. I did the following: Expanded the downloaded JSqueak.zip under a directory, say c:\\JSqueak. cd c:\\JSqueak javac -d . \*.java copy mini.image.gz JSqueak java JSqueak.Main Even if you are not going to learn Smalltalk (why?), you can have the fun of reading Smalltalk VM implemented in Java. If you are lazy and...

Thursday, July 24, 2008 | Java | Read More

BTrace and JMX

You can dyanamically attach BTrace to a Java process to inject trace code into it. BTrace client classescollect the trace output via a socket -- these client classes are used by BTrace command line client as well as VisualVM plugin for BTrace. How about attaching a JMX client to collect BTrace's trace data? Yes, it is possible to access a BTrace class's static fields as attributes of a MBean with this RFE. There are two MBean samples in the BTrace repository. I attached both...

Friday, July 18, 2008 | Java | Read More

Working from an office -- for a change!

I work from home in Chennai, India. There is maintenance power shutdown in my part of the city today [from 9.00 AM to 5.00 PM). I'm writing this blog from a Sun office in Apeejay Business Centre, Chennai. It is nice to be in an office after quite some time - at least as a change! But, I think I'd rather prefer to avoid travel, preparation to go office etc. every day :-)

Thursday, June 26, 2008 | General | Read More

BTrace aggregations - contribution from community

If you have used DTrace, chances are that you have used aggregations. For performance issues, aggregated data is often more useful than individual data points. With BTrace, aggregating data is bit painful (you have to manage using Maps explicitly). It would be nice to have DTrace-style aggregation functions such as sum, max, min and so on. Glencross, Christian M (cited in my previous entry) has contributed code changes, doc and a sample for easy-to-use aggregation facility...

Wednesday, June 25, 2008 | Java | Read More

BTrace in the real world

In the last few weeks, I came to know about two cases of real world use of BTrace.Glencross, Christian M (his blog?) wrote about attempting to write a script to track SQL statements executed by a Java application (private email). Thanks to him for permitting me to blog about his BTrace script. I've made few formatting changes to fit his code in this blog and added few explanatory comments (staring with "VERBOSE:"). import static com.sun.btrace.BTraceUtils.\*;import...

Sunday, June 15, 2008 | Java | Read More

BTrace JavaOne2008 BOF slides..

I received emails asking for BTrace BOF (JavaOne-2008) slides. Better late than never... I've uploaded PDF of the slides. The BOF was mostly around demos -- slides do not contain much. But, slides have few pointers that may be useful.

Wednesday, May 28, 2008 | Java | Read More

Thursday May 8, JavaOne

Here are the few highlights from the talks that I attended today: TS-5428 Java Technology Meets the Real World: Intelligence Everywhere. This talk is about pervasive computing (a.k.a ubiquitous computing) with products from Sentilla. There was an interesting demo about humidity sensor detecting changes and sending a message to a host. The "motes" run CLDC 1.1 VM (+ proprietary profile for motes). These motes have ports for sensors and actuators and some built-in sensor. There...

Friday, May 9, 2008 | Java | Read More

Wednesday May 7, JavaOne

Today Bill, Chihiro, Jaya and I talked on Blu-ray. The talk was centered around the open source project @ http://hdcookbook.dev.java.net - a library and a set of tools to build Blu-ray discs. If you haven't checked out code/docs, you may want to checkout and play with the code. All you need is a laptop with blu-ray drive and a BD-RE disc. Optionally, for added fun you may want to have a hardware bluray player such as PS3 -- so that you can see the output on your TV rather...

Thursday, May 8, 2008 | Java | Read More

Tuesday May 6, JavaOne

In today's sessions that I attended I liked the following: JRuby: Why, What, How... Do It Now This talk is a good introduction to (J)Ruby the language and important applications of (J)Ruby. And many pointers to related (J)Ruby sessions. Nice summary! JavaScript programming language: The Language Everybody Loves to Hate great talk by Roberto Chinnici. Nice summary of functional and prototype-based object orientation aspects of JavaScript. You can easily impress your friends...

Wednesday, May 7, 2008 | Java | Read More

JVM Languages @ JavaOne 2008

In JavaOne 2008, there are many intesting sessions on "other" JVM languages covering both dynamically typed languages (JavaScript, Groovy, JRuby) and statically typed languages (JavaFX, Scala). As usual, there are many sessions covering application aspects -- like using scripting on Glassfish, Grials (Groovy), Rails (JRuby) and so on. But, my interest is mostly on the programming language aspects and JVM implementation issues. Here is a table of sessions covering those: Session...

Tuesday, April 29, 2008 | Java | Read More

BTrace BOF @ JavaOne 2008

We have a BOF on BTrace in this year's JavaOne. But, you will not find the name "BTrace" in session title -- that is because talk was submitted before BTrace was open sourced with that name :-) The details of the BOF is as below. Please visit and let us discuss on dynamic tracing for Java. BOF-5552 Java™ Platform Observability by Bytecode Instrumentation Kannan Balasubramainan, A. Sundararajan Tuesday May 06 19:30 - 20:20 Moscone Center - Esplanade 300 Other related talks/BOFs...

Tuesday, April 29, 2008 | Java | Read More

Groovy jsr-223 engine updated..

Groovy jsr-223 script engine @ scripting.dev.java.net has been updated to use Groovy version 1.5.6.

Monday, April 28, 2008 | Java | Read More

Bluray @ JavaOne 2008

If you want to learn more about Blu-ray disc and what Java has to do with it, you may want to attend the following talks/BOFs @ JavaOne 2008! Date/Time Session ID Session Name Wednesday, May 07 9:30 AM - 10:30 AM TS-5449 Java™ Technology for Blu-ray™ and TV: Creating your own Blu-ray Java Discs Wednesday, May 07 9:30 AM - 1:30 PM - 2:30 PM TS-6464 Blu-ray Disc Security Wednesday, May 07 9:30 AM - 6:30 PM - 7:20 PM BOF-5451 Blu-ray and Java™ Technology Roundtable Thursday May...

Monday, April 28, 2008 | Java | Read More

BTrace - a dynamic tracing tool for Java

Are you interested in a byte code instrumentation (BCI) based dynamic tracing solution for the Java platform? If so, please visit https://btrace.dev.java.net. BTrace is a safe, dynamic tracing solution for Java. You can express tracing code in Java and run it against a running Java application. Your Java application should be running on JDK 6 or above for BTrace to work. You may be using VisualVM, the all-in-one Java troubleshooting tool. VisualVM supports plugin model to...

Friday, March 7, 2008 | Books | Read More

Latest on scripting for the Java platform...

Updates on the world of Scripting for the Java platform: Yoko Harada has updated JRuby jsr-223 engine to use JRuby 1.1RC2. I've updated Groovy jsr-223 engine to use Groovy 1.5.4. You may know this news already: Jython Gurus have joined Sun See also Jython's Future Looking Sunny The Sun is going to shine on Python

Tuesday, March 4, 2008 | Java | Read More

VM on a VM on a ...

My recent fun with virtualization continues. In the last JavaOne, I missed the talk titled "Everything Java": JPC, a Fast x86 PC Emulator. But, I downloaded the source and binary of JPC just to check it out. I ran the classic game "Prince". Nostalgia :-)

Friday, February 15, 2008 | Java | Read More

A tale of many OSes without reboot/partitioning

In my previous post, I talked about having to use more than OS for education/entertainment purpose. The problem is that I've quite a few ISO images and LiveCDs with those images. Two problems: I need to keep searching right LiveCD I want or I need to install more than one OSes on the same/different boxes. Need to re-start the machine if I've use a single machine with many OSes. For kids, all they want is the best stuff available across all operating systems. They don't wait for...

Wednesday, February 13, 2008 | education | Read More

A tale of two operating systems for kids..

When I introduced computers to my kids, as like many other kids they started with games on the net. Mostly playing simple games like tom-and-jerry chase, bob the builder etc. My mother tongue is Tamil and so I came across the kids section of the Tamil Virtual University site. Then, I started experimenting with Squeak and EToys. Later on, I moved to use Scratch. After some time, I learned about GCompris, Tux Math, Alice, Robomind etc. During that period, I still used the...

Monday, February 11, 2008 | education | Read More

No evidence, but still guilty?

Harbhajan banned for three-matches for alleged "racial abuse". Umpires haven't heard or seen anything. Mike Procter himself came on camera and said that the umpires told him they have not heard or seen anything. Did he see anything from the TV footage? It does not seem so. If there is any evidence, we have the right to know it. Aussie players claim something. Indian players claim otherwise. Two parties are not agreeing on what really happened. Under the circumstances, you...

Sunday, January 6, 2008 | cricket | Read More

Aussies win as expected, but...

Aussies win as expected. But, that does not change my comments earlier. While Indian second inning batting is worst, the controversial umpiring decisions had definite effect on the match. While it may sound "sour grapes" now, ICC has to do everything to improve umpiring. And Steve Bucknor has to go!

Saturday, January 5, 2008 | cricket | Read More

Aussies can win any match....

Observations based on the second test:Aussies lost 6 wickets fairly quickly in the first inning. It could have been easily 200 all out. But, one player [Symonds] gets multiple lives! He goes as not out. So long as Steve Bucknor officiates matches India has no chance. He does not ask for third umpire at times when Indian team needs most. Even the third umpire seems to "get it wrong" [what was he doing other than watching TV?] Umpire (Mark Benson) asks the Aussie fielder to check...

Saturday, January 5, 2008 | cricket | Read More

blu-ray.. blu-ray...

I am thrilled to know this news!! And that is not without a bit of self-interest. I work on some blu-ray related activities @ Sun (more on that in future!). BTW, if you are interested in learning about blu-ray and related Java programming platform called BD-J, you may consider the following: Buy a copy of the nice book Programming HD DVD and Blu-ray Disc. Check out the code from the project http://hdcookbook.dev.java.net Buy a laptop with blu-ray disc drive. This will come with...

Friday, January 4, 2008 | Java | Read More

Latest on the Scripting project

Updates on the Scripting project. Updated JavaScript script engine with Rhino version 1.6R7. This version supports E4X without requiring XMLBeans. Updated Groovy script engine to use version 1.5.1. Updated Jython script engine to use version 2.2.1. Updated Freemarker script engine to use version 2.3.11. Yoko Harada is planning to update JRuby script engine with version 1.1x.

Thursday, January 3, 2008 | Java | Read More

13 players in a 11 player sport?

13 players in a 11 player sport? And "that's cricket"??

Wednesday, January 2, 2008 | cricket | Read More

What's new with Scripting for the Java platform?

Sorry about the looo..ng hibernation! Now, it is time for updates on the Scripting project. Yoko Harada updated JRuby script engine with JRuby 1.0.2 and added few other fixes in engine code. I've pre-built binaries of the project (uploaded the .zip and .tar.gz files) Three new jsr-223 compliant script engines: JavaFX Script interpreter had jsr-223 support. Now, the JavaFX Script compiler has jsr-223 support -- you may want to checkout JavaFX Script compiler project. The...

Sunday, November 11, 2007 | Java | Read More

javac's hidden options...

Sorry about not writing much these days. Hoping to blog again... Earlier, I blogged about javac's hidden option "-printflat". I modified javac source to "open up" the hidden "-printflat" flag. Well, it turns out that you don't need to do that!! As per javac source docs, there are 4 kinds of options: standard public options, e.g. -classpath extended public options, beginning -X, e.g. -Xlint hidden options -- not public or documented, e.g. -fullversion even more hidden options --...

Monday, September 10, 2007 | Java | Read More

ANTLRWorks and fun with grammars

If you are a programming languages enthusiast, you'll probably like this. I downloaded ANTLR Parser Generator. In addition to ANTLR, I downloaded the following: ANTLRWorks - a grammar development environment for ANTLRv3. Java 1.5 ANTLR Grammar It is fun to navigate/debug/view grammars and parse trees. Parse tree of a simple Java class looks as follows:

Monday, July 30, 2007 | Java | Read More

If you don't live in Chennai, please skip this post...

I've been receiving many "wrong" calls these days. Apparently, there is a hospital with a telephone number starting with "2664". And my telephone number starts with "2446" and the rest of the digits are same! Looks like folks get confused and dial "44" instead of "66". I end up receiving calls to "Dr. XYZ" at odd times!! Now, I understand what doctors have to go though in their life. Our after working hour conference calls are lot better - at least our US friends understand...

Friday, July 27, 2007 | General | Read More

Week-end fun with the java compiler source code

I downloaded java compiler (javac) source code from the JDK 7 site. I did not download entire JDK – I just downloaded compiler-7-ea-src-b15-05_jul_2007.zip I've installed JDK 6 and NetBeans 5.0 I extracted the source zip file into c:\\javac directory. From NetBeans IDE, File->Open Project menu, I chose c:\\javac\\compiler directory. Then, I build the project – I scrolled the build output log to the end and I saw: Building jar: C:\\javac\\compiler\\dist\\lib\\javac.jar build-bin.javac...

Saturday, July 14, 2007 | Java | Read More

Hacking serviceability code in hotspot JVM

Jim Holmlund (blog?) compiled this very nice summary of serviceability related code in hotspot JVM -- http://openjdk.java.net/groups/serviceability/.

Thursday, July 12, 2007 | Java | Read More

Do you XYZ @ Sun Microsystems?

One of the frequently asked questions to me is this: "do you know one Mr/Mrs/Ms/Dr XYZ at Sun Microsystems?". Invariably, I don't seem to know the person mentioned :-) I tend to explain that Sun is a big company and it is not possible to know each and every engineer/manager/support staff and so on. And full time work-from-home does not help either - one gets even less chance to meet people :-) I've to wait till next JavaOne/Sun Tech Days or some other event to meet my...

Sunday, July 8, 2007 | General | Read More

JavaScript, JSON and JavaFX Script

JavaFX Script, as you may know already, is a declarative and statically typed scripting language. It has first-class functions, declarative syntax, list-comprehensions, and incremental dependency-based evaluation. JavaFX Script syntax includes object literals - a declarative syntax to construct objects. If you knowJavaScript, you may know about JavaScript Object Literals and it's subset called JSON - which is a lightweight data-interchange format (considered to be analternativ...

Sunday, June 24, 2007 | Java | Read More

Learning couple of more SCMs!

There are many Software Configuration Management (SCM) systems also called Revision Control Systems and trillion other names :-) .... Being a Sun employee, I've been using Teamware ever since I joined Sun. During the development of JDK 6, I became involved in integrating JSR-223 reference implementation (RI) code into JDK 6 (javax.script package and Rhino based JavaScript engine). During this effort, I had to learn CVS - because the RI code was kept in CVS repository. In a...

Sunday, June 17, 2007 | General | Read More

JRuby 1.0 released, jsr-223 engine updated!

JRuby 1.0 has been released. The jsr-223 script engine for JRuby had an issue because of a recent change in JRuby parse API during 1.0.0RC3. Thanks to the java.net user "bongobongo" for reporting this issue along with the patch. I've included this fix and regenerated binaries and changed the engine to use JRuby 1.0 version -- as usual, you can find the sources and binaries at @ scripting.dev.java.net

Sunday, June 10, 2007 | Java | Read More

Scripting updates...

It has been a while. I've not updated on scripting.dev.java.net project and related activities. Here it is ... Updated the jsr-223 engine for JRuby to use JRuby version 1.0.0RC2. A recent issue with Pnuts script engine was fixed by Tomatsu. Added a link to JavaFX Script You probably know this already, but just in case you missed: JavaFX Script has jsr-223 script engine for it (included in javafxrt.jar). See also: Programmatically invoking JavaFX Script JavaFX: First Steps -...

Thursday, May 31, 2007 | Java | Read More

A project idea for OpenJDK...

You probably checked out the OpenJDK project and even built it on your favorite platform. And you are wondering how can you do a small, but interesting project with OpenJDK. In Nov 2006, I mentioned about HotSpot Serviceability Agent (SA) which is a set of APIs and tools for debugging HotSpot Virtual Machine processes and core dumps. You may want to look at HotSpot Serviceability page and HotSpot SA sources in the hotspot/agent/ directory and the subdirectories. One of the...

Friday, May 25, 2007 | Java | Read More

Troubleshooting BOF (JavaOne 2007) slides

We received few comments/emails asking for the slides of troubleshooting tools BOF (JavaOne 2007). Alan Bateman has uploaded the slides (PDF) of the troubleshooting tools BOF.

Tuesday, May 22, 2007 | Java | Read More

Programmatically dumping heap from Java applications

In the troubleshooting BOF, we demonstrated how to use the jmap -dump option to dump heap dump of a running application and showed how to browse/analyze the resulting binary heap dump using the jhat tool. One of the questions was how to programmatically dump the heap from applications. For example, you may want to dump multiple heap snapshots from your application at various points in time and analyze those off line using jhat. Yes, you can dump heap from your application --...

Tuesday, May 15, 2007 | Java | Read More

JavaOne'07 -- my summay.

After 19 hours of flight, I finally reached Chennai from SFO (on Sunday morning). I'm still going through the timezone change. I wish for a "Star Trek" like transport :-) This JavaOne turned to be a "device" JavaOne for me -- I attended talks on SunSPOT, Java ME, Blu-ray, OCAP etc. In some sense, it is device JavaOne anyway -- after all one of the big announcements is about JavaFX mobile. I wanted to attend, but missed the talk on "x86 (JPC?) Java emulator". Random bits from...

Monday, May 14, 2007 | Java | Read More

JavaOne'07 Thur (May 10)

I attended only two sessions: TV sessions kick off -- introducing to many Java TV related technologies. One problem with the TV domain is that there are loo...ots of acronyms! One feels lost in the words ... For example, GEM stands for "Globally Executable MHP" and "MHP" stands for Multimedia Home Platform and so on. Add to that the telecommunication/MPEG related jargons. You may want to check out a few sitesthat I find interesting. Sumit Malik (of Sony) showed...

Friday, May 11, 2007 | Java | Read More

JavaOne'07 Wed (May 9)

I attended the following sessions/BOFs (in no specific order): Building PhoneME project and applications on it. The speakers (Stuart Marks and Hinkmond Wong) demonstrated how to SVN checkout, build the platform - both Phone ME feature (CLDC) and Phone ME advanced (CDC). A sample protocol handler (called "upcase" protocol) was added to the platform and the platform was built. Also, the speakers showed how to build CLDC/CDC apps using NetBeans IDE. Stuart Marks made the IDE to...

Thursday, May 10, 2007 | Java | Read More

JavaOne'07 Tuesday (May 8)

Here is what I did on the first day of JavaOne 2007. I attended the keynote session - main messages are: "JavaFX script" language - a dynamic, statically typed language for GUI/Java2D/Swing type applications (can be used for general purpose as well). It was formerly called F3. In future, there will be an authoring tool that emits JavaFX script. JavaFX/Mobile - complete software platform for mobible - sort of like "Java OS" for mobile phones. You have Java SE, yes - you read it...

Wednesday, May 9, 2007 | Java | Read More

Meet you at BOF - 2816 JavaOne 2007

As usual, there is troubleshooting BOF this year as well (2816 - Tuesday 8.00 PM). Alan Bateman, Mandy Chung and yours truely will present. Meet you all there!

Thursday, May 3, 2007 | Java | Read More

Desktop scripting applications with NetBeans 5.5

How about developing desktop Java applications using scripting, XML and database with NetBeans? This afternoon I played with scripting using NetBeans 5.5. Before proceeding further, I will describe the devepment environment: JDK 6 NetBeans 5.5 with NetBeans Enterprise Pack NetBeans Scripting plugins from the Phobos project For desktop apps, you probably need only the NetBeans JavaScript Editor. But, it does not hurt to have everything :-) In addition, I've CVS checked out the...

Wednesday, April 18, 2007 | Java | Read More

SML subset for TEDI?

I came across "Do we need a new kind of schema language?" from Tim Bray's blog. After reading it, I can't resist this: why not use a subset of Standard ML for this purpose? Basic types - SML has int, real, bool, char, string Tuples - SML has t1\*t2\*t3... (for example, int\*bool, int\*string\*real and so on) Lists - 'a list - int list, string list and so on Records - {name1:t1, name2:t2 } (for example, {name:string, age:int}) type for type abbreviations - useful when...

Tuesday, April 10, 2007 | Java | Read More

Retrieving .class files from a Java core dump

In my last blog entry, I explained how to retrieve .class files from a running Java application. How about retrieving .class files from a Java core dump? You may have got a core dump from JVM due to a bug in some JNI code [you may want to run your application with the -Xcheck:jni flag during development] a bug in JVM. You got core dump and hs_err_pid<NNN> file [which you can decode online!] or you may have forced core dump by a tool such as gcore When you debug native core...

Monday, April 2, 2007 | Java | Read More

Retrieving .class files from a running app

Many Java applications generate .class files on-the-fly at runtime. Some applications modify loaded Java classes either at class load time or even later using hotswap. Few examples: Scripting language implementations that generate .class files - like BeanShell, Groovy OR mapping tools such as Toplink Essentials Compilation of XSL stylesheets to .classes (assuming compilation is done at runtime rather than at build). Profilers that use byte code instrumentation technique - like Ne...

Friday, March 30, 2007 | Java | Read More

Script Beans - part 2

This is continuation of my earlier post onscript beans. On rethinking, I've made few (minor) changes to ScriptObject and Callable. The changes are: Using varargs instead of Object[] arguments in few places. Added invoke method in ScriptObject -- this is used to directly invoke a method on a script object instead of getting a method/function valued property using get and then invoking Callable.call method. Why? Many dynamically typed languages have Smalltalk's doesNotUnderstande...

Saturday, March 24, 2007 | Java | Read More

Half empty or half full?

As expected (especially after loosing to Bangladesh), loosing to Sri Lanka followed! Here is my "half full" perspective: Cola companies would probably rethink about their strategy - ads. showing cricketers morphing to tigers?. Good joke! Cricket (for that matter most sports) is for youngsters. If a team member is 30+, he should probably retire - unless if he is a super performer today! - past glory (?) is immaterial. I hope there will be some pressure at home. TV channels...

Friday, March 23, 2007 | cricket | Read More

Script Beans?

When we expose Java objects (or other language objects!) to a scripting language, we may want flexibility. Most scripting languages on the Java platform support JavaBean conventions. For example, JavaScript allows property style access for "getXXX" methods. Some language engines (for example, Groovy) treat java.util.Map's specially to provide map.key_name style access. But, we may want more flexiblity in addition to bean conventions. For example, we may want java.sql.ResultSet...

Wednesday, March 21, 2007 | Java | Read More

JVM Talks...

Recently, I gave a series 4 talks (consecutive saturdays about 2 to 2.5 hours) at CS department of Anna University on Java Virtual Machine. The aim was to give understanding JVM at specification level and not much on any specific implementation of it. I did not create slides on my own. Also, I didn't stick only to slides - I did mostly marker-pen-and-board as well. Initial reading to introduce the concept of virtual machines: First chapter of Virtual Machines: Versatile...

Monday, March 19, 2007 | Java | Read More

Who are "minnows" here?

Yesterday Bangladesh defeated India and Ireland defeated Pakistan. Who are "minnows" here? At least Pakistan had some reasons - they don't have two of their strike bowlers and also miss their star all rounder batsman (although 132 all out would still be questionable). But about Indian team? - rubbish!

Saturday, March 17, 2007 | cricket | Read More

Update Velocity jsr-223 engine to use version 1.5

Came to know from Erik's Linkblog about the new release of Velocity. Updated jsr-223 script engine for Velocity @ scripting.dev.java.net to use Velocity 1.5.

Friday, March 16, 2007 | Java | Read More

blog worth meme...

My blog is worth $30,485.16. How much is your blog worth? I do agree with Melanie Parsons Gao. I too leave my blog link in blog comments that I make! But, like Kevin, I'd love to know how to cash this ;-)

Thursday, March 8, 2007 | General | Read More

(mis)understaning Scala's singleton types?

I've been reading/playing with Scala. Scala has the concept of "singleton types". If types are considered as sets, singleton types are sets with only one object. A singleton type is expressed in Scala using object.type. To refer to the singleton type the expression for object has to be "stable". Informally, this means the expression that denotes the object should evaluate to the "same object reference" every time it is evaluated. A simple Scala interactive session to...

Thursday, March 8, 2007 | Java | Read More

Updated JRuby jsr-223 engine with 0.9.8 and fixed a bug

JRuby 0.9.8 has been released recently. Updated jsr-223 script engine for JRuby @ scripting.dev.java.net to make use of this latest version. Also, fixed a bug in JRuby ScriptEngineFactory's getMethodCallSyntax method. Previously, this method generated code that could not be evaluated. That was because the factory was not generating "$" prefix for Ruby object and arguments. This bug has been fixed.

Tuesday, March 6, 2007 | Java | Read More

Scala for Java programmers - Part 2

This is continuation of my last blog entry titled Scala for Java programmers. Feature Java Scala Application Any Java class with public static void main(String[]) method can be run as an application. public class Hello {public static void main(String[] args) { System.out.println("hello world"); }} Any object with def main(args: Array[String]) : unit method can be run as an application. [Note: Scala does not have static members - you have to use singleton objects.] object...

Monday, March 5, 2007 | Java | Read More

Scala for Java programmers

There are many languages that target to the Java Virtual Machine (JVM) -- not just the scripting and dynamically typed ones. How about learning another statically typed language that is compiled JVM and seamlessly integrates to the Java platform? The latest mantra is "One Great VM, Many Languages", Right? :-) We will look at - Scala? - a functional, object-oriented and concurrent language that runs on the Java platform. Note:this is not a language comparison exercise [i.e., X...

Sunday, March 4, 2007 | Java | Read More

Updated JSR-223 engine for Scheme

From "Script_on_Java", I came to know about new release (1.16.6) of SISC - Java based interpreter for Scheme. I updated the JSR-223 engine for Scheme @ scripting.dev.java.net to use SISC version 1.16.6.

Tuesday, February 27, 2007 | Java | Read More

Sun Tech Days Hyderabad 2007 - trip report and slides

As I mentioned earlier, I spoke at Sun Tech Days 2007. About 10000 folks attended Sun Tech Days. Approximately about 2000 folks attended each talk (at least in the ones in the "main" room where key notes talks were given). Very nice to see so many developers at one place! I think over the years, Sun Tech Days is growing to become like JavaOne. Kannan and I traveled from Chennai to Hyderabad to attend this event. This year I gave two talks. In the talk titled "Java SE...

Monday, February 26, 2007 | Java | Read More

JSR-223 variable access in Scheme, Tcl and F3

jsr-223 defines scripting API for the Java platform -- so that Java programs can execute scripts written in various scripting languages. As you'd probably know already, JDK 6 includes javax.script API and JavaScript engine in it. One of the facilities of javax.script API is script Bindings. Through the javax.script.Bindings interface, you can expose your application objects as global variables to your scripts. Ideally, you want to access global variables by the same name as...

Sunday, February 25, 2007 | Java | Read More

Meet you at Sun Tech Days, Hyderabad (Feb 21-23)

Have you registered for Sun Tech Days - Hyderabad - Feb 21-23? Meet you at Hyderabad....

Thursday, February 15, 2007 | Java | Read More

Updated Jython jsr-223 engine with Jython 2.2b1

Jython 2.2 beta1 has been released recently. I updated jsr-223 script engine for Jython @ scripting.dev.java.net to use Jython 2.2 beta1 version.

Monday, February 12, 2007 | Java | Read More

Programming by Scratch!

No, this is not about scratching head when your manager asks for status :-) I'm talking about the M.I.T Scratch programming language which is based on Squeak. I just downloaded Windows version and played with it for sometime. My son played with it too! They have a very nice Getting Started Guide!

Monday, February 12, 2007 | General | Read More

jhat's JavaScript interface

In one of the recent e-mails, Frank Kieviet suggested an improvement for jhat tool in JDK 6. He said something like: Sundar: another idea to extend jhat: when looking at a memory dump and looking at the routes to a particular classloader, there are sometimes hundreds of references. [...] jhat could print some histogram data so that it’s immediately apparent which object reference is suspect. The above could be generalized to any Java object (not just a classloader object)....

Wednesday, January 24, 2007 | Java | Read More