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.

AccBridgeMethods.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*******************************************************************************
  2. * Copyright (c) 2004 IBM
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Andy Clement - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.systemtest.ajc150;
  12. import java.io.File;
  13. import junit.framework.Test;
  14. import org.aspectj.testing.XMLBasedAjcTestCase;
  15. /**
  16. * <b>These tests check binary weaving of code compiled with the 1.5 compiler. If you need to rebuild
  17. * the class files then you will have to run tests/java5/bridgeMethods/build.xml.</b>
  18. *
  19. * <p>Bridge methods are generated when a type extends or implements a parameterized class or interface and
  20. * type erasure changes the signature of any inherited method.
  21. *
  22. * <p>They impact AspectJ in two ways:
  23. * <ol>
  24. * <li>They exist as a method execution join point, and their 'body' exists as a set of new join points
  25. * (although their body is normally coded simply to delegate to the method they are bridging too).
  26. * <li> They create a potential call join point where a call can be made to the bridge method.
  27. * </ol>
  28. *
  29. * <p>The principal things we have to do are avoid weaving their body and ignore their existence
  30. * as a method execution join point. Their existence as a potential target for a call join point are
  31. * more complicated. Although they exist in the code, a 1.5 compiler will prevent a call to them with
  32. * an error like this:
  33. *
  34. * M.java:3: compareTo(Number) in Number cannot be applied to (java.lang.String)
  35. * new Number(5).compareTo("abc");
  36. *
  37. * Our problem is that a Java 1.4 or earlier compiler will allow you to write calls to this bridge method
  38. * and it will let them through.
  39. */
  40. public class AccBridgeMethods extends org.aspectj.testing.XMLBasedAjcTestCase {
  41. public static Test suite() {
  42. return XMLBasedAjcTestCase.loadSuite(AccBridgeMethods.class);
  43. }
  44. protected File getSpecFile() {
  45. return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml");
  46. }
  47. /**
  48. * AspectX attempts to weave call and execution of the method for which a 'bridge method' is also created.
  49. * If the test works then only two weaving messages come out. If it fails then usually 4 messages come out
  50. * and we have incorrectly woven the bridge method (the 3rd message is execution of the bridge method and
  51. * the 4th message is the call within the bridge method to the real method).
  52. */
  53. public void test001_bridgeMethodIgnored() {
  54. runTest("Ignore bridge methods");
  55. }
  56. }