<i18n dev> RFR: JDK-8285932 Implementation of JEP-430 String Templates (Preview) [v7]
Rémi Forax
forax at openjdk.org
Mon Oct 31 20:54:33 UTC 2022
On Mon, 31 Oct 2022 20:11:34 GMT, Jim Laskey <jlaskey at openjdk.org> wrote:
>> 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](http://openjdk.java.net/jeps/12).
>
> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>
> Add @SafeVarargs declarations
src/java.base/share/classes/java/lang/template/TemplateRuntime.java line 119:
> 117: Class<?> tsClass = st.getClass();
> 118: if (tsClass.isSynthetic()) {
> 119: try {
I do not know if this code is worth of optimizing but the way to avoid to recompute the List<Class<?>> each time is to use a java.lang.ClassValue and store the classes inside an unmodifiable List. (Field[] -> Class<?>[] -> List<Class<?>>) The last leg can be done just by calling List.of(), there is no need for an ArrayList here
-------------
PR: https://git.openjdk.org/jdk/pull/10889
More information about the i18n-dev
mailing list