Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 22:53 Go to next message
Wayne Dremen is currently offline Wayne DremenFriend
Messages: 2
Registered: February 2012
Junior Member
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] Wed, 15 February 2012 04:17 Go to previous messageGo to next message
Abhijeet Shankargouda is currently offline Abhijeet ShankargoudaFriend
Messages: 40
Registered: January 2012
Member
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 06:00 Go to previous messageGo to next message
Wayne Dremen is currently offline Wayne DremenFriend
Messages: 2
Registered: February 2012
Junior Member
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 06:18 Go to previous messageGo to next message
Abhijeet Shankargouda is currently offline Abhijeet ShankargoudaFriend
Messages: 40
Registered: January 2012
Member
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 07:59 Go to previous message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
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: Fri Mar 29 15:10:17 GMT 2024

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

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

Back to the top