Hallo,
I have annotation class inside abstract class, like this:
abstract class RemoteK : Controller() {
...
@Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
annotation class RemoteMethod(val value: String = "", val contentType: String = "application/json")
...
}
when I am calling function with @RemoteMethod annotation form Kotlin, everyting is ok. The problem occurs when I am trying the same, but from Java. In this case I have to fill in explicitly default values (ie. value and contentType). And question is, how can I solve this.
Thank you
Note: Kotlin: kotlinc-jvm 1.1.51 (JRE 1.8.0_131-b11), Spring 3.2.16
Edit: typo
Ok, maybe I did not explain it properly, so a picture is worth a thousand words
@fvasco Thank you, but still looking for tip or advice.
I tried to decompile RemoteK$RemoteMethod.class and it seems ok, there are defaults:
@Target(allowedTargets={AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER})
@Retention(value=RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(value={ElementType.METHOD})
@Metadata(mv={1, 1, 7}, bv={1, 0, 2}, k=1, d1={"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u001b\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\b\u0087\u0002\u0018\u00002\u00020\u0001B\u0014\u0012\b\b\u0002\u0010\u0002\u001a\u00020\u0003\u0012\b\b\u0002\u0010\u0004\u001a\u00020\u0003R\u000e\u0010\u0004\u001a\u00020\u00038\u0006X\u0087\u0004\u00a2\u0006\u0000R\u000e\u0010\u0002\u001a\u00020\u00038\u0006X\u0087\u0004\u00a2\u0006\u0000\u00a8\u0006\u0005"}, d2={"Lorg/maite/mvc/controller/RemoteK$RemoteMethod;", "", "value", "", "contentType", "mvc"})
public static @interface RemoteK.RemoteMethod {
public String value() default "";
public String contentType() default "application/json";
}
working, when annotation class is outside …
@Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
@java.lang.annotation.Target(ElementType.METHOD)
annotation class RemoteMethod(val value: String = "", val contentType: String = "application/json")
abstract class RemoteK : Controller() { ... }