M
Markus Schaber
Hi,
Does anybody know a tool for java that does "real" templates (Not the
limited "Generics" that come with Java 1.5, but more like the Templates
in C++ are, so you have multiple specialised class files for differently
instantiated Templates to avoid all hidden run-time typecasts etc)?
We hope to get the following advantages over the java 1.5 Generics:
- Avoiding of runtime typechecks / casts altogether.
- Availability of the actual type parameters inside the template
instances (so you can e. G. do a
T[] blubb = new T[100];
which impossible with Generics.
- Signature-Based templating (we write a template that accepts all
objects that have a foobar() method, and only when using the template,
you have to ensure that your Class/Interface parameter you use for
instantiation has this foobar() method. This allows to use the same
template (in different places) for different types that have no common
parent providing the foobar() method.
- Runs in java 1.4 VMs, as it will take some time for 1.5 to get stable
enough.
- Possibility of templating primitive types (currently, this is not so
important for us, as the number of primitive types is rather limited and
won't expand in the near future .
Hints to both "preprocessor" and direct byte-code creating tools are
welcome, but we prefer open source tools (or at least tools which come
together with their source code and the license allows us to modify them
and fix bugs).
Thanks for your answers,
Markus Schaber
Does anybody know a tool for java that does "real" templates (Not the
limited "Generics" that come with Java 1.5, but more like the Templates
in C++ are, so you have multiple specialised class files for differently
instantiated Templates to avoid all hidden run-time typecasts etc)?
We hope to get the following advantages over the java 1.5 Generics:
- Avoiding of runtime typechecks / casts altogether.
- Availability of the actual type parameters inside the template
instances (so you can e. G. do a
T[] blubb = new T[100];
which impossible with Generics.
- Signature-Based templating (we write a template that accepts all
objects that have a foobar() method, and only when using the template,
you have to ensure that your Class/Interface parameter you use for
instantiation has this foobar() method. This allows to use the same
template (in different places) for different types that have no common
parent providing the foobar() method.
- Runs in java 1.4 VMs, as it will take some time for 1.5 to get stable
enough.
- Possibility of templating primitive types (currently, this is not so
important for us, as the number of primitive types is rather limited and
won't expand in the near future .
Hints to both "preprocessor" and direct byte-code creating tools are
welcome, but we prefer open source tools (or at least tools which come
together with their source code and the license allows us to modify them
and fix bugs).
Thanks for your answers,
Markus Schaber