harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stepan Mishura (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-66) java.lang.SecurityManager.checkAccess(Thread t) throws NullPointerException for the dead thread.
Date Thu, 02 Feb 2006 08:19:07 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-66?page=comments#action_12364938 ] 

Stepan Mishura commented on HARMONY-66:
---------------------------------------

I've looked into added regression test case and I have the following comment:
The current test case will pass if the method checkAccess() returns silently or AccessControlException
is thrown. I think the test case should be stricter and pass only in one case. Otherwise the
test case may mask a bug in Harmony implementation.

In our case a security manager is not installed by default and the test case doesn't install
it too. As far as I understand the spec. the method checkPermission should not be invoked
so no AccessControlException is thrown. However Harmony implementation throws exception.


> java.lang.SecurityManager.checkAccess(Thread t) throws NullPointerException for the dead
thread.
> ------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-66
>          URL: http://issues.apache.org/jira/browse/HARMONY-66
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Elena Semukhina
>     Assignee: Tim Ellison
>     Priority: Minor

>
> java.lang.SecurityManager.checkAccess(Thread t) throws NullPointerException for the dead
thread.
> According to specification, the Thread.getThreadGroup() method returns null if this thread
has died.
> SecurityManager.checkAccess(Thread t) should take that into account.
> Code for reproducing:
> public class ThreadCheckAccess {
>     class ThreadRunning extends Thread {
>         volatile boolean stopWork = false;
>         int i = 0;
>         public void run () {
>             while (!stopWork) {
>             }
>         }
>     }
>     public void test() {
>         SecurityManager sm = new SecurityManager();
>         System.setSecurityManager(sm);
>         ThreadRunning t = new ThreadRunning();
>         t.start();
>         t.stopWork = true;
>         try {
>             t.join();
>         } catch (InterruptedException e) {
>             e.printStackTrace();          
>         }
>         try {
>             sm.checkAccess(t);
>             System.out.println("PASSED");
>         } catch (NullPointerException e) {
>             e.printStackTrace();
>             System.out.println("FAILED");
>         }
>     }
>     public static void main(String args[]) {
>         new ThreadCheckAccess().test();
>     }
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-31) j2se subset as described in README.txt.
> 2. Compile ThreadCheckAccess.java using BEA 1.4 javac 
> > javac -d . ThreadCheckAccess.java 
> 2. Run java using compatible VM (J9) 
> > java -showversion ThreadCheckAccess 
>   
> Output: 
> java version 1.4.2 (subset) 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.

> java.lang.NullPointerException
>         at java.lang.SecurityManager.checkAccess(SecurityManager.java:92)
>         at java.lang.Thread.checkAccess(Thread.java:423)
>         at ThreadCheckAccess.test(ThreadCheckAccess.java:23)
>         at ThreadCheckAccess.main(ThreadCheckAccess.java:32)
> FAILED
> Output on BEA 1.4.2: 
> PASSED
> Suggested junit test case: 
> package org.apache.harmony.tests.java.lang; 
> import junit.framework.TestCase; 
> public class SecurityManagerTest extends TestCase { 
>     class ThreadRunning extends Thread {
>         volatile boolean stopWork = false;
>         int i = 0;
>         public void run () {
>             while (!stopWork) {
>             }
>         }
>     }
>     public void test_checkAccessLjava_lang_Thread() { 
>         SecurityManager sm = new SecurityManager();
>         System.setSecurityManager(sm);
>         ThreadRunning t = new ThreadRunning();
>         t.start();
>         t.stopWork = true;
>         try {
>             t.join();
>         } catch (InterruptedException e) {
>             fail("Assert 0: unexpected " + e);          
>         }
>         try {
>             sm.checkAccess(t);
>         } catch (NullPointerException e) {
>             fail("Assert 1: NullPointerException has been thrown");
>         }
>     } 
> } 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message