File name influences JastAdd code generation
Idriss has encountered a bug in JastAdd, see attachment. He gets a compilation error when trying to define a collection attribute on an interface. But if he changes the file name from s.jrag to r.jrag, the compilation gets through. He has narrowed down the problem to a very small example.
I tried it on my computer and I got the same compilation error for s.jrag, and also got the error if I changed the filename to r.jrag. But if I changed the filename to z.jrag, the compilation error disappeared.
I guess this problem is related to side effects in aspect weaving as discussed in https://bitbucket.org/jastadd/jastadd2/issues/268/remove-side-effects-in-aspect-weaving
Comments (6)
-
-
There is some kind of order dependency between the
public interface I {}
line inTest.jrag
and the collection declaration ins.jrag
.To fix this, the interface declaration should be added to the AST declarations before processing collection attributes. I’m not sure if this is easy to fix nor not.
-
A hacky solution to fix this particular example without changing JastAdd is to just add
public interface I {}
before the collection attribute (having 2 copies of the interface declaration):public interface I { } coll Collection<String> I.set() [new HashSet<String>()] with add;
-
I think that Idriss has a solution to this problem so that collection attributes are handled similar to other kinds of attributes (not weaved during parsing). But he hasn’t created a PR yet.
-
Here is a single-file test for this bug.
import java.util.*; aspect Test { coll Collection<String> I.set(); public interface I { } A implements I; }
-
- changed status to resolved
- Log in to comment
I tried running JastAdd on the files in the provided zip file and I get a JastAdd error when “s.jrag” is placed before “Test.jrag” on the JastAdd command line (regardless of what I rename the
s.jrag
file to):