JDK-4266845 : 3.10.5: Explicitly mention that string literals can't contain \u0022 (") characters
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: 1.2.2
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 1999-08-30
  • Updated: 2019-10-18
  • Resolved: 2011-07-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 rcFixed
Related Reports
Relates :  
Relates :  
Relates :  
Description

Name: wl91122			Date: 08/30/99


The JLS, section 3.10.5 does not mention that a String literal
can't contain \u0022 (") unicode characters.

The following code:

public class StringTest {
    {
        System.out.println("Hello\u0022World");
    }
}

leads to this error:

C:\DATA\java>javac StringTest.java
StringTest.java:3: ')' expected.
        System.out.println("Hello\u0022World");
                                       ^
StringTest.java:3: String not terminated at end of line.
        System.out.println("Hello\u0022World");
                                            ^
2 errors

(Can be solved by either changing the JLS or by changing the
compiler)
(Review ID: 94595) 
======================================================================

Comments
EVALUATION I think JLS 3.10.5 may as well list \u0022. As for listing all escapes, the escapes I might have expected javac to choke on - \u0000 (null) and \u001a (EOF) - compiled fine with 1.6.
13-07-2007

WORK AROUND Name: wl91122 Date: 08/30/99 use (generate) normal quotes ======================================================================
11-06-2004

EVALUATION Early processing of Unicode escape sequences is translating "\u0022" into '"'. Maybe this is a spec issue? I don't think that the compiler should be modified. iris.garcia@eng 1999-08-30 JLS 3.10.5 specifically mentions that unicode escapes are processed early, and specifically mentions linefeeds and returns, but not double quotes. Perhaps it would be helpful to add a sentence there to avoid confusion. Otherwise, I don't see that this bug report has much to say that hasn't been said in the spec. This is purely a matter of clarifying the exposition in a helpful way -- neither the language or the compiler needs any change here. william.maddox@Eng 1999-08-30 Right. Maybe we should list all escapes? gilad.bracha@eng 2001-06-28
30-08-1999