In Java why this error: ‘attribute value must be constant’?

This

public final static long TESTNG_TEST_TIMEOUT = 300000;

is a constant variable, a type of constant expression.

This

public final static long TESTNG_TEST_TIMEOUT = TimeUnit.MINUTES.toMillis(5);

is not.

Annotation members expect constant expressions (and a few other things like enums and Class literals).

Leave a Comment