To find out the DFA answer:
I think you turned off the "left side" rule at the second token point in JLS 8.2.3.2. In your initialization, myField is on the left. In your call to add, this is on the right side. The code here is implicit:
boolean result = myField.add('test')
You do not evaluate the result, but the compiler still acts as if it were. This is why your initialization passes when your add () call fails.
As to why this is so, I have no idea. This may well be for the convenience of JVM developers, as far as I know.
rtperson
source share