Bug 71257 - Provide An Option to NOT use ThreadLocal for cflow in rt.jar
Summary: Provide An Option to NOT use ThreadLocal for cflow in rt.jar
Status: RESOLVED WORKSFORME
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 2000
: P4 enhancement (vote)
Target Milestone: 1.5.1   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-02 16:56 EDT by Ron Bodkin CLA
Modified: 2005-10-27 09:58 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ron Bodkin CLA 2004-08-02 16:56:45 EDT
Enhancement request in aspectjrt.jar:

I am trying to use AspectJ to weave an aspect that uses a cflow pointcut into an
applet. But the Sun Java Plug-In version 1.4.2_04 throws a security violation if
an applet tries to construct a ThreadLocal. So I'd like to be able to use the
old cflow stack implementation. I get this exception:

Caused by: java.security.AccessControlException: access denied
(java.util.PropertyPermission aspectj.runtime.cflowstack.usethreadlocal read)

	at java.security.AccessControlContext.checkPermission(Unknown Source)

	at java.security.AccessController.checkPermission(Unknown Source)

	at java.lang.SecurityManager.checkPermission(Unknown Source)

	at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)

	at java.lang.System.getProperty(Unknown Source)

	at
org.aspectj.runtime.internal.CFlowStack.selectFactoryForVMVersion(CFlowStack.java:124)

	at org.aspectj.runtime.internal.CFlowStack.<clinit>(CFlowStack.java:59)

	... 33 more

I can work around this problem by using aspectjrt.jar from AspectJ 1.1.1, but
think there ought to be some runtime flag to not use ThreadLocals...
Comment 1 Adrian Colyer CLA 2004-08-06 08:35:04 EDT
changed severity to 'enhancement'.....
Comment 2 Adrian Colyer CLA 2005-03-22 09:14:28 EST
Andy - doesn't your autodetect logic catch this case? If not we should either
improve the detection or if that's impossible, give a compiler option...
Comment 3 Andrew Clement CLA 2005-09-28 07:20:12 EDT
Hmmmmmmmmmmmmm

The logic has been in place for a while to ensure the security exception isn't
surfaced when attempting to read the system property.  I'm just a little unsure
if it will behave exactly how you want.  If the system property cannot be read
then we check the version number of the class file - 46 or higher and we assume
ThreadLocal is available.  So, if the security exception is now hidden and yet
it still attempts to utilise threadlocal, try compiling -target 1.1 to generate
version 45 class files.  that should cause it to avoid doing anything with
ThreadLocal.  I've tried to recreate the problem here just using appletviewer
but can't seem to get the security policy right, whatever I try it successfully
accesses the system property.

If you happen to know how to set my local policy such that an applet can't
access sys props then I'll look into it a little further...
Comment 4 Andrew Clement CLA 2005-10-27 06:38:37 EDT
I think the support is there but can't test it.  If you can't try it soon Ron,
I'll close this.
Comment 5 Ron Bodkin CLA 2005-10-27 09:03:44 EDT
Do you not see this issue in running an applet on a standard Java Plug-In? I 
didn't do anything to configure it...

However, this issue came up on a project that I'm not working on any more, so I 
don't have the environment to test it with myself.
Comment 6 Andrew Clement CLA 2005-10-27 09:26:14 EDT
I couldnt seem to recreate with a standard applet - it is possible the 'detect'
logic was enhanced after you originally hit the problem and before I attempted
to recreate.
Comment 7 Ron Bodkin CLA 2005-10-27 09:32:48 EDT
Sounds plausible. Let's mark it as resolved and let someone reopen it if they 
find the issue again.
Comment 8 Andrew Clement CLA 2005-10-27 09:58:17 EDT
Thanks Ron - gets my numbers down ;) I'm happy to work on this if it raises its
head again.