Eclipse QuickFix problem
Encountered a strange problem while working on Eclipse [In the latest integration build - Version: 3.1.0 Build id: 200412081200]
I wrote a small snippet of code -
if(getContentSpec().equals("Test"))
return true;
The method getContentSpec was not implemented in the class; so it gave a compilation error. I took the QuickFix route and asked Eclipse to generate the stub for me. To my surprise, it generated the following code -
/**
* @return
*/
private AbstractList getContentSpec() {
// TODO Auto-generated method stub
return null;
}
I didn't really expect the method to return a String - but I at least expected it to return an Object. But it ended by returning an AbstractList!!!!! This was s t r a n g e!
To recreate the problem, before I submit the bug, I created a simple class -
private Object getContentSpec() {
// TODO Auto-generated method stub
return null;
}
Well, thats what I wanted in the original code ... why did it behave differently here?
I finally tracked it down to ... guess what? ... an import statement.
Try QuickFix on the following code
import java.util.ArrayList;
import java.util.List;
public class QuickFixEquals {
public boolean hasChildren() {
return (getContentSpec().equals("Test"));
}
public List<String> getList() {
return new ArrayList<String>();
}
}
Apply QuickFix, and lo, you get -
private AbstractList<E> getContentSpec() {
// TODO Auto-generated method stub
return null;
}
Here's the link to the QuickFix Bug.
Encountered a strange problem while working on Eclipse [In the latest integration build - Version: 3.1.0 Build id: 200412081200]
I wrote a small snippet of code -
if(getContentSpec().equals("Test"))
return true;
The method getContentSpec was not implemented in the class; so it gave a compilation error. I took the QuickFix route and asked Eclipse to generate the stub for me. To my surprise, it generated the following code -
/**
* @return
*/
private AbstractList
// TODO Auto-generated method stub
return null;
}
I didn't really expect the method to return a String - but I at least expected it to return an Object. But it ended by returning an AbstractList!!!!! This was s t r a n g e!
To recreate the problem, before I submit the bug, I created a simple class -
public class QuickFixEquals {Applied QuickFix ... and the code generated was
public boolean hasChildren() {
return (getContentSpec().equals("Test"));
}
}
private Object getContentSpec() {
// TODO Auto-generated method stub
return null;
}
Well, thats what I wanted in the original code ... why did it behave differently here?
I finally tracked it down to ... guess what? ... an import statement.
Try QuickFix on the following code
import java.util.List;It will generate
public class QuickFixEquals {
public boolean hasChildren() {
return (getContentSpec().equals("Test"));
}
}
private List getContentSpec() {Better yet, try this code
// TODO Auto-generated method stub
return null;
}
import java.util.ArrayList;
import java.util.List;
public class QuickFixEquals {
public boolean hasChildren() {
return (getContentSpec().equals("Test"));
}
public List<String> getList() {
return new ArrayList<String>();
}
}
Apply QuickFix, and lo, you get -
private AbstractList<E> getContentSpec() {
// TODO Auto-generated method stub
return null;
}
Here's the link to the QuickFix Bug.
0 Comments:
Post a Comment
<< Home