On Mon, 31 Oct 2022 20:50:49 GMT, Rémi Forax <fo...@openjdk.org> wrote:
>> 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 Will use List.of. I think use case is raw and caching should be left to the user. > src/java.base/share/classes/java/lang/template/TemplateRuntime.java line 132: > >> 130: return result; >> 131: } >> 132: for (Object value : st.values()) { > > I think that valueTypes() should return the types of the values not the > dynamic classes of the values. > Here there is no type information so it should be Object for all values. > > It has also the nice property that the return type of the accessors returned > by valueAccessors are the same as valueTypes() which is i believe more > coherent. Changing ------------- PR: https://git.openjdk.org/jdk/pull/10889