
findbugs - issue #36
Impossible cast from javax.naming.CompositeName to com.sun.jndi.dns.DnsName in compareRange(int, int, Name) in DnsName.java
Bug report generated from FindBugs Impossible cast from javax.naming.CompositeName to com.sun.jndi.dns.DnsName in compareRange(int, int, Name)
In class com.sun.jndi.dns.DnsName In method compareRange(int, int, Name) Actual type javax.naming.CompositeName Expected com.sun.jndi.dns.DnsName Value loaded from n At DnsName.java:[line 390]
Relevant source code: 386: * greater than those of "n". 387: */ 388: private int compareRange(int beg, int end, Name n) { 389: if (n instanceof CompositeName) { 390: n = (DnsName) n; // force ClassCastException 391: } 392: // Loop through labels, starting with most significant. 393: int minSize = Math.min(end - beg, n.size()); 394: for (int i = 0; i < minSize; i++) {
Bug pattern explanation: This cast will always throw a ClassCastException. FindBugs tracks type information from instanceof checks, and also uses more precise information about the types of values returned from methods and loaded from fields. Thus, it may have more precise information that just the declared type of a variable, and can use this to determine that a cast will always throw an exception at runtime.
FindBugs issue identifier (do not modify or remove): b9c5e422ce21dc230c2d8195629f9ab1
Comment #1
Posted on Feb 24, 2010 by Happy Giraffe(No comment was entered for this change.)
Status: Invalid
Labels:
FindBugsGenerated