I have a code like
private List<xyzClass> fieldName;
public List<xyzClass> getFieldName(){
return fieldName;
}
public void setFieldName(List<xyzClass> abc){
this.fieldName= abc;
}
but when compiled to java byte code, the parameteres are missing as below:
private List fieldName;
public List getFieldName(){
return fieldName;
}
public void setFieldName(List abc){
this.fieldName= abc;
}
This is creating issue with SOAP as not able to typecast to xyzClass Exception.
From Eclipse I see the class file created is good but when I tried command line javac or maven the class file is missing these parameters.
This is as a result of type erasure. Basically java uses the generics to confirm that you are not violating the type constraints during compile time. All the generics are then removed and replaced with the highest class in the inheritance hierarchy. This will default to Object but if you say <T extends ParentClass> (for example) the T generics will be replaced with ParentClass.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With