You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Steve Loughran <st...@iseran.com> on 2000/09/09 01:59:56 UTC

Executing java via ExecuteJava raising an IllegalAccessError?

I've been wrapping someone else's code up in ExecuteJava because a) they
foolishly used System.exit() wherever they could and b) I need to adjust the
classpath.

Although I can load and invoke their main() method fine, I get IllegalAccess
errors on the package scop methods they invoke on other classes in the same
package.

Has anyone else encountered this little problem and any suggestions to a
workaround?

    -Steve




Re: System.exit() [was Re: Executing java via ExecuteJava raising an IllegalAccessError?]

Posted by David Medinets <me...@mtolive.com>.
thanks for confirming my understanding. I plan to create some Ant tasks that
can analyze ColdFusion templates and generate documentation (like javadoc
does for java). And I'd like to learn some organization techniques and
coding techniques from the Ant project.

----- Original Message -----
From: "David Walend" <dw...@eecs.tufts.edu>


> I'll pick this up, but don't want to start a religious war. What follows
> is high-level foofy design stuff, and there really are some situations
> when you want to call System.exit().



System.exit() [was Re: Executing java via ExecuteJava raising an IllegalAccessError?]

Posted by David Walend <dw...@eecs.tufts.edu>.
I'll pick this up, but don't want to start a religious war. What follows
is high-level foofy design stuff, and there really are some situations
when you want to call System.exit(). 

On Sat, 9 Sep 2000, David Medinets wrote:

> Hi. Why is using System.exit() foolish? 

If the code containing System.exit() is always stand-alone, it's not
foolish. If someone tries to call that code from inside their own, then
the System.exit() can end the java process too soon.

For example, weblogic's ejbc calls System.exit(). (Or at least it used
to.) That works fine, as long as I called ejbc by hand. When I tried to
write some code to use ejbc and then do something else, the code didn't
work; ejbc exited and my own code never ran.

> What should be used instead? 

If nothing is wrong, then return; is a good option. (I've seen some
complex code that returns an int indicating {done|not done}.
System.exit() does this for the shell.)

If something is horribly wrong, throw a subclass of RuntimeException that
says what's going on as clearly as possible.

> Are you
> referring to thinging like handling unrecoverable exceptions that should be
> thrown up the chain or to exceptions like files not being found that could
> be handled directly?

Both I suppose. I've discovered that code I've never expected anyone to  
use leaks out from my hard drive as library code. Avoiding System.exit()
saves me lots of support work and refactoring.

Hope that helps. If it pisses someone off, sorry.

Dave



Re: Executing java via ExecuteJava raising an IllegalAccessError?

Posted by David Medinets <me...@mtolive.com>.
Hi. Why is using System.exit() foolish? What should be used instead? Are you
referring to thinging like handling unrecoverable exceptions that should be
thrown up the chain or to exceptions like files not being found that could
be handled directly?

----- Original Message -----
From: "David Walend" <dw...@eecs.tufts.edu>
To: "ant" <an...@jakarta.apache.org>
Sent: Saturday, September 09, 2000 11:13 AM
Subject: Re: Executing java via ExecuteJava raising an IllegalAccessError?


> On Fri, 8 Sep 2000, Steve Loughran wrote:
>
> > I've been wrapping someone else's code up in ExecuteJava because a) they
> > foolishly used System.exit() wherever they could and b) I need to adjust
the
> > classpath.
> >
> > Although I can load and invoke their main() method fine, I get
IllegalAccess
> > errors on the package scop methods they invoke on other classes in the
same
> > package.
> >
> > Has anyone else encountered this little problem and any suggestions to a
> > workaround?
>
> Steve,
>
> I haven't tried this from inside ant yet, and haven't hit this specific
> problem before but...
>
> I've gotten around other people's calling System.exit() by using a
> security policy that won't let them do it. Then, the security exception
> bubbles politely out of their code to some point where I can catch it. Not
> really in the theme of the java security kit, but is a nice hack.
>
> Hope that helps,
>
> Dave
>


Re: Executing java via ExecuteJava raising an IllegalAccessError?

Posted by David Walend <dw...@eecs.tufts.edu>.
On Fri, 8 Sep 2000, Steve Loughran wrote:

> I've been wrapping someone else's code up in ExecuteJava because a) they
> foolishly used System.exit() wherever they could and b) I need to adjust the
> classpath.
> 
> Although I can load and invoke their main() method fine, I get IllegalAccess
> errors on the package scop methods they invoke on other classes in the same
> package.
> 
> Has anyone else encountered this little problem and any suggestions to a
> workaround?

Steve,

I haven't tried this from inside ant yet, and haven't hit this specific
problem before but...

I've gotten around other people's calling System.exit() by using a
security policy that won't let them do it. Then, the security exception
bubbles politely out of their code to some point where I can catch it. Not
really in the theme of the java security kit, but is a nice hack.

Hope that helps,

Dave