Tim Cooke wrote:Giving an example of when you saw this warning might give a bit of context for your question. Otherwise the best I can offer is "it depends".
Jesse Silverman wrote:Hi Tim:
I am thinking the OP may have used the word "warning" somewhat carelessly.
I definitely have seen this as an actual warning in other languages I need to work in, including when it was like "warning -- this very bad thing you should never do just happened". The code compiled (depending on settings) and you were playing the slot machines to find out what would happen at runtime (also often dependent upon compile settings).
But as far as I recall, this message is always associated with a compile failure in Java since way back.
There are warning class messages, usually about type-unsafe operations or deprecated usages, I don't think this was ever one of those.
Andrzej Zahorski wrote:You can send me your github account with Purple Mooseage ;)
Yees, it is a compile time error.
Tim Cooke wrote:. . . curious that you report only seeing a warning . . .
The javac tool doesn't execute any code, nor does it reason what the result of System#nanoTime() is. It leaves all that sort of thing to runtime.
Jesse Silverman wrote:. . . very strict rules specified in the JLS about what the compiler is or is not allowed . . .
It would appear it does; that section starts,
Yesterday, I wrote:. . . Maybe this JLS (=Java® Language Specification) section gives you the details . . .
Every local variable declared by a statement (§14.4.2, §14.14.1, §14.14.2, §14.20.3) and every blank final field (§4.12.4, §184.108.40.206) must have a definitely assigned value when any access of its value occurs. . . . or a compile-time error occurs.