Andy Reitz (blog)

 

 

JavaOne: BOF-9335: Scalable Languages: The Future of BeanShell and Java-Compatible Scripting Languages

Doing JSR for BeanShell, to make it standardized, and potentially part of Java proper (someday). Will give more visibility and participation. BeanShell being developed by small team, so this will expand resources. New in 2.0:
  • Full java syntax compatability
  • performance: JavaCC 3.0 parser faster and smaller; caching of method resolution gives boost
  • better error reporting
  • Applet friendly (again) -- doesn't trip applet security; advantage of existing reflection-based implementation (do things w/o code generation)
  • new features: mix-ins, properties style auto-allocation of variables (can use BeanShell as more advanced java properties file)
  • Mix-ins: import java object into BeanShell namespace.
Java Syntax Compatibility
  • Full java 1.4 syntax support (on all VMs)
  • Some Java 5 features (all VMs): Boxing, enhanced for loop, static imports
  • Core Reflection doesn't allow introspection into core types -- added this in BeanShell 2.0
True Scripted Classes
  • Generated classes with real Java types, backed by scripts in the interpreter.
  • Scripts can now go anywhere Java goes.
  • Expose all methods and typed variables of the class.
  • Bound in the namespace in which they are declared.
  • May freely mix loose / script syntax with full Java class syntax.
  • Full java syntax on classes -- this, super, static, instance variables, and blocks. (no way to access superclass from reflection API)
  • Full constructor functionality.
Limitations:
  • Reflective access permissions (knocks out applets for the scripted classes)
  • bugs
New APIs:
  • javax.script (JSR-223) - will be a part of Java 6, powerful API for calling scripting languages from Java
  • BeanShell API compiler - have persistent classes backed by scripts.
Compiled API classes are like python -- you can take a .bsh script, and compile it into a .class file. Then it can be used by native Java code. Will it be like Python, in that if you modify the .bsh, it will automatically re-make the .class? I asked about this, and I found that this is sortof different from what Python is doing. Basically, the .class file only includes a stub, that wraps around the functionality that is implemented in the .bsh file. This stub allows the Java code to invoke the functionality of the .bsh file. Behind-the-scenes, BeahShell will launch a separate JVM for each .class file. This separate JVM will execute the code in the .bsh file.

New BeanShell community site, includes Wiki (J2EEWiki). Wiki site is beanshell.ikayzo.org/docs. Subversion for source control.