...
Code Block | ||
---|---|---|
| ||
@SuppressWarnings("unchecked""unchecked") class Legacy { Set s = new HashSet(); public final void doLogic(int a,char c) { s.add(a); s.add(c); // Type unsafe operation, ignored } } |
...
Code Block | ||
---|---|---|
| ||
class Legacy { @SuppressWarnings("unchecked""unchecked") Set s = new HashSet(); public final void doLogic(int a,char c) { s.add(a); // Produces unchecked warning s.add(c); // Produces unchecked warning } } |
...
Code Block | ||
---|---|---|
| ||
@SuppressWarnings("unchecked""unchecked") public <T><T> T[] toArray(T[] a) { if (a.length << size) return (T[]) Arrays.copyOf(elements, size, a.getClass()); // Produces unchecked warning // ... } |
...
Code Block | ||
---|---|---|
| ||
// ... @SuppressWarnings("unchecked""unchecked") T[] result = (T[]) Arrays.copyOf(elements, size, a.getClass()); return result; // ... |
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
References
[Bloch 08] Item 24: "Eliminate unchecked warnings"
...
SCP03-J. Do not reuse names 05. Scope (SCP) 06. Integers (INT)