JDK-6304521 : Request extension of Java language to support annotated strings
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-08-01
  • Updated: 2010-04-04
  • Resolved: 2006-11-17
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
Some other languages (e.g. Perl, C#) have support for annotated or verbatim strings. A double quoted string immediately prefixed with an at-sign, thus:

@""

does not escape any characters so allowing verbatim text blocks to be defined easily.

JUSTIFICATION :
Advantages:

(1) Very useful for handling large amounts of text
(2) Has been used successfully in other languages so well known
(3) Should be quite easy to implement
(4) Easy to learn, remember and use
(5) Should not break any existing syntactic elements

Disadvatntages:

(1) One extra syntax element to learn and remember
(2) Would require a language and VM change which affects backwards compatibility

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Can quote literal strings including CRs, \s and other common characters without escaping.
ACTUAL -
Not possible in current implementations without using escapes. Clumsy and error prone for large text blocks.

CUSTOMER SUBMITTED WORKAROUND :
Use escapes.

Comments
EVALUATION One of numerous requests for improved handling of literals.
17-11-2006