Summary: | unused private method false positive? | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Rodrigo Peretti <rodrigo> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED INVALID | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 2.1 | ||
Target Milestone: | 3.0 M1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Rodrigo Peretti
2003-04-02 11:57:33 EST
I cannot reproduce on your testcase. Also note I had to tweak the following code to get it to compile. private B getB_in_X() { return new B(){}; // added anonymous } OK, I might have missed something (I haven't really tried that on Eclipse - sorry). Here is a more concrete example: import java.io.ByteArrayInputStream; import java.io.InputStream; import org.eclipse.core.resources.IStorage; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IPersistableElement; import org.eclipse.ui.IStorageEditorInput; public class X { public X() { getEditorInput(); } /** * Returns an empty storage. */ private IStorage getStorage() { return new IStorage() { public InputStream getContents() throws CoreException { return new ByteArrayInputStream("".getBytes()); } public IPath getFullPath() { return null; } public String getName() { return null; } public boolean isReadOnly() { return false; } public Object getAdapter(Class adapter) { return null; } }; } private IEditorInput getEditorInput() { return new IStorageEditorInput() { public IStorage getStorage() throws CoreException { return getStorage(); } public boolean exists() { return false; } public ImageDescriptor getImageDescriptor() { return null; } public String getName() { return null; } public IPersistableElement getPersistable() { return null; } public String getToolTipText() { return null; } public Object getAdapter(Class adapter) { return null; } }; } } X.getStorage() is indeed unused, since the invocation buried in: public IStorage getStorage() throws CoreException { return getStorage(); } is recursively calling itself. If you want to target X.getStorage(), then it should use 'X.this.getStorage();'. Is it ok or am I missing something obvious ? oooppsss... It seems that I was missing something obvious. :-) The funny thing is that it works during runtime. Or you sure it doesn't perform an infinite recursion ? Yes, I'm sure. I was using J9 - not sure if that makes a difference. I do not have the code in my workspace anymore but I can get that back if you want. Wait... I might be wrong. I might have never tried running the code like that. Now I recall that I did have the X.this.getStorage() in my code to get rid of the warning. You're right. Please close this bug and don't tell anyone about it!!! ;-) Closing |