Hi Ian.

Ian Rogers wrote:
> by default a JVM doesn't have a security manager. However, if we're
> executing applets in a web browser the browser would install a security
> manager to provide the "sandbox" security model. 

I have not looked in details at the code, but do you really need to do
the test on every invocation of this specific method?  Can't the test
for security manager be done once and for all earlier?  Then you can use
inheritance/delegation (or other standard design patterns) to delegate
the call to the appropriate method that will assume a "non-null" pointer
(or null).

I think that execution time of application versus applets shouldn't be
prioritized one over the other; so the exception mechanism is not a good
solution as it would favor one of the two, and slow down the other.

> Best practice is always subjective so it's hard to know the
> best way to deal with these situations within your JVM.

My comments on exceptions are NOT VM specific.  Exceptions should be
"exceptional".  From a VM designer point of view, the last thing to
optimize (in priority) is exceptions.

I would even expect exception execution time to hardly be measurable, as
the exception object has to store the stack trace, which can be of
varied length, and thus the simple creation of an exception object might
also trigger garbage collection, create additional garbage (and thus put
more pressure on the memory management system).  Unreliably measurable
exceptions mean unreliably measurable application execution time, etc...

Anyway, have fun!

Etienne
-- 
----------------------------------------------------------------------
Etienne M. Gagnon, M.Sc.                     e-mail: [EMAIL PROTECTED]
Author of SableVM:                             http://www.sablevm.org/
----------------------------------------------------------------------

Reply via email to