Added content to the template of Ver 1.2 and added additional casting to the OXM from field/value creation
mechanism as when compiling it outside of eclipse javac cannot cast from a generic type to the real type.
diff --git a/java_gen/templates/of_factory_class.java b/java_gen/templates/of_factory_class.java
index 503c492..adf5df1 100644
--- a/java_gen/templates/of_factory_class.java
+++ b/java_gen/templates/of_factory_class.java
@@ -97,7 +97,8 @@
//:: method_name = oxm_name.replace('OFOxm', '')
//:: method_name = method_name[0].lower() + method_name[1:]
case ${value}:
- return (OFOxm<F>)${method_name}((${type_name})value);
+ //:: # The cast to Object is done to avoid some javac bug that in some versions cannot handle cast from generic type to other types but Object
+ return (OFOxm<F>)((Object)${method_name}((${type_name})((Object)value)));
//:: #endfor
default:
return null;
@@ -115,7 +116,8 @@
//:: method_name = oxm_name.replace('OFOxm', '')
//:: method_name = method_name[0].lower() + method_name[1:]
case ${value}:
- return (OFOxm<F>)${method_name}((${type_name})value, (${type_name})mask);
+ //:: # The cast to Object is done to avoid some javac bug that in some versions cannot handle cast from generic type to other types but Object
+ return (OFOxm<F>)((Object)${method_name}((${type_name})((Object)value), (${type_name})((Object)mask)));
//:: #endfor
default:
return null;
@@ -133,7 +135,8 @@
//:: method_name = oxm_name.replace('OFOxm', '')
//:: method_name = method_name[0].lower() + method_name[1:]
case ${value}:
- return (OFOxm<F>)${method_name}((${type_name})(masked.getValue()), (${type_name})(masked.getMask()));
+ //:: # The cast to Object is done to avoid some javac bug that in some versions cannot handle cast from generic type to other types but Object
+ return (OFOxm<F>)((Object)${method_name}((${type_name})((Object)(masked.getValue())), (${type_name})((Object)(masked.getMask()))));
//:: #endfor
default:
return null;