0

I have a an Xtend subclass PubnubMessage that inherits one field and has a constructor generated via active annotation. I can see the public constructor in the generated Java code, and it correctly accepts one argument for the field, but when I try to call that constructor from another Xtend class like so:

override successCallback(String channel, Object message)
{
    send(new PubnubMessage(message))
}

I get this error on the constructor call:

Invalid number of arguments. The constructor PubnubMessage() is not applicable for the arguments (Object)

Only the default no-arg constructor is visible, but there shouldn't even be a default constructor since an explicit one is generated. If I make a Java class with the same call:

new PubnubMessage(message);

There is no error. Here is the relevant code:

SocketMessage.xtend

@JsonData class SocketMessage
{
    Object message
}

SocketMessage.java (Xtend generated)

@JsonData
@SuppressWarnings("all")
public class SocketMessage {
  private final Object message;

@JsonCreator
public SocketMessage(@JsonProperty final Object message) {
  super();
  this.message = message;
}

PubnubMessage.xtend

@JsonData class PubnubMessage extends SocketMessage {}

PubnubMessage.java (Xtend generated)

@JsonData
@SuppressWarnings("all")
public class PubnubMessage extends SocketMessage {
  @JsonCreator  
  public PubnubMessage(@JsonProperty final Object message) {
    super(message);
}

I've left out the generated hashCode(), equals(), and toString(). Everything about this Java code seems fine to me, and like I said, I can successfully call it from other Java classes, but not from Xtend.

rmm
  • 119
  • 1
  • 5
  • Is the class that produces the error 'The constructor PubnubMessage() is not applicable for the arguments (Object)' in a project that has a dependency to the active annotation project? – Sebastian Zarnekow Jan 23 '15 at 07:34
  • If the active annotations project is `org.eclipse.xtend.lib.macro` then yes, it's included as a transitive Maven dependency. – rmm Jan 23 '15 at 15:34
  • Is it common to get bogus type errors from Eclipse when running the Xtend plugin? I've had several times now where there's a type mismatch or similar error in Eclipse, but the code still compiles just fine. If it keeps up I should be able to put more specifics on the Bugzilla eventually. – rmm Jan 23 '15 at 16:15
  • No, this is quite uncommon. Please file a bugzilla. The active annotations project is the project where you define your AA. My question aimed at another scenario. Do you have three projects (1 with JsonData, a second with PubnubMessage and a third with this code: 'send(new PubnubMessage(message))'), or only two projects (1 with JsonData and a second with PubnubMessage and the 'send' code)? – Sebastian Zarnekow Jan 24 '15 at 10:57

0 Answers0