]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 74238: Applet which uses cflow pointcut gets AccessControlException
authoraclement <aclement>
Thu, 14 Oct 2004 08:12:09 +0000 (08:12 +0000)
committeraclement <aclement>
Thu, 14 Oct 2004 08:12:09 +0000 (08:12 +0000)
ajde/testdata/SecurityManagerTest/build.xml [new file with mode: 0644]
ajde/testdata/SecurityManagerTest/src/Aspect.aj [new file with mode: 0644]
ajde/testdata/SecurityManagerTest/src/HelloWorld.java [new file with mode: 0644]
lib/test/aspectjrt.jar
runtime/src/org/aspectj/runtime/internal/CFlowCounter.java
runtime/src/org/aspectj/runtime/internal/CFlowStack.java

diff --git a/ajde/testdata/SecurityManagerTest/build.xml b/ajde/testdata/SecurityManagerTest/build.xml
new file mode 100644 (file)
index 0000000..2b2496f
--- /dev/null
@@ -0,0 +1,38 @@
+<project name="SecurityManagerTest" default="all" basedir=".">
+
+       <property name="aspectj" value="j:\eclipse\aspectj_ws\aj-build\dist\tools\lib"/>
+       <property name="aspectjrt" value="${aspectj}/aspectjrt.jar" />
+       <property name="aspectjtools" value="${aspectj}/aspectjtools.jar" />
+
+       <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
+               <classpath>
+                       <pathelement path="${aspectjtools}"/>
+               </classpath>
+       </taskdef>
+
+       <target name="compile">
+               <iajc
+                       srcdir="${basedir}/src"
+                       classpath="${aspectjrt}"
+                       destdir="${basedir}/bin"
+                       verbose="true"
+
+               fork="true"
+               forkclasspath="${aspectjtools}"
+               >
+               </iajc>
+       </target>
+       
+       <target name="run">
+               <java
+                       classname="HelloWorld"
+                       classpath="${basedir}/../../../runtime/bin;${basedir}/bin"
+                       fork="yes"
+               >
+                       <jvmarg value="-Djava.security.manager"/>
+               </java>
+       </target>
+       
+       <target name="all" depends="compile, run"/>
+
+</project>
diff --git a/ajde/testdata/SecurityManagerTest/src/Aspect.aj b/ajde/testdata/SecurityManagerTest/src/Aspect.aj
new file mode 100644 (file)
index 0000000..74a3f6b
--- /dev/null
@@ -0,0 +1,24 @@
+/*\r
+ * Created on 28-Sep-2004\r
+ *\r
+ * TODO To change the template for this generated file go to\r
+ * Window - Preferences - Java - Code Style - Code Templates\r
+ */\r
+\r
+\r
+\r
+/**
+ * @author websterm
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */\r
+public aspect Aspect {\r
+\r
+       pointcut method () :\r
+               execution(* println(..)) && within(HelloWorld) && cflow(execution(* main(..)));\r
+       \r
+       before () : method () {\r
+               System.out.println(thisJoinPoint.getSignature());\r
+       }\r
+}\r
diff --git a/ajde/testdata/SecurityManagerTest/src/HelloWorld.java b/ajde/testdata/SecurityManagerTest/src/HelloWorld.java
new file mode 100644 (file)
index 0000000..fe981e7
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Created on 28-Sep-2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * @author websterm
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class HelloWorld {
+
+       public static void println () {
+               System.out.println("Hello World!");
+       }
+       
+       public static void main(String[] args) {
+               println();
+//             System.getProperty("foo");
+       }
+}
index 1e52a637314b5fff6038c7fb74ec869fbf3c4620..7f2818be5d9c0bbc0b81e26bd9e8cbaadb2e636f 100644 (file)
Binary files a/lib/test/aspectjrt.jar and b/lib/test/aspectjrt.jar differ
index e48f6786439a0dff82a586b7732ac0412b6013fa..3e20cae289b46548ec84b323222364bb0c0f0554 100644 (file)
@@ -50,7 +50,7 @@ public class CFlowCounter {
        private static ThreadStackFactory getThreadLocalStackFactoryFor11() { return new ThreadStackFactoryImpl11(); }
     
        private static void selectFactoryForVMVersion() {
-               String override = System.getProperty("aspectj.runtime.cflowstack.usethreadlocal","unspecified");
+               String override = getSystemPropertyWithoutSecurityException("aspectj.runtime.cflowstack.usethreadlocal","unspecified");
                boolean useThreadLocalImplementation = false;
                if (override.equals("unspecified")) {
                        String v = System.getProperty("java.class.version","0.0");
@@ -67,6 +67,16 @@ public class CFlowCounter {
                }
        }
        
+       
+       private static String getSystemPropertyWithoutSecurityException (String aPropertyName, String aDefaultValue) {
+               try {
+                       return System.getProperty(aPropertyName, aDefaultValue);
+               }
+               catch (SecurityException ex) {
+                       return aDefaultValue;
+               }
+       }
+       
        //  For debug ...
        public static String getThreadStackFactoryClassName() {
                return tsFactory.getClass().getName();
index 5e6eff590a1d8a05b175b15cd8921eda8d720789..e9d81112455db70b03b898af01b8645dc25cc80f 100644 (file)
@@ -121,7 +121,7 @@ public class CFlowStack {
        private static ThreadStackFactory getThreadLocalStackFactoryFor11() { return new ThreadStackFactoryImpl11(); }
     
        private static void selectFactoryForVMVersion() {
-               String override = System.getProperty("aspectj.runtime.cflowstack.usethreadlocal","unspecified");
+               String override = getSystemPropertyWithoutSecurityException("aspectj.runtime.cflowstack.usethreadlocal","unspecified");
                boolean useThreadLocalImplementation = false;
                if (override.equals("unspecified")) {
                        String v = System.getProperty("java.class.version","0.0");
@@ -138,6 +138,16 @@ public class CFlowStack {
                }
        }
        
+       private static String getSystemPropertyWithoutSecurityException (String aPropertyName, String aDefaultValue) {
+               try {
+                       return System.getProperty(aPropertyName, aDefaultValue);
+               }
+               catch (SecurityException ex) {
+                       return aDefaultValue;
+               }
+       }
+
+       
        //  For debug ...
        public static String getThreadStackFactoryClassName() {
                return tsFactory.getClass().getName();