aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Clement <aclement@vmware.com>2012-03-19 11:59:49 -0700
committerAndy Clement <aclement@vmware.com>2012-03-19 11:59:49 -0700
commit3632df8d96f210577c2d86c0b184737a59db23aa (patch)
tree76b7ffda8985500e1f9e04125be780818dcf1e17
parentf259133f31dc96885b1a800ea25d195757ee44a2 (diff)
downloadaspectj-3632df8d96f210577c2d86c0b184737a59db23aa.tar.gz
aspectj-3632df8d96f210577c2d86c0b184737a59db23aa.zip
testdir
-rw-r--r--tests/indy/one/Asp.java6
-rw-r--r--tests/indy/one/Code1.classbin0 -> 1528 bytes
-rw-r--r--tests/indy/one/Code1.java21
-rw-r--r--tests/indy/one/Generator.classbin0 -> 3757 bytes
-rw-r--r--tests/indy/one/Generator.java101
-rw-r--r--tests/indy/one/Invoker.classbin0 -> 388 bytes
-rw-r--r--tests/indy/one/indy.jarbin0 -> 409 bytes
-rw-r--r--tests/indy/two/Asp.java6
-rw-r--r--tests/indy/two/Code1.java21
-rw-r--r--tests/indy/two/Generator.java101
-rw-r--r--tests/indy/two/indy.jarbin0 -> 409 bytes
11 files changed, 256 insertions, 0 deletions
diff --git a/tests/indy/one/Asp.java b/tests/indy/one/Asp.java
new file mode 100644
index 000000000..a7a41ef7b
--- /dev/null
+++ b/tests/indy/one/Asp.java
@@ -0,0 +1,6 @@
+aspect Aspect {
+
+ before(): staticinitialization(!Aspect) {
+ System.out.println(thisJoinPointStaticPart);
+ }
+}
diff --git a/tests/indy/one/Code1.class b/tests/indy/one/Code1.class
new file mode 100644
index 000000000..5e5c2ba99
--- /dev/null
+++ b/tests/indy/one/Code1.class
Binary files differ
diff --git a/tests/indy/one/Code1.java b/tests/indy/one/Code1.java
new file mode 100644
index 000000000..2899340d2
--- /dev/null
+++ b/tests/indy/one/Code1.java
@@ -0,0 +1,21 @@
+import java.lang.invoke.CallSite;
+import java.lang.invoke.ConstantCallSite;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+public class Code1 {
+
+ // Called via invokedynamic from a generated class
+ private static void foo() {
+ System.out.println("foo() is running");
+ }
+
+ public static CallSite bootstrap(MethodHandles.Lookup caller, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+ MethodHandles.Lookup lookup = MethodHandles.lookup();
+ Class<?> thisClass = lookup.lookupClass();
+ MethodHandle mh = lookup.findStatic(thisClass, name, type);
+ return new ConstantCallSite(mh);//mh.asType(type));
+ }
+
+} \ No newline at end of file
diff --git a/tests/indy/one/Generator.class b/tests/indy/one/Generator.class
new file mode 100644
index 000000000..d4a793b23
--- /dev/null
+++ b/tests/indy/one/Generator.class
Binary files differ
diff --git a/tests/indy/one/Generator.java b/tests/indy/one/Generator.java
new file mode 100644
index 000000000..77f1e1807
--- /dev/null
+++ b/tests/indy/one/Generator.java
@@ -0,0 +1,101 @@
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.invoke.CallSite;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+import org.objectweb.asm.*;
+
+public class Generator implements Opcodes {
+
+ private String generatedRunnerTypename,linkClassName,dynMethodName,dynMethodDescriptor;
+ private byte[] bytes;
+
+ /**
+ * Main entry point generates a default thing, in this case a class called 'Invoker' that will use the bootstrap method on Code1 to run 'foo()'
+ * @param args
+ * @throws Throwable
+ */
+ public static void main(String[] args) throws Throwable {
+ Generator g = new Generator("Invoker","Code1","foo","()V");
+ g.dump();
+ }
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+
+ public Generator(String generatedRunnerTypename, String linkClassName, String dynMethodName, String dynMethodDescriptor) {
+ this.generatedRunnerTypename = generatedRunnerTypename;
+ this.linkClassName = linkClassName;
+ this.dynMethodName = dynMethodName;
+ this.dynMethodDescriptor = dynMethodDescriptor;
+ this.bytes = generateClass();
+ }
+
+ public void dump() {
+ try {
+ FileOutputStream fos
+ = new FileOutputStream(new File(generatedRunnerTypename+".class"));
+ fos.write(bytes);
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public byte[] generateClass() {
+ ClassWriter cw = new ClassWriter(0);
+ cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, generatedRunnerTypename, null, "java/lang/Object", null);
+ createConstructor(cw);
+ createMain(cw);
+ cw.visitEnd();
+ return cw.toByteArray();
+ }
+
+ private void createMain(ClassWriter cw) {
+ MethodVisitor mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
+ mv.visitCode();
+ MethodType mt = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class,
+ MethodType.class);
+ Handle bootstrap = new Handle(Opcodes.H_INVOKESTATIC, this.linkClassName, "bootstrap",
+ mt.toMethodDescriptorString());
+ int maxStackSize = 0;//addMethodParameters(mv);
+ mv.visitInvokeDynamicInsn(dynMethodName, dynMethodDescriptor, bootstrap);
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(maxStackSize, 1);
+ mv.visitEnd();
+ }
+
+// public byte[] dump(String dynamicInvokerClassName, String dynamicLinkageClassName, String bootstrapMethodName, String targetMethodDescriptor)
+// throws Exception {
+// ClassWriter cw = new ClassWriter(0);
+// cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, dynamicInvokerClassName, null, "java/lang/Object", null);
+// createConstructor(cw);
+// createMain(dynamicLinkageClassName, bootstrapMethodName, targetMethodDescriptor, cw);
+// cw.visitEnd();
+// return cw.toByteArray();
+// }
+
+
+
+// protected int addMethodParameters(MethodVisitor mv) {
+// return 0;
+// }
+
+
+ private void createConstructor(ClassWriter cw) {
+ MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+} \ No newline at end of file
diff --git a/tests/indy/one/Invoker.class b/tests/indy/one/Invoker.class
new file mode 100644
index 000000000..6f651583d
--- /dev/null
+++ b/tests/indy/one/Invoker.class
Binary files differ
diff --git a/tests/indy/one/indy.jar b/tests/indy/one/indy.jar
new file mode 100644
index 000000000..d6ec561f4
--- /dev/null
+++ b/tests/indy/one/indy.jar
Binary files differ
diff --git a/tests/indy/two/Asp.java b/tests/indy/two/Asp.java
new file mode 100644
index 000000000..329822c9d
--- /dev/null
+++ b/tests/indy/two/Asp.java
@@ -0,0 +1,6 @@
+aspect Aspect {
+
+ before(): execution(* *.*(..)) && !within(Aspect) {
+ System.out.println(thisJoinPointStaticPart);
+ }
+}
diff --git a/tests/indy/two/Code1.java b/tests/indy/two/Code1.java
new file mode 100644
index 000000000..2899340d2
--- /dev/null
+++ b/tests/indy/two/Code1.java
@@ -0,0 +1,21 @@
+import java.lang.invoke.CallSite;
+import java.lang.invoke.ConstantCallSite;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+public class Code1 {
+
+ // Called via invokedynamic from a generated class
+ private static void foo() {
+ System.out.println("foo() is running");
+ }
+
+ public static CallSite bootstrap(MethodHandles.Lookup caller, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+ MethodHandles.Lookup lookup = MethodHandles.lookup();
+ Class<?> thisClass = lookup.lookupClass();
+ MethodHandle mh = lookup.findStatic(thisClass, name, type);
+ return new ConstantCallSite(mh);//mh.asType(type));
+ }
+
+} \ No newline at end of file
diff --git a/tests/indy/two/Generator.java b/tests/indy/two/Generator.java
new file mode 100644
index 000000000..77f1e1807
--- /dev/null
+++ b/tests/indy/two/Generator.java
@@ -0,0 +1,101 @@
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.invoke.CallSite;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+import org.objectweb.asm.*;
+
+public class Generator implements Opcodes {
+
+ private String generatedRunnerTypename,linkClassName,dynMethodName,dynMethodDescriptor;
+ private byte[] bytes;
+
+ /**
+ * Main entry point generates a default thing, in this case a class called 'Invoker' that will use the bootstrap method on Code1 to run 'foo()'
+ * @param args
+ * @throws Throwable
+ */
+ public static void main(String[] args) throws Throwable {
+ Generator g = new Generator("Invoker","Code1","foo","()V");
+ g.dump();
+ }
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+
+ public Generator(String generatedRunnerTypename, String linkClassName, String dynMethodName, String dynMethodDescriptor) {
+ this.generatedRunnerTypename = generatedRunnerTypename;
+ this.linkClassName = linkClassName;
+ this.dynMethodName = dynMethodName;
+ this.dynMethodDescriptor = dynMethodDescriptor;
+ this.bytes = generateClass();
+ }
+
+ public void dump() {
+ try {
+ FileOutputStream fos
+ = new FileOutputStream(new File(generatedRunnerTypename+".class"));
+ fos.write(bytes);
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public byte[] generateClass() {
+ ClassWriter cw = new ClassWriter(0);
+ cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, generatedRunnerTypename, null, "java/lang/Object", null);
+ createConstructor(cw);
+ createMain(cw);
+ cw.visitEnd();
+ return cw.toByteArray();
+ }
+
+ private void createMain(ClassWriter cw) {
+ MethodVisitor mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
+ mv.visitCode();
+ MethodType mt = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class,
+ MethodType.class);
+ Handle bootstrap = new Handle(Opcodes.H_INVOKESTATIC, this.linkClassName, "bootstrap",
+ mt.toMethodDescriptorString());
+ int maxStackSize = 0;//addMethodParameters(mv);
+ mv.visitInvokeDynamicInsn(dynMethodName, dynMethodDescriptor, bootstrap);
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(maxStackSize, 1);
+ mv.visitEnd();
+ }
+
+// public byte[] dump(String dynamicInvokerClassName, String dynamicLinkageClassName, String bootstrapMethodName, String targetMethodDescriptor)
+// throws Exception {
+// ClassWriter cw = new ClassWriter(0);
+// cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, dynamicInvokerClassName, null, "java/lang/Object", null);
+// createConstructor(cw);
+// createMain(dynamicLinkageClassName, bootstrapMethodName, targetMethodDescriptor, cw);
+// cw.visitEnd();
+// return cw.toByteArray();
+// }
+
+
+
+// protected int addMethodParameters(MethodVisitor mv) {
+// return 0;
+// }
+
+
+ private void createConstructor(ClassWriter cw) {
+ MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+} \ No newline at end of file
diff --git a/tests/indy/two/indy.jar b/tests/indy/two/indy.jar
new file mode 100644
index 000000000..d6ec561f4
--- /dev/null
+++ b/tests/indy/two/indy.jar
Binary files differ