From 5bfb1c03c7b1c192d7b748ae024696367546b886 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 19 May 2010 15:13:18 +0000 Subject: [PATCH] 312839: smaller class files --- .../systemtest/ajc160/SanityTests.java | 240 ++++++++++-------- .../systemtest/ajc169/Ajc169Tests.java | 18 ++ .../org/aspectj/systemtest/ajc169/ajc169.xml | 9 + .../tools/MultiProjectIncrementalTests.java | 3 +- 4 files changed, 169 insertions(+), 101 deletions(-) diff --git a/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java b/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java index bda998979..6bcc9625c 100644 --- a/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java +++ b/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java @@ -30,106 +30,146 @@ import org.aspectj.testing.XMLBasedAjcTestCase; */ public class SanityTests extends org.aspectj.testing.XMLBasedAjcTestCase { - // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) - public void testSimpleJava_A() { runTest("simple - a");} - public void testSimpleJava_B() { runTest("simple - b");} - public void testSimpleCode_C() { runTest("simple - c");} - public void testSimpleCode_D() { runTest("simple - d");} - public void testSimpleCode_E() { runTest("simple - e");} - public void testSimpleCode_F() { runTest("simple - f");} - public void testSimpleCode_G() { runTest("simple - g");} - - public void testSimpleCode_H() { runTest("simple - h");} - public void testSimpleCode_I() { runTest("simple - i");} - - // Check the version number in the classfiles is correct when Java6 options specified - public void testVersionCorrect1() throws ClassNotFoundException { - runTest("simple - j"); - checkVersion("A",50,0); - } - public void testVersionCorrect2() throws ClassNotFoundException { - runTest("simple - k"); - checkVersion("A",50,0); - } - public void testVersionCorrect3() throws ClassNotFoundException { - runTest("simple - l"); - checkVersion("A",50,0); - } - public void testVersionCorrect4() throws ClassNotFoundException {// check it is 49.0 when -1.5 is specified - runTest("simple - m"); - checkVersion("A",49,0); - } - - // Check the stackmap stuff appears for methods in a Java6 file -// public void testStackMapAttributesAppear() throws ClassNotFoundException { -// runTest("simple - n"); -// checkStackMapExistence("A","_"); -// checkStackMapExistence("X","__ajc$pointcut$$complicatedPointcut$1fe"); -// } - - /* For the specified class, check that each method has a stackmap attribute */ - private void checkStackMapExistence(String classname,String toIgnore) throws ClassNotFoundException { - toIgnore="_"+(toIgnore==null?"":toIgnore)+"_"; - JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),classname); - Method[] methods = jc.getMethods(); - for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; - if (toIgnore.contains("_"+method.getName()+"_")) continue; - boolean hasStackMapAttribute = findAttribute(method.getAttributes(),"StackMapTable"); - if (!hasStackMapAttribute) fail("Could not find StackMap attribute for method "+method.getName()); - } - } - - private boolean findAttribute(Attribute[] attrs,String attributeName) { - if (attrs==null) return false; - for (int i = 0; i < attrs.length; i++) { - Attribute attribute = attrs[i]; - if (attribute.getName().equals(attributeName)) return true; - //System.out.println(attribute.getName()); - if (attribute.getName().equals("Code")) { - Code c = (Code)attribute; - Attribute[] codeAttributes = c.getAttributes(); - for (int j = 0; j < codeAttributes.length; j++) { - Attribute codeAttribute = codeAttributes[j]; - if (codeAttribute.getName().equals(attributeName)) return true; - //System.out.println(codeAttribute.getName()); + // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) + public void testSimpleJava_A() { + runTest("simple - a"); + } + + public void testSimpleJava_B() { + runTest("simple - b"); + } + + public void testSimpleCode_C() { + runTest("simple - c"); + } + + public void testSimpleCode_D() { + runTest("simple - d"); + } + + public void testSimpleCode_E() { + runTest("simple - e"); + } + + public void testSimpleCode_F() { + runTest("simple - f"); + } + + public void testSimpleCode_G() { + runTest("simple - g"); + } + + public void testSimpleCode_H() { + runTest("simple - h", true); + } + + public void testSimpleCode_I() { + runTest("simple - i"); + } + + // Check the version number in the classfiles is correct when Java6 options specified + public void testVersionCorrect1() throws ClassNotFoundException { + runTest("simple - j"); + checkVersion("A", 50, 0); + } + + public void testVersionCorrect2() throws ClassNotFoundException { + runTest("simple - k"); + checkVersion("A", 50, 0); + } + + public void testVersionCorrect3() throws ClassNotFoundException { + runTest("simple - l"); + checkVersion("A", 50, 0); + } + + public void testVersionCorrect4() throws ClassNotFoundException {// check it is 49.0 when -1.5 is specified + runTest("simple - m"); + checkVersion("A", 49, 0); + } + + // Check the stackmap stuff appears for methods in a Java6 file + // public void testStackMapAttributesAppear() throws ClassNotFoundException { + // runTest("simple - n"); + // checkStackMapExistence("A","_"); + // checkStackMapExistence("X","__ajc$pointcut$$complicatedPointcut$1fe"); + // } + + /* For the specified class, check that each method has a stackmap attribute */ + private void checkStackMapExistence(String classname, String toIgnore) throws ClassNotFoundException { + toIgnore = "_" + (toIgnore == null ? "" : toIgnore) + "_"; + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); + Method[] methods = jc.getMethods(); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + if (toIgnore.contains("_" + method.getName() + "_")) { + continue; + } + boolean hasStackMapAttribute = findAttribute(method.getAttributes(), "StackMapTable"); + if (!hasStackMapAttribute) { + fail("Could not find StackMap attribute for method " + method.getName()); + } + } + } + + private boolean findAttribute(Attribute[] attrs, String attributeName) { + if (attrs == null) { + return false; + } + for (int i = 0; i < attrs.length; i++) { + Attribute attribute = attrs[i]; + if (attribute.getName().equals(attributeName)) { + return true; + } + // System.out.println(attribute.getName()); + if (attribute.getName().equals("Code")) { + Code c = (Code) attribute; + Attribute[] codeAttributes = c.getAttributes(); + for (int j = 0; j < codeAttributes.length; j++) { + Attribute codeAttribute = codeAttributes[j]; + if (codeAttribute.getName().equals(attributeName)) { + return true; + // System.out.println(codeAttribute.getName()); + } + } } } - } - return false; - } - - private void checkVersion(String classname,int major,int minor) throws ClassNotFoundException { - JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),classname); - if (jc.getMajor()!=major) fail("Expected major version to be "+major+" but was "+jc.getMajor()); - if (jc.getMinor()!=minor) fail("Expected minor version to be "+minor+" but was "+jc.getMinor()); - } - - // Check the stackmap stuff is removed when a method gets woven (for now...) -// public void testStackMapAttributesDeletedInWovenCode() { -// fail("Not implemented"); -// } - - - ///////////////////////////////////////// - public SyntheticRepository createRepos(File cpentry) { - ClassPath cp = new ClassPath(cpentry+File.pathSeparator+System.getProperty("java.class.path")); - return SyntheticRepository.getInstance(cp); - } - - protected JavaClass getClassFrom(File where,String clazzname) throws ClassNotFoundException { - SyntheticRepository repos = createRepos(where); - return repos.loadClass(clazzname); - } - - ///////////////////////////////////////// - public static Test suite() { - return XMLBasedAjcTestCase.loadSuite(SanityTests.class); - } - - protected File getSpecFile() { - return new File("../tests/src/org/aspectj/systemtest/ajc160/sanity-tests.xml"); - } - - + return false; + } + + private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException { + JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); + if (jc.getMajor() != major) { + fail("Expected major version to be " + major + " but was " + jc.getMajor()); + } + if (jc.getMinor() != minor) { + fail("Expected minor version to be " + minor + " but was " + jc.getMinor()); + } + } + + // Check the stackmap stuff is removed when a method gets woven (for now...) + // public void testStackMapAttributesDeletedInWovenCode() { + // fail("Not implemented"); + // } + + // /////////////////////////////////////// + public SyntheticRepository createRepos(File cpentry) { + ClassPath cp = new ClassPath(cpentry + File.pathSeparator + System.getProperty("java.class.path")); + return SyntheticRepository.getInstance(cp); + } + + protected JavaClass getClassFrom(File where, String clazzname) throws ClassNotFoundException { + SyntheticRepository repos = createRepos(where); + return repos.loadClass(clazzname); + } + + // /////////////////////////////////////// + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SanityTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc160/sanity-tests.xml"); + } + } diff --git a/tests/src/org/aspectj/systemtest/ajc169/Ajc169Tests.java b/tests/src/org/aspectj/systemtest/ajc169/Ajc169Tests.java index 151108e7a..25e323f1b 100644 --- a/tests/src/org/aspectj/systemtest/ajc169/Ajc169Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc169/Ajc169Tests.java @@ -18,6 +18,24 @@ import org.aspectj.testing.XMLBasedAjcTestCase; public class Ajc169Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testClassFileSize_312839_1() { + runTest("class file size - 1"); + // 2531 (0x404): 1.6.9.M2 size of Class.class + // 2494 (0x3DF): first little stab, compressing aspectnames attached to type mungers + // 2370 (0x363): changed read/write sourcelocation to write path rather than File object: + // 2358 (0x357): aspects affecting type compressed (weaverstate reweavable info) + // 2102 (0x257): changed read/write sourcelocation in type munger to NOT use object streams + // 2053 (0x1EF): changed path in sourcelocation read/write to be constant pool (so shared between both mungers) + // 2019: changed resolvedMemberImpl name/signature to be compressed refs + // 1954 (0x18C) + + // Aspect size (X.class) down from 6459 to 4722 + // 4551: changed exact type pattern writing to use constant pool, and + // changed typepatternlist to not both writing/reading location + + // TODO actually test something :) + } + // control test - weaves everything public void testScopingLTW_122460_1() { runTest("scoping ltw - 1"); diff --git a/tests/src/org/aspectj/systemtest/ajc169/ajc169.xml b/tests/src/org/aspectj/systemtest/ajc169/ajc169.xml index 63fadedaf..b76de13b7 100644 --- a/tests/src/org/aspectj/systemtest/ajc169/ajc169.xml +++ b/tests/src/org/aspectj/systemtest/ajc169/ajc169.xml @@ -2,6 +2,15 @@ + + + + + + + + + diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index b37a2f79d..831b61462 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -482,7 +482,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa alter(p, "inc1"); build(p); // error is: inter-type declaration from X conflicts with existing member: void A.() - List ms = getErrorMessages(p); + // List ms = + getErrorMessages(p); assertEquals(4, getErrorMessages(p).size()); // Why 4 errors? I believe the problem is: // 2 errors are reported when there is a clash - one against the aspect, one against the affected target type. -- 2.39.5