Effective type parametrization in Java
Péter Attila Soha, Norbert Pataki · AIP conference proceedings · 2019
Type parametrization is an essential construct in modern programming languages, Java offers generics, C++ offers templates for highly reusable code. The mechanism between these constructs differs and affects usage and runtime performance, as well. Java uses type erasure, C++ deals with instantiations.In this paper, we argue for a new approach in Java which is similar to C++ template construct. The proposed method contains a template syntax and a developed tool which can instantiate Java templates and generates Java source code. The templates have advantages related to special template parameters that are not supported by generics. On the other hand, the instantiations have to be processed at compilation time, but the runtime performance of the code is improved. We measure how the Java templates speed-up the execution.