You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AroundAMain.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * Xerox/PARC initial implementation
  11. * ******************************************************************/
  12. import java.util.Arrays;
  13. import junit.framework.TestCase;
  14. import org.aspectj.runtime.internal.AroundClosure;
  15. import org.aspectj.util.Reflection;
  16. public class AroundAMain extends TestCase {
  17. public AroundAMain(String name) {
  18. super(name);
  19. }
  20. public static void main(String[] args) throws ClassNotFoundException {
  21. AroundClosure closure = new AroundClosure() {
  22. public Object run(Object[] args) throws Throwable {
  23. // System.out.println("run with: " + Arrays.asList(args));
  24. return new Integer(10);
  25. }
  26. };
  27. Object instance = Reflection.getStaticField(Class.forName("AroundA"),
  28. "ajc$perSingletonInstance");
  29. Reflection.invoke(Class.forName("AroundA"), instance, "ajc$around$AroundA$46",
  30. new Integer(10), new Boolean(true), closure);
  31. Reflection.invoke(Class.forName("AroundA"), instance, "ajc$around$AroundA$c5",
  32. "hello there", closure);
  33. Reflection.invoke(Class.forName("AroundA"), instance, "ajc$around$AroundA$150",
  34. new String[1], closure);
  35. }
  36. }