diff options
author | Andy Clement <aclement@gopivotal.com> | 2014-09-30 11:08:50 -0700 |
---|---|---|
committer | Andy Clement <aclement@gopivotal.com> | 2014-09-30 11:08:50 -0700 |
commit | 102173fc11fc6648ed8f2283d3c5ad535e412c73 (patch) | |
tree | 41f4d30666dcbaf76353d34e7f94d6e92c10da73 /tests/bugs183/445395/ControlFlowDriver.java | |
parent | e26c781374ac7afeaf8859baf4fc55d7dfb7b3a7 (diff) | |
download | aspectj-102173fc11fc6648ed8f2283d3c5ad535e412c73.tar.gz aspectj-102173fc11fc6648ed8f2283d3c5ad535e412c73.zip |
445395: invokedynamic in around advice
Diffstat (limited to 'tests/bugs183/445395/ControlFlowDriver.java')
-rwxr-xr-x | tests/bugs183/445395/ControlFlowDriver.java | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/bugs183/445395/ControlFlowDriver.java b/tests/bugs183/445395/ControlFlowDriver.java new file mode 100755 index 000000000..318362c79 --- /dev/null +++ b/tests/bugs183/445395/ControlFlowDriver.java @@ -0,0 +1,75 @@ +//package org.acmsl.pocs.lambdafor; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.function.Function; + +public class ControlFlowDriver { + + private static boolean m__bUsed = false; + + public ControlFlowDriver() { + } + + protected static void immutableSetUsed(final boolean used) { + m__bUsed = used; + } + + protected static void setUsed(final boolean used) { + immutableSetUsed(used); + } + + public static boolean isUsed() { + return m__bUsed; + } + + public <C extends Collection<I>, I, R> Collection<R> forloop(final C items, + final Function<I, R> lambda) { + setUsed(true); + + final List<R> result = new ArrayList<R>(items.size()); + + final List<I> list = new ArrayList<I>(items); + + int position = -1; + + while (true) { + ControlFlowCommand command = waitForCommand(); + + switch (command) { + case NEXT: + position++; + break; + case PREVIOUS: + position++; + break; + case RELOAD: + break; + default: + break; + } + + if (position < 0) { + position = 0; + } else if (position > list.size() - 1) { + break; + } + + result.set(position, lambda.apply(list.get(position))); + } + + return result; + } + + protected ControlFlowCommand waitForCommand() { + try { + Thread.sleep(1000); + } catch (final InterruptedException interruptedException) { + // whatever + } + + return ControlFlowCommand.NEXT; + } + +} |