@Optional annotation not found

617 views Asked by At

I'm using com4j to generate Java type definitions from a COM type library. The generated code contains a lot of uses of the @Optional annotation, for example:

@DISPID(14) //= 0xe. The runtime will prefer the VTID if present
@VTID(23)
void mail(
    java.lang.String sendTo,
    @Optional @DefaultValue("") java.lang.String sendCc,
    @Optional @DefaultValue("0") int option,
    @Optional @DefaultValue("") java.lang.String subject,
    @Optional @DefaultValue("") java.lang.String comment);

However @Optional is not resolving and I'm unable to find where it's defined.

2

There are 2 answers

0
Fergal On BEST ANSWER

Found the problem. I was using an older version of com4j that didn't yet support the @Optional annotation. Updated to the latest and it resolved.

0
James Raitsev On

You can always create it yourself:

public @interface Optional {

}