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.

GenericType.java 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. public class GenericType<V extends Integer> {
  2. public GenericType(V value) {}
  3. public void foo() {}
  4. //
  5. // public void bar() {}
  6. protected V getValue() {
  7. return null;
  8. }
  9. public static void main(String[] args) {
  10. new GenericType<Integer>(null).foo();
  11. }
  12. }
  13. aspect SomeAspect {
  14. before(GenericType t): call(* GenericType.foo()) && target(t) {
  15. // Direct call to non-generic method works
  16. // t.bar();
  17. // Indirect call to non-generic method works
  18. // t.callNormalMethod();
  19. // Direct call to generic method works
  20. // t.getValue();
  21. // Indirect call to generic method produces a NoSuchMethodError
  22. t.callGenericMethod();
  23. }
  24. // private void GenericType.callNormalMethod() {
  25. // bar();
  26. // }
  27. private void GenericType.callGenericMethod() {
  28. getValue();
  29. }
  30. }