summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2004-10-14 08:12:09 +0000
committeraclement <aclement>2004-10-14 08:12:09 +0000
commit6e155a6b9b78ec64f2fd4dc08152698277f1e7b7 (patch)
treea8209a54d2190e699cecb488c93825bcacf1b464
parent234bea2297cc780d5bf38ebbc4087e938cc3b6e8 (diff)
downloadaspectj-6e155a6b9b78ec64f2fd4dc08152698277f1e7b7.tar.gz
aspectj-6e155a6b9b78ec64f2fd4dc08152698277f1e7b7.zip
Fix for Bugzilla Bug 74238: Applet which uses cflow pointcut gets AccessControlException
-rw-r--r--ajde/testdata/SecurityManagerTest/build.xml38
-rw-r--r--ajde/testdata/SecurityManagerTest/src/Aspect.aj24
-rw-r--r--ajde/testdata/SecurityManagerTest/src/HelloWorld.java24
-rw-r--r--lib/test/aspectjrt.jarbin41305 -> 41549 bytes
-rw-r--r--runtime/src/org/aspectj/runtime/internal/CFlowCounter.java12
-rw-r--r--runtime/src/org/aspectj/runtime/internal/CFlowStack.java12
6 files changed, 108 insertions, 2 deletions
diff --git a/ajde/testdata/SecurityManagerTest/build.xml b/ajde/testdata/SecurityManagerTest/build.xml
new file mode 100644
index 000000000..2b2496fc1
--- /dev/null
+++ b/ajde/testdata/SecurityManagerTest/build.xml
@@ -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
index 000000000..74a3f6bc9
--- /dev/null
+++ b/ajde/testdata/SecurityManagerTest/src/Aspect.aj
@@ -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 aspect Aspect {
+
+ pointcut method () :
+ execution(* println(..)) && within(HelloWorld) && cflow(execution(* main(..)));
+
+ before () : method () {
+ System.out.println(thisJoinPoint.getSignature());
+ }
+}
diff --git a/ajde/testdata/SecurityManagerTest/src/HelloWorld.java b/ajde/testdata/SecurityManagerTest/src/HelloWorld.java
new file mode 100644
index 000000000..fe981e7e6
--- /dev/null
+++ b/ajde/testdata/SecurityManagerTest/src/HelloWorld.java
@@ -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");
+ }
+}
diff --git a/lib/test/aspectjrt.jar b/lib/test/aspectjrt.jar
index 1e52a6373..7f2818be5 100644
--- a/lib/test/aspectjrt.jar
+++ b/lib/test/aspectjrt.jar
Binary files differ
diff --git a/runtime/src/org/aspectj/runtime/internal/CFlowCounter.java b/runtime/src/org/aspectj/runtime/internal/CFlowCounter.java
index e48f67864..3e20cae28 100644
--- a/runtime/src/org/aspectj/runtime/internal/CFlowCounter.java
+++ b/runtime/src/org/aspectj/runtime/internal/CFlowCounter.java
@@ -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();
diff --git a/runtime/src/org/aspectj/runtime/internal/CFlowStack.java b/runtime/src/org/aspectj/runtime/internal/CFlowStack.java
index 5e6eff590..e9d811124 100644
--- a/runtime/src/org/aspectj/runtime/internal/CFlowStack.java
+++ b/runtime/src/org/aspectj/runtime/internal/CFlowStack.java
@@ -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();