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.

ErasureMatching.aj 862B

123456789101112131415161718192021222324252627282930313233
  1. import java.util.List;
  2. public aspect ErasureMatching {
  3. declare warning : execution(static Object Utils.first(List)) : "static generic method match";
  4. declare warning : execution(Number Utils.max(Number, Number)) : "instance generic method match";
  5. declare warning : execution(public List G.getAllDataItems()) : "method in generic type match";
  6. declare warning : set(Object G.myData) : "field in generic type match";
  7. }
  8. class Utils {
  9. /** static generic method */
  10. static <T> T first(List<T> ts) { return null; }
  11. /** instance generic method */
  12. <T extends Number> T max(T t1, T t2) { return t1; }
  13. }
  14. class G<T> {
  15. // field with parameterized type
  16. T myData = null;
  17. // method with parameterized return type
  18. public List<T> getAllDataItems() { return null; }
  19. }