Pat Niemeyer has released a beta version of BeanShell 2.0. This release shows that BeanShell is now fully compatible with Java.
It can now read in ordinary .java files and BeanShell scripted classes are fully typed and appear to Java as ordinary classes.
The new version also includes static imports:
static import java.lang.Math.*;
sqrt(4.0);
and mix-ins. You can import the methods and fields of a Java object instance into a BeanShell namespace:
Map map = new HashMap();
importObject( map );
put("foo", "bar");
print( get("foo") ); // "bar"
Previous limitations on the implementation of anonymous inner classes have also been lifted, allowing BeanShell to extend arbitrary Java classes and implement abstract base classes.
Read the BeanShell 2.0 Announcement
Visit the BeanShell Home Page
-
BeanShell 2.0: A Fully Java Compatible Scripting Language (13 messages)
- Posted by: Dion Almaer
- Posted on: September 02 2003 09:56 EDT
Threaded Messages (13)
- Must be a Java Web Start application ! by Franck Arnulfo on September 02 2003 13:02 EDT
- BeanShell security by maxim kramarenko on September 02 2003 16:19 EDT
- Secure Beanshell by Steven Pearson on September 02 2003 17:43 EDT
- Bravo! by Brian Miller on September 02 2003 18:56 EDT
- Feedback regarding Judoscript by SUDIP BHATTACHARYA on September 03 2003 01:01 EDT
- Performance by Luke S on September 03 2003 05:04 EDT
- Another... by joost de vries on September 03 2003 06:28 EDT
-
Application Customization /Extension Patterns ? by Manish Sharan on September 03 2003 03:30 EDT
- Application Customization /Extension Patterns ? by josef betancourt on September 03 2003 07:12 EDT
- BeanShell vs. DynamicJava... by Patrick Niemeyer on September 05 2003 05:15 EDT
-
Application Customization /Extension Patterns ? by Manish Sharan on September 03 2003 03:30 EDT
- Re: BeanShell performance.... by Patrick Niemeyer on September 05 2003 16:54 EDT
- Another... by joost de vries on September 03 2003 06:28 EDT
- BeanShell 2.0: A Fully Java Compatible Scripting Language by David Tinker on September 04 2003 00:39 EDT
- More Free Open Source Scripting Languages For Java by Gerald Bauer on September 04 2003 19:09 EDT
-
Must be a Java Web Start application ![ Go to top ]
- Posted by: Franck Arnulfo
- Posted on: September 02 2003 13:02 EDT
- in response to Dion Almaer
I'll really enjoy it if Pat could make a Java Web Start version of BeanShell on his web site ! -
BeanShell security[ Go to top ]
- Posted by: maxim kramarenko
- Posted on: September 02 2003 16:19 EDT
- in response to Dion Almaer
How I can restrict access to the internal program methods in BeanShell ? I think that this is important security requirement for many apps. -
Secure Beanshell[ Go to top ]
- Posted by: Steven Pearson
- Posted on: September 02 2003 17:43 EDT
- in response to maxim kramarenko
You can add permission checks that only allow code trusted code to make calls into you.
As long as beanshell isn't granted these permissions you should be ok.
This is pretty invasive but would apply equally to all scripting languages and dynamically loaded code.
I spent a few hours investigating this and I think that beanshell expects to have "AllPermission" or at least some pretty invasive permissions. It makes heavy use of reflection.
I think some changes may be necessary to make beanshell run in a hardened environment.
I investigated this and I think that beanshell needs a few doPrivilegeds() around the reflective code but still execute the reflective calls in the non-privileged context.
bean shell consoles then need to be opened in a non privileged access control context and all should be well. -
Bravo![ Go to top ]
- Posted by: Brian Miller
- Posted on: September 02 2003 18:56 EDT
- in response to Dion Almaer
This is what JavaScript should have been all along. This is an immense windfall for the community. -
Feedback regarding Judoscript[ Go to top ]
- Posted by: SUDIP BHATTACHARYA
- Posted on: September 03 2003 01:01 EDT
- in response to Dion Almaer
Can someone give some feedback on Judoscript (http://www.judoscript.com) ? It is also a java based scripting langauge and has some high level features for doing JDBC and EJB stuff. -
Performance[ Go to top ]
- Posted by: Luke S
- Posted on: September 03 2003 05:04 EDT
- in response to Dion Almaer
Good news!
Does anybody know if the version 2 release features any performance improvements, I remember in this article BeanShell came out looking quite sluggish (http://www.javaworld.com/javaworld/jw-04-2002/jw-0405-scripts.html).
I would be interested in any users views on BeanShell performance in general and this new release in particular.
Cheers -
Another...[ Go to top ]
- Posted by: joost de vries
- Posted on: September 03 2003 06:28 EDT
- in response to Luke S
And there's Dynamicjava -
Application Customization /Extension Patterns ?[ Go to top ]
- Posted by: Manish Sharan
- Posted on: September 03 2003 15:30 EDT
- in response to joost de vries
While working for business application ISVs , I have always been intrigued by the possiblity of allowing the customer to modify the application and making it easier for them inject their specific logic into the application without them having to spend $$ for customization .
With technologies like Beanshell, DynamicJava and AspectJ, I can sense that this should be achievable ; can someone share some insight into using any of these for the purpose of application customization ? -
Application Customization /Extension Patterns ?[ Go to top ]
- Posted by: josef betancourt
- Posted on: September 03 2003 19:12 EDT
- in response to Manish Sharan
For specific tool customization, like editors, it sounds great. But, for business applications, seems difficult to do. One would have to really constrain the reach of the scripts or create a 'little language'. Scripts, unless they have safeguards like 'strict' modes, can be very brittle. Another, problem is that script languages have very powerful scripting syntax, and so can be harder to read and maintain than normal Java. This is one great advantage of BeanShell; it is Java with scripting freedom.
There are probably more robust approaches, like Business Rule Engines, MVC frameworks, and perhaps some web service 'Orchestration' tools that present an IDE. Of course, some applications can present a visual component that allows an ISV engineer to connect components and services.
OTOH, an application can have entry points that instead of invoking compiled components, can access a script library. Thus, supplying an easily changed library, even in the field, can be cool. The edit, compile, store, deploy, cycle seems very prehistoric. We should be at quasi-compiled(?) languages like Python, Perl, etc. There is plenty of cpu cycles and network bandwidth is going up with Internet2 and other develpments. Ooops! Got into a rant. -
BeanShell vs. DynamicJava...[ Go to top ]
- Posted by: Patrick Niemeyer
- Posted on: September 05 2003 17:15 EDT
- in response to joost de vries
Someone with more experience with DynamicJava will have to set me straight if I'm wrong, but after my quick look I see these differences:
1) BeanShell interpretes a superset of what DynamicJava can interpret - e.g. BeanShell (2.0) interprets standard Java source but also allows allows true loosely typed variables and method signatures, as well as method closures and other scripting language features.
2) BeanShell appears to be about half the size of DynamicJava (with even smaller subsets if you require less functionality).
3) Ironically, DynamicJava is less dynamic than BeanShell - I'd image because it generates bytecode for everything. DJ does not seem to support dynamically loaded commands or scripting language features such as the "eval()" method. BeanShell can create scripted objects and classes bound in the current scope at any time. It also has sophisticated scoping extensions such as "this.caller" that allows BeanShell command writers to write methods that have side effects in the caller's namespace.
4) DynamicJava is probably faster than BeanShell right now... again, just guessing because it generates bytecode.
5) Dynamic Java's full Java language support is probably more mature than BeanShell's interpreted classes which are only in beta-1 right now.
Pat Niemeyer
Author of BeanShell and the book Learning Java, O'Reilly & Associates -
Re: BeanShell performance....[ Go to top ]
- Posted by: Patrick Niemeyer
- Posted on: September 05 2003 16:54 EDT
- in response to Luke S
Certain aspects of BeanShell performance were improved significantly in version 1.3 a few months back. If invoking methods on Java classes is what you do most then BeanShell is about twice as fast as it was.
BeanShell is wide open for future performance improvements. Much of BeanShell's small size and simplicity is due to the fact that it relies almost entirely on the Java reflection API and does no bytecode generation (only the new class emulation in 2.0 requires bytecode generation). However there are several places where the architecure has been specifically designed to allow optimizations that are not yet in place. For example, resolving an ambiguous name (basically everything from a variable reference to a method call) in a namespace utilizes a name resolver abstraction that allows BeanShell to cache arbitrary information about the resolution so that it doesn't have to repeat it if the namespace hasn't changed (e.g. new variables or classes are added to the scope). This is 90% (just guessing) of what Beanshell does at runtime - aside from calling methods... (see above) - and we have hardly touched it yet.
I think there is a lot of potential for BeanShell to get very fast in the future.
Pat Niemeyer
Author of BeanShell and the book Learning Java, O'Reilly & Asssociates -
BeanShell 2.0: A Fully Java Compatible Scripting Language[ Go to top ]
- Posted by: David Tinker
- Posted on: September 04 2003 00:39 EDT
- in response to Dion Almaer
Hi All
We use BeanShell in the JDO Genie Workbench. Users can write and execute snippets of JDO code for cut and paste or data fixes or whatever. Adding this capability to an application is a huge feature and was very easy to do with BeanShell. Thanks guys!
Cheers
David
JDO Genie - www.jdogenie.com -
More Free Open Source Scripting Languages For Java[ Go to top ]
- Posted by: Gerald Bauer
- Posted on: September 04 2003 19:09 EDT
- in response to Dion Almaer
If anyone is interested over at the Viva! site I've put together a page listing the major free open-source scripting languages for Java (including Python, Ruby, Smalltalk, Scheme and more) @ http://viva.sourceforge.net/lang.html