harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vasily Zakharov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-3786) [drlvm][netbeans] SecurityManager.getStackClasses() return incorrect
Date Sun, 29 Apr 2007 02:57:15 GMT
[drlvm][netbeans] SecurityManager.getStackClasses() return incorrect
--------------------------------------------------------------------

                 Key: HARMONY-3786
                 URL: https://issues.apache.org/jira/browse/HARMONY-3786
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
            Reporter: Vasily Zakharov
            Priority: Minor


I'm not sure whether this issue should have been filed against classlib/luni, classlib/security,
DRLVM/kernel_classes or DRLVM itself, but it only occurs on DRLVM. Please suggest the correct
component if you know one.

Consider the following simple test. It installs a security manager that prints the return
of SecurityManager.getClassContext() as well as the stack trace at the same point when System.getProperty("test")
is called:

public class Test {
    static boolean success = true;

    public static void main(String args[]) throws Exception {
        System.setSecurityManager(new TestSecurityManager());
        System.getProperty("test");
        System.out.println(success ? "SUCCESS" : "FAIL");
    }

    static class TestSecurityManager extends SecurityManager {
        public void checkPropertyAccess(String name) {
            if (name.equals("test")) {
                Class[] context = getClassContext();
                System.out.println("checkPropertyAccess(" + name + ") class context: ");

                for (int i = 0; i < context.length; i++) {
                    Class cls = context[i];
                    if (cls == SecurityManager.class) {
                        success = false;
                    }
                    System.out.println("\t" + cls.getName());
                }
                System.out.print("found at stack: ");
                new Throwable().printStackTrace(System.out);
            }
        }
    }
}

Output on RI:

checkPropertyAccess(test) class context:
        Test$TestSecurityManager
        java.lang.System
        Test
found at stack: java.lang.Throwable
        at Test$TestSecurityManager.checkPropertyAccess(Test.java:24)
        at java.lang.System.getProperty(Unknown Source)
        at Test.main(Test.java:6)
SUCCESS

Output on Harmony/IBM VM:

checkPropertyAccess(test) class context:
        Test$TestSecurityManager
        java.lang.System
        java.lang.System
        Test
found at stack: java.lang.Throwable
        at Test$TestSecurityManager.checkPropertyAccess(Test.java:24)
        at java.lang.System.getProperty(System.java:675)
        at java.lang.System.getProperty(System.java:660)
        at Test.main(Test.java:6)
SUCCESS

Output on Harmony/DRL VM:

checkPropertyAccess(test) class context:
        java.lang.SecurityManager
        Test$TestSecurityManager
        java.lang.System
        java.lang.System
        Test
found at stack: java.lang.Throwable
        at Test$TestSecurityManager.checkPropertyAccess(Test.java:24)
        at java.lang.System.getProperty(System.java:158)
        at java.lang.System.getProperty(System.java:149)
        at Test.main(Test.java:6)
FAIL

Logically, the list of classes in the class context and in the stack trace should be identical.
This is true for RI and Harmony/IBMVM, but on Harmony/DRLVM extra java.lang.SecurityManager
appears on the top of class context for some reason. The problem occurs on both Jit and Interpreter.

The test provided here probably won't make a good regression. Maybe SecurityManager.getClassContext()[i].getName()
should be compared to new Throwable().getStackTrace()[i].getClassName() or something like
that. I'm not sure which approach is the most correct and effective one in this case.

This bug was found while trying to run NetBeans on Harmony. It is indicated by the following
line in NetBeans log:
"Warning: use of system property netbeans.home in java.lang.SecurityManager has been obsoleted
in favor of InstalledFileLocator"
that is printed from org.netbeans.TopSecurityManager.checkPropertyAccess() method, line 197.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message