diff options
author | acolyer <acolyer> | 2005-09-08 14:09:18 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-09-08 14:09:18 +0000 |
commit | 08d6a5d1e032d33b46afca2fd92d3700b06a6cc6 (patch) | |
tree | ddc9e159e4b94211d7b833620e985f3a416bd411 /tests | |
parent | 2505485766b460041f2648e56f34132982f6428a (diff) | |
download | aspectj-08d6a5d1e032d33b46afca2fd92d3700b06a6cc6.tar.gz aspectj-08d6a5d1e032d33b46afca2fd92d3700b06a6cc6.zip |
tests and fix for pr109042, unusedArgument warning on aj synthetic args
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bugs150/pr109042.aj | 166 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java | 4 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 5 |
3 files changed, 175 insertions, 0 deletions
diff --git a/tests/bugs150/pr109042.aj b/tests/bugs150/pr109042.aj new file mode 100644 index 000000000..c0744f133 --- /dev/null +++ b/tests/bugs150/pr109042.aj @@ -0,0 +1,166 @@ +import java.util.ArrayList; +import java.util.List; + +class PlayList { + + private static PlayList instance; + + private List<Song> list; + + private PlayList() { + list = new ArrayList<Song>(); + } + + public static PlayList instance() { + if(instance==null ) { + instance = new PlayList(); + } + return instance; + } + + public void enqueue(Song song) { + list.add(song); + if(Player.instance().isIdle()) { + new Thread() { + public void run() { + System.out.println("Playing playlist..."); + for (Song s : list) { + Player.instance().play(s.getName()); + } + } + }.start(); + } + } + +} + +class Song { + + private String name; + + public Song(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} + +class Player { + + private static Player instance; + + private Player() {} + + public static Player instance() { + if(instance==null ) { + instance = new Player(); + } + return instance; + } + + public void play(String name) { + System.out.println("Playing Song "+name+"..."); + } + + public boolean isIdle() { + return true; + } +} + +class Jukebox { + + public void play(Song song) { + Player.instance().play(song.getName()); + } + + } + +class Main { + + public static void main(String[] args) { + Song song = new Song("Merry XMas"); + Jukebox jukebox = new Jukebox(); + + jukebox.play(song); + } + +} + +aspect PlaylistAspect { + + void around(Song song) : + call(public void Jukebox.play(Song)) + && args(song) { + PlayList.instance().enqueue(song); + } + +} + +aspect CreditsAspect { + + void around() : call(public void Jukebox.play(Song)) { + if(Credits.instance().enoughCredits()) { + System.out.println("Withdrawing credit."); + Credits.instance().withDraw(); + proceed(); + } else { + throw new InsufficientCreditsException(); + } + } + +} + +class Credits { + + private static final int INITIAL_CREDITS = 10; + + private static Credits instance; + + private int credits; + + private Credits() { + credits = INITIAL_CREDITS; + } + + public static Credits instance() { + if(instance==null ) { + instance = new Credits(); + } + return instance; + } + + public boolean enoughCredits() { + return credits > 0; + } + + public void withDraw() { + credits--; + } +} + +@SuppressWarnings("serial") +class InsufficientCreditsException extends RuntimeException { + + public InsufficientCreditsException() { + super(); + } + + public InsufficientCreditsException(String message, Throwable cause) { + super(message, cause); + } + + public InsufficientCreditsException(String message) { + super(message); + } + + /** + * @param cause + */ + public InsufficientCreditsException(Throwable cause) { + super(cause); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index fd2c8a329..f129c6f9f 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -405,6 +405,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testSuperCallInITD() { runTest("super call in ITD"); } + + public void testNoUnusedParameterWarningsForSyntheticAdviceArgs() { + runTest("no unused parameter warnings for synthetic advice args"); + } // helper methods..... public SyntheticRepository createRepos(File cpentry) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index fbec23663..28017a7dd 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -516,6 +516,11 @@ <message kind="error" line="14" text="The method print() is undefined for the type Object"/> </compile> </ajc-test> + + <ajc-test dir="bugs150" pr="109042" title="no unused parameter warnings for synthetic advice args"> + <compile files="pr109042.aj" options="-warn:+unusedArgument -warn:+unusedPrivate -warn:+unusedImport -1.5"> + </compile> + </ajc-test> <!-- ============================================================================ --> <!-- ============================================================================ --> |