Static ending in scala annotation

I have a java class with constants:

public abstract class TestGroup { public static final String UNIT = "unit"; ... } 

in java I can use it in annotation:

 @Test(groups=TestGroup.UNIT) public class Unit1Test {...} 

but when I do it in Scala (2.10.4):

 @Test(groups=Array(TestGroup.UNIT)) class Unit2Test{...} 

I get this compilation error:

  error: annotation argument needs to be a constant; found: TestGroup.UNIT [ERROR] @Test(groups=Array(TestGroup.UNIT)) [ERROR] ^ 

how can I use constant annotations with constants in cross-compiled Scala?

Note: previous question How to add a constant and a literal in annotations? doesn't help as it shows Scala constants in Scala code. I want to use Java constants from Scala code.

+6
source share

Source: https://habr.com/ru/post/970250/


All Articles