[java] UnnecessaryCastRule: verify clone is not flagged

This commit is contained in:
Andreas Dangel
2020-05-23 18:41:37 +02:00
parent 473a806cb7
commit 7feb805f96

View File

@ -120,6 +120,19 @@ public class UnnecessaryCastSample {
Map<String, ?> map = new HashMap<>();
String dataFromMap = (String) map.get("foo");
}
}
]]></code>
</test-code>
<test-code>
<description>Avoid clone false-positive</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class UnnecessaryCastSample {
public void localVars() {
List<String> strings = new ArrayList<>();
List<String> copy = (List<String>) strings.clone();
}
}
]]></code>
</test-code>