Community
Participate
Working Groups
Assume you have code like this: public class Test { public void doSomething() { String text = "This is a block comment end: */"; } } Now insert a block comment begin '/*' at the start of the line containing the variable declaration. The java editor then shows a block comment from the beginning of the line to the '*/' in the string, and a compiler error for the trailing '";' ("String literal is not properly closed by a double-quote"). Even if you now put a '*/' after the semicolon on the same or next line (e.g. using Source->Add Block Comment in the first place), still the compiler error persists. Note: this compiler problem also exists in Sun's JDK 1.4.2_03
This behavior is imposed by the language. If you break the string in between * and /, it will be fine. public class Test { public void doSomething() { String text = "This is a block comment end: *"+"/"; } }
You're right, the JLS states as much (http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#48125). Of course it's sad that the weak expressivness of the recursive-descent grammar imposes this - in my eyes - useless constraint upon the language.