Hi everybody,
I am trying to use @:strict to add an annotation (
JCIP's GuardedBy annotation) to a var field for Java. Ultimately, the annotation could be anything, but that is my specific use case.
I am able to do this for function fields and class type but @:strict seems to be ignored and stripped from the var field.
I created an extern for net.jcip.annotations.GuardedBy and applied it where applicable.
Example:
package com.company.annotations;
#if java
@:native("net.jcip.annotations.GuardedBy") extern class GuardedBy
{
public function value() : String;
}
#end
Usage:
@:strict(com.company.annotations.GuardedBy({ value :"lock" }))
private var toBeGuarded:String; // Does not retain the annotation!
@:strict(com.company.annotations.GuardedBy({ value :"lock" }))
public function doSomething() : Void
{
// Some code where lock is used
}
I was wondering if this is as designed or if there is a way to do this. I don't really see why @:strict would work for a class and functions but not vars.
Any help would be greatly appreciated.
Thanks!