« July 2006 »
SunMonTueWedThuFriSat
      
1
2
5
7
8
9
10
11
13
14
16
19
20
21
23
24
25
26
29
30
     
Today
XML

Blog::Navigation

GetJava Download Button
Get the Source
Personal Blog

Blog::Referers

Today's Page Hits: 762

Powered by Roller Weblogger.
« Previous day (Jul 13, 2006) | Main | Next day (Jul 15, 2006) »
20060715 Saturday July 15, 2006

Recent changes in JSR-223

As you may know already, Mustang (Java SE 6) includes JSR-223: Scripting for the Java Platform API. There was a recent change (since Mustang build 91) in javax.script.Invocable interface. Previously, there were two invoke methods in this interface - one for calling script top-level or global functions from Java and another for calling methods on script object. These have been renamed to invokeFunction and invokeMethod respectively.

javax.script.Invocable interface used to have the following methods:

    // call script global function
    invoke(String name, Object...args)
    // call method on a script object
    invoke(Object this, String name, Object...args)

This results in a problem when invoking a function with String arguments. For example, the following call

    Object ret = engine.invoke("functionName", "arg1", "arg2", "arg3");

is ambiguous. javac cannot tell which invoke overload is being called. User gets an error that looks like:

    reference to invoke is ambiguous, both method invoke(java.lang.Object, 
java.lang.String,java.lang.Object...) in javax.script.Invocable and method 
invoke(java.lang.String,java.lang.Object...) in javax.script.Invocable match

Now, these methods have been renamed to

    // call a script global function
    invokeFunction(String name, Object...args)
    // call a method on a script object
    invokeMethod(Object this, String name, Object...args)

The JavaScript engine (co-bundled in Sun's Java SE 6 implementation) and the script engines maintained at http://scripting.dev.java.net have been fixed to track this interface change. If you are maintaining/implementing your own JSR-223 engine, please fix it for this change.

In addition to this, scripting.dev.java.net project has been updated to use
  1. Groovy version 1.6 JSR-06
  2. JRuby version 0.9.0
  3. to track recent changes with JSR-199 (Java compiler API) [for Java script engine]

If you are using http://phobos.dev.java.net, you may want to refer to Roberto Chinnici's blog entry titled Tracking JSR-223 Changes



( Jul 15 2006, 08:33:28 AM IST ) Permalink del.icio.us | furl | simpy | slashdot | technorati | digg

Copyright (C) 2005, A. Sundararajan's Weblog