[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Wrong exception thrown in AccessContoller
From: |
Nicolas Geoffray |
Subject: |
Wrong exception thrown in AccessContoller |
Date: |
Wed, 14 Sep 2005 11:51:14 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.6 (X11/20050913) |
Hello everyone,
In java.security.AccessController
doPrivileged(PrivilegedExceptionAction) and
doPrivileged(PrivilegedExceptionAction, AccessControlContext) are
supposed to wrap all checked exceptions thrown in a
PrivilegedActionException object. By "checked" it means all exceptions
but RuntimeException. The implementation of
the two methods in gnu classpath treats non checked exceptions as
checked exceptions, which is not a correct behaviour.
I attached a patch (it's patched against 0.13, but it's ok for 0.18) and
a java program which execution is different between sun and gnu classpath.
Cheers,
Nicolas
import java.security.*;
public class Access{
public static void main(String [] args){
try {
String s = (String) AccessController.doPrivileged(
new PrivilegedExceptionAction() {
public Object run(){
Object o = null;
return o.toString();
}
});
} catch (PrivilegedActionException e) {
System.out.println(e);
}
}
}
*** classpath-0.13/java/security/AccessController.java Fri Jan 7 00:32:28 2005
--- classpath-0.13-jnjvm/java/security/AccessController.java Mon Jun 20
14:56:44 2005
***************
*** 153,158 ****
--- 153,162 ----
{
return action.run();
}
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
catch (Exception e)
{
throw new PrivilegedActionException(e);
***************
*** 190,195 ****
--- 194,203 ----
{
return action.run();
}
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
catch (Exception e)
{
throw new PrivilegedActionException(e);
- Wrong exception thrown in AccessContoller,
Nicolas Geoffray <=