diff options
author | Andy Clement <aclement@pivotal.io> | 2017-09-21 10:48:59 -0700 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2017-09-21 10:48:59 -0700 |
commit | 26712118bad08e60c66237e6aa2cfbd6f275cbbe (patch) | |
tree | 64531f485c94c9f6e7f1acb8506bf51cc8343cf1 /tests/bugs1810 | |
parent | 39b70af69b0b086f82da8ac032de5e5a5e0cdc45 (diff) | |
parent | 6d6738cfece6328027916681e67e54225531db38 (diff) | |
download | aspectj-26712118bad08e60c66237e6aa2cfbd6f275cbbe.tar.gz aspectj-26712118bad08e60c66237e6aa2cfbd6f275cbbe.zip |
Bring Java9 branch in line with 1.8.11 progress
Diffstat (limited to 'tests/bugs1810')
-rw-r--r-- | tests/bugs1810/500035/Code.java | 30 | ||||
-rw-r--r-- | tests/bugs1810/500035/Code2.java | 30 | ||||
-rw-r--r-- | tests/bugs1810/500035/Code3.java | 76 | ||||
-rw-r--r-- | tests/bugs1810/500035/Code4.java | 35 | ||||
-rw-r--r-- | tests/bugs1810/501656/ApplicationException.java | 9 | ||||
-rw-r--r-- | tests/bugs1810/501656/ApplicationExceptionHandler.java | 17 | ||||
-rw-r--r-- | tests/bugs1810/501656/Code.java | 4 | ||||
-rw-r--r-- | tests/bugs1810/501656/out/com/myapp/ApplicationException.class | bin | 0 -> 499 bytes | |||
-rw-r--r-- | tests/bugs1810/502807/TestCollectors.java | 36 | ||||
-rw-r--r-- | tests/bugs1810/508661/A_yes.java | 8 | ||||
-rw-r--r-- | tests/bugs1810/508661/B_no.java | 7 | ||||
-rw-r--r-- | tests/bugs1810/508661/CacheMethodResult.java | 4 | ||||
-rw-r--r-- | tests/bugs1810/508661/CacheMethodResultAspect.java | 10 | ||||
-rw-r--r-- | tests/bugs1810/508661/Run.java | 6 | ||||
-rw-r--r-- | tests/bugs1810/508661/aop.xml | 10 | ||||
-rw-r--r-- | tests/bugs1810/ambig/Code.java | 8 | ||||
-rw-r--r-- | tests/bugs1810/ambig/X.java | 13 |
17 files changed, 303 insertions, 0 deletions
diff --git a/tests/bugs1810/500035/Code.java b/tests/bugs1810/500035/Code.java new file mode 100644 index 000000000..58e738da4 --- /dev/null +++ b/tests/bugs1810/500035/Code.java @@ -0,0 +1,30 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code { + + @Around(value = "args(regex, replacement) && target(targetObject) " + + "&& call(public String String.replaceFirst(String, String)) " +//, argNames = "proceedingJoinPoint,targetObject,regex,replacement,thisJoinPoint" +) + public String replaceFirstAspect(ProceedingJoinPoint proceedingJoinPoint, String targetObject, String regex, String replacement) throws Throwable { +System.out.println("targetObject = "+targetObject); +System.out.println("regex = "+regex); +System.out.println("replacement = "+replacement); + String returnObject = (String) proceedingJoinPoint.proceed(new Object[]{ targetObject, regex, replacement}); + return returnObject; + } + + + public static void main(String []argv) { + new Code().run(); + } + + public void run() { + String s = "hello"; + s = s.replaceFirst("l","7"); + System.out.println(s); + } + +} diff --git a/tests/bugs1810/500035/Code2.java b/tests/bugs1810/500035/Code2.java new file mode 100644 index 000000000..23eddce7e --- /dev/null +++ b/tests/bugs1810/500035/Code2.java @@ -0,0 +1,30 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code2 { + + @Around(value = "args(regex, replacement) && target(targetObject) " + + "&& call(public String String.replaceFirst(String, String)) && this(c)" +//, argNames = "proceedingJoinPoint,targetObject,regex,replacement,thisJoinPoint" +) + public String replaceFirstAspect(ProceedingJoinPoint proceedingJoinPoint, Code2 c, String targetObject, String regex, String replacement) throws Throwable { +System.out.println("targetObject = "+targetObject); +System.out.println("regex = "+regex); +System.out.println("replacement = "+replacement); + String returnObject = (String) proceedingJoinPoint.proceed(new Object[]{ c, targetObject, regex, replacement}); + return returnObject; + } + + + public static void main(String []argv) { + new Code2().run(); + } + + public void run() { + String s = "hello"; + s = s.replaceFirst("l","8"); + System.out.println(s); + } + +} diff --git a/tests/bugs1810/500035/Code3.java b/tests/bugs1810/500035/Code3.java new file mode 100644 index 000000000..48f672991 --- /dev/null +++ b/tests/bugs1810/500035/Code3.java @@ -0,0 +1,76 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code3 { + + @Around(value = "args(s) && target(targeto) && call(* Foo.run1(String))") + public void first(ProceedingJoinPoint proceedingJoinPoint, Foo targeto, String s) throws Throwable { + System.out.println("first: binding target, just passing everything through: target=Foo(1)"); + proceedingJoinPoint.proceed(new Object[]{ targeto, s}); + } + + @Around(value = "args(s) && this(thiso) && target(targeto) && call(* run2(String))") + public void second(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, Foo targeto, String s) throws Throwable { + System.out.println("second: binding this and target, just passing everything through: this=Foo(0) target=Foo(1)"); + proceedingJoinPoint.proceed(new Object[]{ thiso, targeto, s}); + } + + @Around(value = "args(s) && this(thiso) && call(* run3(String))") + public void third(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, String s) throws Throwable { + System.out.println("third: binding this, just passing everything through: this=Foo(0)"); + proceedingJoinPoint.proceed(new Object[]{ thiso, s}); + } + + @Around(value = "args(s) && this(thiso) && call(* run4(String))") + public void fourth(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, String s) throws Throwable { + System.out.println("fourth: binding this, switching from Foo(0) to Foo(3)"); + proceedingJoinPoint.proceed(new Object[]{ new Foo(3), s}); + } + + @Around(value = "args(s) && target(targeto) && call(* run5(String))") + public void fifth(ProceedingJoinPoint proceedingJoinPoint, Foo targeto, String s) throws Throwable { + System.out.println("fifth: binding target, switching from Foo(1) to Foo(4)"); + proceedingJoinPoint.proceed(new Object[]{ new Foo(4), s}); + } + + @Around(value = "args(s) && this(thiso) && target(targeto) && call(* run6(String))") + public void sixth(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, Foo targeto, String s) throws Throwable { + System.out.println("sixth: binding this and target, switching them around (before this=Foo(0) target=Foo(1))"); + proceedingJoinPoint.proceed(new Object[]{ targeto, thiso, s}); + } + + public static void main(String []argv) { + new Foo(0).execute1(); + new Foo(0).execute2(); + new Foo(0).execute3(); + new Foo(0).execute4(); + new Foo(0).execute5(); + new Foo(0).execute6(); + } +} + +class Foo { + int i; + public Foo(int i) { + this.i = i; + } + + public void execute1() { new Foo(1).run1("abc"); } + public void execute2() { new Foo(1).run2("abc"); } + public void execute3() { new Foo(1).run3("abc"); } + public void execute4() { new Foo(1).run4("abc"); } + public void execute5() { new Foo(1).run5("abc"); } + public void execute6() { new Foo(1).run6("abc"); } + + public void run1(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run2(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run3(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run4(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run5(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run6(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + + public String toString() { + return ("Foo(i="+i+")"); + } +} diff --git a/tests/bugs1810/500035/Code4.java b/tests/bugs1810/500035/Code4.java new file mode 100644 index 000000000..176ce2011 --- /dev/null +++ b/tests/bugs1810/500035/Code4.java @@ -0,0 +1,35 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +public aspect Code4 { + + void around(Foo targeto, String s): call(* Foo.run(String)) && args(s) && target(targeto) { + System.out.println("first: binding target, just passing everything through"); + proceed(targeto, s); + } + + public static void main(String []argv) { + new Foo(0).execute(); + } +} + +class Foo { + int i; + public Foo(int i) { + this.i = i; + } + + public void execute() { + Foo f1 = new Foo(1); + Foo f2 = new Foo(2); + f1.run("abc"); + } + + public void run(String s) { + System.out.println("Executing run("+s+") on "+this.toString()); + } + + public String toString() { + return ("Foo(i="+i+")"); + } +} diff --git a/tests/bugs1810/501656/ApplicationException.java b/tests/bugs1810/501656/ApplicationException.java new file mode 100644 index 000000000..5392eeaef --- /dev/null +++ b/tests/bugs1810/501656/ApplicationException.java @@ -0,0 +1,9 @@ +package com.myapp; + +public class ApplicationException extends Exception { + private static final long serialVersionUID = 1L; + + public ApplicationException(String message) { + super(message); + } +} diff --git a/tests/bugs1810/501656/ApplicationExceptionHandler.java b/tests/bugs1810/501656/ApplicationExceptionHandler.java new file mode 100644 index 000000000..bd96e1c27 --- /dev/null +++ b/tests/bugs1810/501656/ApplicationExceptionHandler.java @@ -0,0 +1,17 @@ +package com.myapp.aspect; + +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; + +import com.myapp.ApplicationException; + +@Aspect +public abstract class ApplicationExceptionHandler<EX extends ApplicationException> { + @AfterThrowing( + pointcut = "execution(* com.myapp.*.facade.*.*(..))", + throwing = "exception" +, argNames="exception" + ) + public abstract void handleFacadeException(EX exception); + +} diff --git a/tests/bugs1810/501656/Code.java b/tests/bugs1810/501656/Code.java new file mode 100644 index 000000000..c8e603a9e --- /dev/null +++ b/tests/bugs1810/501656/Code.java @@ -0,0 +1,4 @@ +public abstract class Code { + public void m(String str1) {} + public abstract void m2(String str2); +} diff --git a/tests/bugs1810/501656/out/com/myapp/ApplicationException.class b/tests/bugs1810/501656/out/com/myapp/ApplicationException.class Binary files differnew file mode 100644 index 000000000..fbbbdda19 --- /dev/null +++ b/tests/bugs1810/501656/out/com/myapp/ApplicationException.class diff --git a/tests/bugs1810/502807/TestCollectors.java b/tests/bugs1810/502807/TestCollectors.java new file mode 100644 index 000000000..323fb76ce --- /dev/null +++ b/tests/bugs1810/502807/TestCollectors.java @@ -0,0 +1,36 @@ +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +public class TestCollectors { + Set<Integer> ids; + + public TestCollectors(Set<Inner> inners) { + ids = inners.stream().collect(Collectors.toList(Inner::getId)); +// ids = inners.stream().map(Inner::getId).collect(Collectors.toSet()); + } + + public static void main() { + Set<Inner> inners = new HashSet<>(); + inners.add(new Inner(1, "a")); + inners.add(new Inner(1, "a")); + + new TestCollectors(inners); + } + + + public static class Inner { + private int id; + private String name; + + public Inner(int id, String name) { + this.id = id; + this.name = name; + } + + public int getId() { return id; } + + public String getName() { return name; } + } +} + diff --git a/tests/bugs1810/508661/A_yes.java b/tests/bugs1810/508661/A_yes.java new file mode 100644 index 000000000..9920f069a --- /dev/null +++ b/tests/bugs1810/508661/A_yes.java @@ -0,0 +1,8 @@ +public class A_yes { + @CacheMethodResult + public void m() { + System.out.println("A_yes.m()"); + Class[] itfs = A_yes.class.getInterfaces(); + System.out.println("A_yes has interface? "+((itfs==null||itfs.length==0)?"no":itfs[0].getName())); + } +} diff --git a/tests/bugs1810/508661/B_no.java b/tests/bugs1810/508661/B_no.java new file mode 100644 index 000000000..e65d63377 --- /dev/null +++ b/tests/bugs1810/508661/B_no.java @@ -0,0 +1,7 @@ +class B_no { + public void m() { + System.out.println("B_no.m()"); + Class[] itfs = B_no.class.getInterfaces(); + System.out.println("B_no has interface? "+((itfs==null||itfs.length==0)?"no":itfs[0].getName())); + } +} diff --git a/tests/bugs1810/508661/CacheMethodResult.java b/tests/bugs1810/508661/CacheMethodResult.java new file mode 100644 index 000000000..fd919bd5b --- /dev/null +++ b/tests/bugs1810/508661/CacheMethodResult.java @@ -0,0 +1,4 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface CacheMethodResult {} diff --git a/tests/bugs1810/508661/CacheMethodResultAspect.java b/tests/bugs1810/508661/CacheMethodResultAspect.java new file mode 100644 index 000000000..d7626a917 --- /dev/null +++ b/tests/bugs1810/508661/CacheMethodResultAspect.java @@ -0,0 +1,10 @@ +aspect CacheMethodResultAspect perthis(cache()) { + + pointcut cache() : execution(@CacheMethodResult * *.*(..)); + + Object around() : cache() { + System.out.println("around: "+thisJoinPointStaticPart.getSignature()); + return proceed(); + } +} + diff --git a/tests/bugs1810/508661/Run.java b/tests/bugs1810/508661/Run.java new file mode 100644 index 000000000..176e5a499 --- /dev/null +++ b/tests/bugs1810/508661/Run.java @@ -0,0 +1,6 @@ +public class Run { + public static void main(String []argv) { + new A_yes().m(); + new B_no().m(); + } +} diff --git a/tests/bugs1810/508661/aop.xml b/tests/bugs1810/508661/aop.xml new file mode 100644 index 000000000..5b89e6614 --- /dev/null +++ b/tests/bugs1810/508661/aop.xml @@ -0,0 +1,10 @@ +<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"> +<aspectj> + <weaver> + </weaver> + + <aspects> + <aspect name="CacheMethodResultAspect" /> + </aspects> + +</aspectj> diff --git a/tests/bugs1810/ambig/Code.java b/tests/bugs1810/ambig/Code.java new file mode 100644 index 000000000..dab8d6f09 --- /dev/null +++ b/tests/bugs1810/ambig/Code.java @@ -0,0 +1,8 @@ +import java.util.List; + +aspect F { void A.xx(List<String> x) { xx(null);this.xx(null);};} +class A {} +class B extends A { void xx(List<String> x) { xx(null); this.xx(null); super.xx(null); }} +class C implements D { public void xx(List<String> x) { xx(null); new A().xx(null); new B().xx(null); }} +interface D { void xx(List<String> x); } +class E { void foo() { new B().xx(null); new A() {}.xx(null); } } diff --git a/tests/bugs1810/ambig/X.java b/tests/bugs1810/ambig/X.java new file mode 100644 index 000000000..6f0a73d97 --- /dev/null +++ b/tests/bugs1810/ambig/X.java @@ -0,0 +1,13 @@ +import java.util.List; + +aspect F { + void A.xx(List<String> x) { } +} +class A { + //void xx(List<String> x) {} +} +class E { + void foo() { + new A() {}.xx(null); + } +} |