United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6454579 : Add treble quotation marks like """ to Java

Details
Type:
Enhancement
Submit Date:
2006-07-31
Status:
Closed
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2006-11-17
Component:
specification
OS:
windows_xp
Sub-Component:
language
CPU:
x86
Priority:
P5
Resolution:
Duplicate
Affected Versions:
6
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description
A DESCRIPTION OF THE REQUEST :
When we program in Java and Other language, such as Groovy and JavaScript, we have to write \' , \n, \" and + many times. For example,
/*
Without treble quotation marks supported, Java program embeded with Groovy code
*/
GroovyShell shell = new GroovyShell(binding);

 Object value = shell.evaluate(
  "println 'Hello World!';\n" +
  "x = 123;\n" +
  "for (i in 0..9) {\n" +
  "	x += i;\n" +
  "	println x;\n" +
  "}\n" +
  "return foo = foo * 10;"
 );

If Java supports treble quotation marks, we can program like following code. The Java code become much more concise than before.
/*
With treble quotation marks supported, Java program embeded with Groovy code
*/
GroovyShell shell = new GroovyShell(binding);

 Object value = shell.evaluate(
   """
   println 'Hello World!';
   x = 123;
   for (i in 0..9) {
   	 x += i;
   	 println x;
   }
   return foo = foo * 10;
  """
 );


JUSTIFICATION :
The enhancement will make Java more concise and more readable.
Especially, JDK6.0 will support JavaScript code embeded in Java code, the enhancement will play an important role in Java programming in future.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
/*
With treble quotation marks supported, Java program embeded with Groovy code
*/
GroovyShell shell = new GroovyShell(binding);

 Object value = shell.evaluate(
   """
   println 'Hello World!';
   x = 123;
   for (i in 0..9) {
   	 x += i;
   	 println x;
   }
   return foo = foo * 10;
  """
 );

ACTUAL -
/*
Without treble quotation marks supported, Java program embeded with Groovy code
*/
GroovyShell shell = new GroovyShell(binding);

 Object value = shell.evaluate(
  "println 'Hello World!';\n" +
  "x = 123;\n" +
  "for (i in 0..9) {\n" +
  "	x += i;\n" +
  "	println x;\n" +
  "}\n" +
  "return foo = foo * 10;"
 );



---------- BEGIN SOURCE ----------
// EmbedTest .java
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import org.codehaus.groovy.control.CompilationFailedException;

public class EmbedTest {
  public static void main(String[] args) {
    Binding binding = new Binding();
    binding.setVariable("foo", new Integer(2));
    GroovyShell shell = new GroovyShell(binding);
    try {
      Object value = shell.evaluate(
        "println 'Hello World!';\n" +
        "x = 123;\n" +
        "for (i in 0..9) {\n" +
        "	x += i;\n" +
        "	println x;\n" +
        "}\n" +
        "return foo = foo * 10;"
      );
    } catch (CompilationFailedException e) {
      e.printStackTrace();
    }
  }
}

  
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Not found :-(

                                    

Comments



Hardware and Software, Engineered to Work Together