Hy,

I've found some bad code (in fact it's "only" bad naming of constants) 
that severly confuses IDEA when used in combination with other arcane 
technices... 

I had a class (not written by me!) that had a public static final int 
named SomeThing. Additionally it used a class named 
com.example.SomeThing.

SomeThing (the class) was only used once to cast the return value of 
one function to SomeThing before passing it on to another function.

The Problem (apart from bad maintainability of this code) is that IDEA 
shows the import of com.example.SomeThing as unused, 'cause it thinks 
the SomeThing-cast refers to the static final.

Here's some example code that shows the behaviour:


import java.util.Collections;
import java.util.Collection;
import java.util.Enumeration;

public class Test {
    private static final int Collection = 0;
    public static void main(String[] args) throws Exception
    {
        Enumeration e = Collections.enumeration((Collection)      
                getObjectThatIsReallyACollection());
    }

    private static Object getObjectThatIsReallyACollection()
          throws Exception
    {
        return Class.forName("java.util.ArrayList").newInstance();
    }
}

the problem is not urgent, as for me the real sollution is giving the 
static final a correct name (SOME_THING) so the problem is solved for 
me.

regards
Joachim Sauer

-- 
Anyone who gets in between me and my morning coffee should be insecure. 
[sic]
                                                             - RFC 2324
_______________________________________________
Eap-bugs mailing list
[EMAIL PROTECTED]
http://lists.jetbrains.com/mailman/listinfo/eap-bugs

Reply via email to