In a utility class we have the declaration/assignment:

public static final Pattern justWhitespace = Pattern.compile("^\\s*$");

and when this is being used it is returning null.
There were various functions above this declaration that call a function below that uses the justWhitespace variable. Investigation found that moving this declaration/assignment above all the functions to the top of the class gave a populated justWhitespace value.

Not sure why the compiler does not manage this, perhaps its the statics and finals in play? Possibly a quirk in Java 11?
Can anyone advise. Thanks