cbuschka / beanshell2

Automatically exported from code.google.com/p/beanshell2
0 stars 0 forks source link

Beanshell really slow in applets, tries to load classes remotely #34

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Write an applet that uses beanshell scripts, I think nothing really 
complicated is needed to trigger this issue.
2. Watch how the applet slows to a crawl.

What is the expected output? What do you see instead?

Something that runs in one second in the local machine can take minutes on 
a slow connection.

The reason seems to be that the applet tag puts the codebase into the 
classpath, and BeanShell looks there first in its Class.forName(...) and 
similar calls. This doesn't seem to make much sense, as it should at the 
very least look in the local jars first.

I have stumbled into this issue now but it is better documented in the old 
beanshell list, there are several threads reporting it:

http://osdir.com/ml/java.beanshell.user/2005-04/msg00031.html
http://osdir.com/ml/java.beanshell.user/2005-03/msg00033.html
http://osdir.com/ml/java.beanshell.user/2005-11/msg00033.html

This is a real show-stopper for anyone wanting to use beanshell in 
applets. A fix in beanshell2 would be very nice.

Original issue reported on code.google.com by komoku on 26 Apr 2010 at 7:58

GoogleCodeExporter commented 9 years ago
It is pretty obvious, but just for completeness... in "What steps will 
reproduce the 
problem", I forgot to mention that you need to load the applet from a remote 
server 
to notice it. If you load it locally, it won't go to the network to find 
classes so 
it won't slow down.

Original comment by komoku on 26 Apr 2010 at 8:01

GoogleCodeExporter commented 9 years ago

Original comment by fschm...@gmail.com on 20 Feb 2011 at 10:12

GoogleCodeExporter commented 9 years ago
To simplify debugging: One could set a classloader instance for an interpreter 
instance. I passed a simple class loader which only logs the requested class 
and resource names.

It turned out that some 'silly' class names are requested. Beanshell is a 
scripting name without strong typing, so each 'name' which is no reachable 
variable name could be a class name (or the prefix of one). The only way to 
know is to ask the classloader. In case of applet this time is significant 
(http call).

I'll investigate further if there are any optimizations possible. E.g. i 
observed requests for class 'bsh' even if the executed script is empty *. Then 
there is the command handling. And in the stable 2.0b4 there were also the 
requests for corresponding ".java" files (see issue 17 'classloader attempts to 
load java files').

* Footnote: Caused by "getu("bsh")" in constructor of Interpreter.

Original comment by pejob...@gmail.com on 20 Feb 2011 at 11:54