This is the CSR for the implementation of JEP-430 String Templates (Preview)
Summary
Enhance the Java programming language with string templates, which are similar to string literals but contain embedded expressions. A string template is interpreted at run time by replacing each expression with the result of evaluating that expression, possibly after further validation and transformation. This is a preview language feature and API.
Problem
Injecting values into strings using the Java + string operator can often lead to unreadable code and code that is prone to errors and/or injection attacks.
Solution
JEP-430 String Templates (Preview) introduces string templates which will allow users to inject values into a String in situ. The use of string templates versus string interpolation allows for a richer feature that, in addition to composition, allows validation and non-string result transformations.
Specification
The following APIs were added:
- java.base/java/lang/StringTemplate.html
- java.base/java/lang/StringTemplate.Processor.html
- java.base/java/lang/StringTemplate.Processor.Linkage.html
- java.base/java/lang/runtime/TemplateRuntime.html
- java.base/java/util/FormatProcessor.html
- jdk.compiler/com/sun/source/tree/StringTemplateTree.html
The static field STR
declared in java.lang.StringTemplate
is imported automatically into every Java program, as if the declaration import static java.lang.StringTemplate.STR;
appeared at the beginning of each compilation unit immediately after any package declaration. (In JDK releases where the String Templates feature is in preview, the automatic importing occurs only if preview features are enabled.)
The static field RAW
which is also declared in java.lang.StringTemplate
is not imported automatically imported every Java program.
The following APIs were modified:
- csr of
-
JDK-8285932 Implementation of JEP 430 String Templates (Preview)
-
- Resolved
-
- relates to
-
JDK-8296302 JEP 430: JLS Changes for String Templates (Preview)
-
- Closed
-