IntelliJ compiler getting confused with uncompilable code in one liner comment
I have a class like the following:
/**
* From: JLS, 3.10.5
*
*/
public class JlsStringLiterals {
public static void main(String[] args) {
// String foo = "\u000a";
}
}
If you see clearly this is uncompilable:
String foo = "\u000a";
but it is commented, so it shouldn't cause a compiler error, anyway IntelliJ is warning the following:
Error:(9, 32) unclosed string literal
Is this a bug?
请先登录再写评论。
http://youtrack.jetbrains.com/issue/IDEABKL-89
I think the bug isn't the same, the following sentence
This doesn't:
I don't have the JLS in front of me to provide a citation, but it is my understanding that the unicode escapes are treated almost at a "pre-processor" level: i.e. it appears to the compiler as if there was a literal "\n" character exactly where the backslash escape sequence starts.
Thus, if one thinks of it as a preprocessor expansion, the commented code is:
Similarly, as you observed, just commenting out the "\u000a" sequence is not an error because it just puts a newline in the comment. It would match my expectations if you put some trailing characters after the "\u000a" and the compiler should equally barf.
For example:
HTH,
-- /v\atthew
You was right
// \u000a; hello I am extra textProduces an error, because unicode character has been proccesed before compilation, while
// \u000aDoesn't prompt any compiler error.
Anyway IntelliJ IDEA insn't prompting the error for the first example until compiling.
Thanks