diff options
author | aclement <aclement> | 2004-12-03 16:11:16 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-12-03 16:11:16 +0000 |
commit | 343fd37dfa5fb623c3ed8c5b561d88221dee2ca5 (patch) | |
tree | 1e497708fcc6293d69838b4fba9d26883af2b0a0 /tests | |
parent | dae0fd4898e22dc648317f77b988d5d308fcaf42 (diff) | |
download | aspectj-343fd37dfa5fb623c3ed8c5b561d88221dee2ca5.tar.gz aspectj-343fd37dfa5fb623c3ed8c5b561d88221dee2ca5.zip |
72766 - varargs policing in signature matching
Diffstat (limited to 'tests')
4 files changed, 82 insertions, 14 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc150/AllTestsJava5_binaryWeaving.java b/tests/src/org/aspectj/systemtest/ajc150/AllTestsJava5_binaryWeaving.java index 44e76aac6..ec734bd87 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/AllTestsJava5_binaryWeaving.java +++ b/tests/src/org/aspectj/systemtest/ajc150/AllTestsJava5_binaryWeaving.java @@ -29,6 +29,7 @@ public class AllTestsJava5_binaryWeaving { suite.addTestSuite(CovarianceTests.class); suite.addTestSuite(Enums.class); suite.addTestSuite(Annotations.class); + suite.addTestSuite(Varargs.class); //$JUnit-END$ return suite; } diff --git a/tests/src/org/aspectj/systemtest/ajc150/TestUtils.java b/tests/src/org/aspectj/systemtest/ajc150/TestUtils.java index b7d90489e..3462432e3 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/TestUtils.java +++ b/tests/src/org/aspectj/systemtest/ajc150/TestUtils.java @@ -24,9 +24,17 @@ public abstract class TestUtils extends AjcTestCase { private static final boolean verbose = false; protected File baseDir; + protected CompilationResult binaryWeave(String inpath,String insource,int expErrors,int expWarnings) { + return binaryWeave(inpath,insource,expErrors,expWarnings,false); + } - protected CompilationResult binaryWeave(String inpath, String insource,int expErrors,int expWarnings) { - String[] args = new String[] {"-inpath",inpath,insource,"-showWeaveInfo","-proceedOnError"}; + protected CompilationResult binaryWeave(String inpath, String insource,int expErrors,int expWarnings,boolean xlinterror) { + String[] args = null; + if (xlinterror) { + args = new String[] {"-inpath",inpath,insource,"-showWeaveInfo","-proceedOnError","-Xlint:warning"}; + } else { + args = new String[] {"-inpath",inpath,insource,"-showWeaveInfo","-proceedOnError"}; + } CompilationResult result = ajc(baseDir,args); if (verbose || result.hasErrorMessages()) System.out.println(result); assertTrue("Expected "+expErrors+" errors but got "+result.getErrorMessages().size()+":\n"+ diff --git a/tests/src/org/aspectj/systemtest/ajc150/Varargs.java b/tests/src/org/aspectj/systemtest/ajc150/Varargs.java new file mode 100644 index 000000000..075790c9b --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc150/Varargs.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import org.aspectj.bridge.IMessage; +import org.aspectj.tools.ajc.CompilationResult; + + +/** + * Varargs, the rules/tests: + * + * 1. cannot match on a varargs method by using 'Object[]' in your signature, + * this affects call/execution/initialization/withincode + */ +public class Varargs extends TestUtils { + + protected void setUp() throws Exception { + super.setUp(); + baseDir = new File("../tests/java5/varargs"); + } + + // check when signature is from a call PCD + // should get message: + // "an array type as the last parameter in a signature does not match on the varargs declared method: <blah>" + public void test001_cantMatchVarargsWithObjectArray_callPCD() { + CompilationResult cR = binaryWeave("testcode.jar","VarargsAspect01.aj",0,3,true); + assertTrue("Did not get expected message about a varargs mismatch, instead got: "+cR.getWarningMessages(), + ((IMessage)cR.getWarningMessages().get(0)).toString().indexOf("varargs declared method")!=-1); + verifyWeavingMessagesOutput(cR,new String[]{}); + } + + // check when signature is from an execution PCD + public void test002_cantMatchVarargsWithObjectArray_execPCD() { + CompilationResult cR = binaryWeave("testcode.jar","VarargsAspect02.aj",0,1,true); + assertTrue("Did not get expected message about a varargs mismatch, instead got: "+cR.getWarningMessages(), + ((IMessage)cR.getWarningMessages().get(0)).toString().indexOf("varargs declared method")!=-1); + verifyWeavingMessagesOutput(cR,new String[]{}); + } + + // check when signature is from an initialization PCD + public void test003_cantMatchVarargsWithObjectArray_initPCD() { + CompilationResult cR = binaryWeave("testcode.jar","VarargsAspect03.aj",0,1,true); + assertTrue("Did not get expected message about a varags mismatch, instead got: "+cR.getWarningMessages(), + ((IMessage)cR.getWarningMessages().get(0)).toString().indexOf("varargs declared method")!=-1); + verifyWeavingMessagesOutput(cR,new String[]{}); + } + + // check when signature is from an withincode PCD + public void test003_cantMatchVarargsWithObjectArray_withincodePCD() { + CompilationResult cR = binaryWeave("testcode.jar","VarargsAspect04.aj",0,1,true); + assertTrue("Did not get expected message about a varags mismatch, instead got: "+cR.getWarningMessages(), + ((IMessage)cR.getWarningMessages().get(0)).toString().indexOf("varargs declared method")!=-1); + verifyWeavingMessagesOutput(cR,new String[]{}); + } + +}
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/todo.txt b/tests/src/org/aspectj/systemtest/ajc150/todo.txt index b055ac55b..d6bc462df 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/todo.txt +++ b/tests/src/org/aspectj/systemtest/ajc150/todo.txt @@ -4,25 +4,18 @@ Initial support for these features is mostly to do with tolerance of them for bi X Bridge Methods (Ignore them completely - they provide no join points) X Covariance (Properly support covariance) -o Varargs (Don't allow Object[] to match a varargs method) -o Autoboxing ( -o -source 1.5 (So we can change our behavior, e.g. autoboxing) -o LocalVarTypeTable (Manipulate it the same as we do the LocalVariableTable) X Annotations (No ITDs allowed) X Enums (No ITDs allowed) +X Varargs (Don't allow Object[] to match a varargs method) +o Autoboxing +o -source 1.5 (So we can change our behavior, e.g. autoboxing) +o LocalVarTypeTable (Manipulate it the same as we do the LocalVariableTable) o Annotation (No DECPs allowed) o Enums (No DECPs allowed) -=== - -Things not done: - -Marked with XXXAJ5 - currently tagging things like: - -- No covariance support for dynamic pointcut matching, need to dup declaringTypeMatch() changes for cov support === Things we ought to do: - Lift binary decp restriction -- ResolvedTypeMunger - switch on remembering source location ! +- ResolvedTypeMunger - switch on remembering source location !
\ No newline at end of file |