Syntax error when declaring generic methods in aspects?

Issue #183 resolved
Ismail Badawi created an issue

I have a simple grammar in hello.ast:

Program;

And this aspect in hello.jadd:

aspect Generics {
    public <T> void Program.print(T t) {
      System.out.println(t);
    }
 }

With jastadd 2.1.6, this gives me

Error at hello.jadd:2:3: syntax error

I wanted to use a (static) generic method in a project and I ended up declaring it in a regular Java class and calling it from the aspect. Is there some way to declare generic methods in an aspect, or are they not supported?

Comments (3)

  1. Jesper Mattsson

    There is a workaround, but it is somewhat cumbersome:

    aspect Generics {
        public class Program {
            public <T> void print(T t) {
              System.out.println(t);
            }
        }
    }
    
  2. Jesper Öqvist

    This is an error in the JastAdd2 parser. The parser originally only supported Java 1.4, and support for Java 1.5 features have been gradually added but is lacking in some areas still such as in this case. The best fix would be to make the parser an extension of our JastAddJ parser which is much better maintained. In the meantime I will try to fix this in the current parser.

  3. Log in to comment