harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Catherine Hope (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-6503) [classlib][luni] ObjectOutputStream.writeObject throws AccessControlException when suppressAccessChecks not granted
Date Thu, 15 Jul 2010 09:29:50 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-6503?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Catherine Hope updated HARMONY-6503:
------------------------------------

    Attachment: 6503-2.patch

Apologies, I had only tested this on the IBM VME and not with DRLVM - I also get a crash reported
when I run the test from ant, though when I run it with the junit command-line runner I get:

There was 1 error:
1) test_writeObjectWithSecurityManager(org.apache.harmony.luni.tests.java.io.ObjectOutputStreamTest)java.security.AccessControlException:
Permission check failed (java.lang.RuntimePermission accessDeclaredMembers)
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:132)
	at java.security.AccessController.checkPermission(AccessController.java:194)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:862)
	at java.lang.SecurityManager.checkMemberAccess(SecurityManager.java:322)
	at java.lang.Class.checkMemberAccess(Class.java:681)
	at java.lang.Class.getDeclaredFields(Class.java:436)
	at java.io.ObjectStreamClass.createClassDesc(ObjectStreamClass.java:258)
	at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:997)
	at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1697)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1639)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1603)
	at org.apache.harmony.luni.tests.java.io.ObjectOutputStreamTest.test_writeObjectWithSecurityManager(ObjectOutputStreamTest.java:1411)
	at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)

FAILURES!!!
Tests run: 35,  Failures: 0,  Errors: 1

The testcase passes if I also add the accessDeclaredMembers RuntimePermission to the policy,
however I don't need this permission on the RI and according to the spec member access is
granted to "classes that have the same class loader as the caller".
With the original policy if I call object.getClass().getDeclaredFields() directly from my
test class then no access control exception is seen.  However when it's called from ObjectStreamClass.createClassDesc
the classloader is not recognised as being the same.  I've traced this to the native method
VMStack.getCallerClass which is returning null when called with argument "3" instead of the
name of the classloader, but I don't understand the DRLVM code enough to fix this.

I'm going to add the additional policy permission into the testcase so that the fix to ObjectStreamClass
can be committed.  Without the fix the testcase gives:

test_writeObjectWithSecurityManager(org.apache.harmony.luni.tests.java.io.ObjectOutputStreamTest)java.security.AccessControlException:
Permission check failed (java.lang.reflect.ReflectPermission suppressAccessChecks)
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:132)
	at java.security.AccessController.checkPermission(AccessController.java:194)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:862)
	at java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:131)
	at java.io.ObjectStreamClass.findPrivateMethod(ObjectStreamClass.java:1047)
	at java.io.ObjectStreamClass.createClassDesc(ObjectStreamClass.java:302)
	at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:996)
	at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1697)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1639)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1603)
	at org.apache.harmony.luni.tests.java.io.ObjectOutputStreamTest.test_writeObjectWithSecurityManager(ObjectOutputStreamTest.java:1411)
	at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)

With the fix (and on the RI) there is no exception thrown.

> [classlib][luni] ObjectOutputStream.writeObject throws AccessControlException when suppressAccessChecks
not granted
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6503
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6503
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Catherine Hope
>            Priority: Minor
>         Attachments: 6503-2.patch, 6503.patch
>
>
> Calling java.io.ObjectOutputStream.writeObject(ObjectOutputStream)  with a security manager
installed and the policy has not granted java.lang.reflect.ReflectPermission suppressAccessChecks
throws a java.security.AccessControlException.  
> java.security.AccessControlException: Access denied (java.lang.reflect.ReflectPermission
suppressAccessChecks)
> 	at java.security.AccessController.checkPermission(AccessController.java:95)
> 	at java.lang.SecurityManager.checkPermission(SecurityManager.java:862)
> 	at java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:103)
> 	at java.io.ObjectStreamClass.findPrivateMethod(ObjectStreamClass.java:1050)
> 	at java.io.ObjectStreamClass.createClassDesc(ObjectStreamClass.java:303)
> 	at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:997)
> 	at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1696)
> 	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1639)
> 	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1603)
> 	at org.apache.harmony.luni.tests.java.io.ObjectOutputStreamTest.test_writeObjectWithSecurityManager(ObjectOutputStreamTest.java:1406)
> This does not occur on the RI.

-- 
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