I have a constant byte array, for instance
static final byte myArray = "something".getBytes();
is the expression new String(myArray) evaluated at compile time ?
No. It's evaluated at runtime.
You can have it evaluated at compile time if you use:
static final String myString = "something";
I don't see why it wouldn't be evaluated at compile time.
This is described in JLS Sec 15.9.4:
Every time the [class instance creation] expression is evaluated, a fresh object is created.
But aside from that, it's not a constant expression if you use a
byte as a parameter: even though you can't assign a new value to the
static final array reference, you can still change the array elements. This should be of concern particularly as the
myArray field is (or at least appears) non-private.
String is immutable, a
static final String is a constant. However, this doesn't mean that it could be evaluated at compile time if you use a string, because of the JLS quote above.