Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Refactoring a Class Without Static Imports
Refactoring a Class Without Static Imports [message #798625] Tue, 14 February 2012 17:53 Go to next message
Eclipse UserFriend
I am refactoring a class containing public static final fields. Eclipse is proposing to update the references to the moved class using static imports. How do I prevent this and have Eclipse use a standard import?


Don't want this:
import static MyClass.MY_STATIC_FIELD;


Want this:
import MyClass;
Re: Refactoring a Class Without Static Imports [message #798783 is a reply to message #798625] Tue, 14 February 2012 23:17 Go to previous messageGo to next message
Eclipse UserFriend
Try to put that MyClass into particular package then import that package then you can access it.
Re: Refactoring a Class Without Static Imports [message #798829 is a reply to message #798783] Wed, 15 February 2012 01:00 Go to previous messageGo to next message
Eclipse UserFriend
Sorry I wasn't clear earlier. The class is already in a package. It's not that I can't access it. I am using the Move refactoring and Eclipse is Updating References to the class, but it is using static imports instead of regular imports in those classes.


Don't want this:
import static com.pkg.MyClass.MY_STATIC_FIELD;


Want this:
import com.pkg.MyClass;
Re: Refactoring a Class Without Static Imports [message #798843 is a reply to message #798829] Wed, 15 February 2012 01:18 Go to previous messageGo to next message
Eclipse UserFriend
you can directly write the classpath i.e import com.pkg.MyClass; it will not warn or give any error for doing this thing.
and more over static fields can be accessed directly using classname.staticfieldname rather than objectname.staticfieldname, because static field are only one for a class and common for all the object of that class i.e only one copy of static field is shared by all the objects .
Static field is the part of Class not part of object
Re: Refactoring a Class Without Static Imports [message #798901 is a reply to message #798843] Wed, 15 February 2012 02:59 Go to previous message
Eclipse UserFriend
I am not able to reproduce this. I get only the standard import!
Previous Topic:Issue with deployment of EJB project
Next Topic:Cannot be resolved to a type
Goto Forum:
  


Current Time: Tue May 20 03:21:20 EDT 2025

Powered by FUDForum. Page generated in 0.07245 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top