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);
_______________________________________________
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath