Java Reference
In-Depth Information
Applicability
Failing to consider integer promotions when dealing with floating-point and integer oper-
ands can result in loss of precision.
Bibliography
[Bloch 2005]
Puzzle 9, “Tweedledum”
Puzzle 31, “Ghost of Looper”
[Findbugs 2008]
“BIT: Bitwise OR of Signed Byte Value”
[JLS 2013]
§4.2.2, “Integer Operations”
§5.6, “Numeric Promotions”
§15.26.2, “Compound Assignment Operators”
[Long 2012]
NUM13-J. Avoid loss of precision when converting primitive integers to
floating-point
30. Enable compile-time type checking of variable arity parameter types
A variable arity (aka varargs ) method is a method that can take a variable number of ar-
guments. The method must contain at least one fixed argument. When processing a vari-
able arity method call, the Java compiler checks the types of all arguments, and all of
the variable actual arguments must match the variable formal argument type. However,
compile-time type checking is ineffective when Object or generic parameter types are
used [Bloch 2008]. The presence of initial parameters of specific types is irrelevant; the
compiler will remain unable to check Object or generic variable parameter types. Enable
strong compile-time type checking of variable arity methods by using the most specific
type possible for the method parameter.
 
Search WWH ::




Custom Search