[
https://issues.apache.org/jira/browse/OFBIZ-3102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12771529#action_12771529
]
Marc Morin commented on OFBIZ-3102:
-----------------------------------
Generally, we should strive to have no @SuppressWarnings("unchecked") in the
code at all. Ideally, only in 1 or two spots in UtilGenerics where you just
can't get around Java generics issues like the following:
List<MyClass> mymethod(List<Input> list) {
return (List<MyClass>) list;
}
The compiler cannot check the generic type at compile time and will not check
at run-time. It will generate a compiler warning. To now have it show up, you
can @SuppressWarnings("unchecked") on the method.
For the normal case in the code, we want to encourage the proper use of
generics. An example, which is the bulk of the type of code we're modifying is
a hold over of pre-Java 1.5 (I think that's when Generics were introduced).
Map myMethod(Map values) {
Map newMap = new FastMap(values);
newMap.put("this", "that");
return newMap;
}
This will result in warnings related to the generics. You can make them go
away with a big old @SuppressWarnings("unchecked") on the method, but that
isn't as desirable as
Map<String, String> myMethod(Map<String, String> values) {
Map<String, String> newMap = new FastMap<String, String)(values);
newMap.put("this", "that");
return newMap;
}
> framework - base
> ----------------
>
> Key: OFBIZ-3102
> URL: https://issues.apache.org/jira/browse/OFBIZ-3102
> Project: OFBiz
> Issue Type: Sub-task
> Components: framework
> Affects Versions: SVN trunk
> Reporter: Bob Morley
> Attachments: OFBIZ-3102 base warning.patch
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.