You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Tim Ellison <t....@gmail.com> on 2010/07/20 13:13:33 UTC

[classlib][luni]SecurityManager.checkExit(status) function fails to check for various status values (HARMONY-6593)

This seems to be an interesting difference between Java 5 and Java 6
behavior in the RI...

    Permission p1 = new RuntimePermission("exitVM");
    Permission p2 = new RuntimePermission("exitVM.0");

    p1.implies(p2);

this 'implies' is false on Java 5, but true on Java 6


    Permission p3 = new RuntimePermission("exitVM.*");
    Permission p4 = new RuntimePermission("exitVM");

    p3.implies(p4);

this is also false on Java 5, and true on Java 6.

I can see the logic for the changes in Java 6, which is the behavior I
would expect from a basic permission.  However, to retain compatibility
with the RI I'm inclined to match the difference and put different code
into our Java 5 and Java 6 streams.

I wonder how many apps fix their policy file when moving from Java 5 to
Java 6 8-0

Regards,
Tim


On 20/Jul/2010 09:41, Tim Ellison (JIRA) wrote:
>     [ https://issues.apache.org/jira/browse/HARMONY-6593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12890216#action_12890216 ] 
> 
> Tim Ellison commented on HARMONY-6593:
> --------------------------------------
> 
> This causes another test to fail:
> 
> This should throw a SecurityException.
> 
> junit.framework.AssertionFailedError: This should throw a SecurityException.
> at org.apache.harmony.luni.tests.java.lang.SecurityManagerTest.test_checkExit_int(SecurityManagerTest.java:288)
> at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:197)
> 
> 
> I'll take a look too.
> 
> 
>> [classlib][luni]SecurityManager.checkExit(status) function fails to check for various status values
>> ---------------------------------------------------------------------------------------------------
>>
>>                 Key: HARMONY-6593
>>                 URL: https://issues.apache.org/jira/browse/HARMONY-6593
>>             Project: Harmony
>>          Issue Type: Bug
>>          Components: Classlib
>>    Affects Versions: 5.0M13
>>         Environment: Windows and Linux
>>            Reporter: Mohanraj Loganathan
>>            Assignee: Tim Ellison
>>         Attachments: securityManager_exitV_001.diff
>>
>>
>> Consider the testcase below[1]. Harmony throws unknown permission 
>> But with RI the same test passes. 
>> As per API doc, checkExit should be able to check VM exit status. 
>> [1] testcase: 
>>     public void test_checkExit_int1() {
>>         SecurityManager mySecMngr = new SecurityManager(){
>>             public void checkPermission(Permission permission) {
>>                 if (!permission.equals(new RuntimePermission("exitVM.1") )) {
>>                     throw new SecurityException("unknown permission");
>>                 }
>>             }
>>         };
>>         mySecMngr.checkExit(1);
>>         try {
>>             mySecMngr.checkExit(2);
>>             fail("Should throw SecurityException");
>>         } catch (SecurityException se) {
>>             // expected
>>         }
>>     }
>