diff options
5 files changed, 46 insertions, 10 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java index 9821f9ad5..ba0fa3a1f 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java @@ -132,6 +132,7 @@ public abstract class World implements Dump.INode { private boolean synchronizationPointcutsInUse = false; // Xset'table options private boolean runMinimalMemory = false; + private boolean transientTjpFields = false; private boolean runMinimalMemorySet = false; private boolean shouldPipelineCompilation = true; private boolean shouldGenerateStackMaps = false; @@ -944,6 +945,7 @@ public abstract class World implements Dump.INode { // false public final static String xsetDEBUG_BRIDGING = "debugBridging"; // default // false + public final static String xsetTRANSIENT_TJP_FIELDS = "makeTjpFieldsTransient"; // default false public final static String xsetBCEL_REPOSITORY_CACHING = "bcelRepositoryCaching"; public final static String xsetPIPELINE_COMPILATION = "pipelineCompilation"; public final static String xsetGENERATE_STACKMAPS = "generateStackMaps"; @@ -1615,6 +1617,9 @@ public abstract class World implements Dump.INode { s = p.getProperty(xsetDEBUG_STRUCTURAL_CHANGES_CODE, "false"); forDEBUG_structuralChangesCode = s.equalsIgnoreCase("true"); + + s = p.getProperty(xsetTRANSIENT_TJP_FIELDS,"false"); + transientTjpFields = s.equalsIgnoreCase("true"); s = p.getProperty(xsetDEBUG_BRIDGING, "false"); forDEBUG_bridgingCode = s.equalsIgnoreCase("true"); @@ -1669,6 +1674,11 @@ public abstract class World implements Dump.INode { ensureAdvancedConfigurationProcessed(); return runMinimalMemory; } + + public boolean isTransientTjpFields() { + ensureAdvancedConfigurationProcessed(); + return transientTjpFields; + } public boolean isRunMinimalMemorySet() { ensureAdvancedConfigurationProcessed(); diff --git a/tests/bugs170/transientTjpFields/Code.java b/tests/bugs170/transientTjpFields/Code.java new file mode 100644 index 000000000..8b4c44e17 --- /dev/null +++ b/tests/bugs170/transientTjpFields/Code.java @@ -0,0 +1,12 @@ +public class Code { + public void m() { + } + + public void n() { + } + +} + +aspect X { + before(): execution(* Code.*(..)) {System.out.println(thisJoinPointStaticPart);} +} diff --git a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java index 4e40d4162..63cb5e22b 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java @@ -11,27 +11,33 @@ package org.aspectj.systemtest.ajc170; import java.io.File; -import java.util.List; import junit.framework.Test; -import org.aspectj.apache.bcel.util.ClassPath; +import org.aspectj.apache.bcel.classfile.Field; +import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.testing.XMLBasedAjcTestCase; -import org.aspectj.weaver.CrosscuttingMembers; -import org.aspectj.weaver.ReferenceType; -import org.aspectj.weaver.ResolvedMember; -import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.TypeFactory; -import org.aspectj.weaver.TypeVariable; import org.aspectj.weaver.UnresolvedType; -import org.aspectj.weaver.World; -import org.aspectj.weaver.bcel.BcelWorld; /** * @author Andy Clement */ public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testTransientTjpFields()throws Exception { + runTest("transient tjp fields"); + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Code"); + Field[] fs = jc.getFields(); + //private static final org.aspectj.lang.JoinPoint$StaticPart ajc$tjp_0 [Synthetic] + //private static final org.aspectj.lang.JoinPoint$StaticPart ajc$tjp_1 [Synthetic] + for (Field f: fs) { + if (!f.isTransient()) { + fail("Field should be transient: "+f); + } + } + } + public void testGenericsWithTwoTypeParamsOneWildcard() { UnresolvedType ut; diff --git a/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml b/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml index 8a6c34c53..314ff1c6d 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml +++ b/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml @@ -2,6 +2,11 @@ <suite> + <ajc-test dir="bugs170/transientTjpFields" title="transient tjp fields"> + <compile files="Code.java" options="-Xset:makeTjpFieldsTransient=true"> + </compile> + </ajc-test> + <ajc-test dir="bugs170/language" title="perthis"> <compile files="PerThis.java" options="-1.7"> </compile> diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java index 6a41e410d..606bd2a96 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java @@ -981,7 +981,7 @@ public final class LazyClassGen { return tjpField; } - int modifiers = Modifier.STATIC | Modifier.FINAL; + int modifiers = Modifier.STATIC | Modifier.FINAL ; // XXX - Do we ever inline before or after advice? If we do, then we // better include them in the check below. (or just change it to @@ -1034,6 +1034,9 @@ public final class LazyClassGen { } } } + if (!isInterface() && world.isTransientTjpFields()) { + modifiers|=Modifier.TRANSIENT; + } FieldGen fGen = new FieldGen(modifiers, jpType, "ajc$tjp_" + tjpFieldsCounter++, getConstantPool()); addField(fGen); tjpField = fGen.getField(); |