I’m confused. The following code has errors (“…” represents elided code):
int byteOrder = ...;
switch (byteOrder)
{
case HDF5Constants.H5T_ORDER_BE:
return ByteOrder.BIG_ENDIAN;
...
}
The error is on the case statement and Eclipse complains “case expressions must be constant expressions”. I looked in the source file for this and it has a long list of lines like this:
final public static int H5T_ORDER_BE = H5.J2C( JH5T_ORDER_BE );
I thought you could use final public static int constants as cases in a switch statement. Am I wrong???
From what you’ve shown
H5T_ORDER_BEis not a compile-time constant (which it needs to be) – it’s evaluated at runtime during the initialisation of the class. If it evaluated to a constant such as123(rather than what appears to be a static method call) then the compiler wouldn’t complain.