Bug 26195

Summary: JDT compiler doesn't report recursive constructor invocation
Product: [Eclipse Project] JDT Reporter: Craig Miskell <cmiskell>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0.1   
Target Milestone: 2.1 M4   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:

Description Craig Miskell CLA 2002-11-13 15:42:40 EST
The JDT doesn't report a recursive constructor invocation, whereas javac does. 
I'm couldn't find any reference in the java language specs saying such a
definition is truly illegal, but it's clearly not a good thing to do.  I think
that JDT should report it as an error (it's never going to work :-))
Comment 1 Philipe Mulet CLA 2002-11-14 05:43:20 EST
We have to report these errors. 
On following test case, I get 2 errors:

Kind	Status	Priority	Description	Resource	In Folder
	Location
Error			Recursive constructor invocation RC()	RC.java	Crap/src
	line 4 in RC.RC(int)
Error			Recursive constructor invocation RC(int)	RC.java
	Crap/src	line 7 in RC.RC()

public class RC {
	RC(int i){
		this();
	}
	RC(){
		this(0);
	}
}

Can you provide a test case reproducing what you see ? 
Comment 2 Craig Miskell CLA 2002-11-14 16:22:53 EST
Sure can. I should have initially, but I thought it was a simple case (obviously
it's not, and I apologize for assuming you guys had missed something simple).

It appears to be when the constructor would recurse to itself, but there's
another constructor with the same number of args or something like that.  

Test case below:

public class TestEclipseBug { 

	private Object root;
	private Number count;

    public TestEclipseBug(Class rootClass) {
    	this(rootClass, null);
    }

   public TestEclipseBug(Class rootClass, Number count) {
    	this.root=rootClass;
    	this.count=count;
    }  

	public TestEclipseBug(String objEntityName) {
		this(objEntityName);
	}
	
	public TestEclipseBug(String aName, Number count) {
    	this.root=aName;
    	this.count=count;
   	}
	
}
Comment 3 Philipe Mulet CLA 2002-11-14 17:25:22 EST
Indeed, we have a problem. 3rd constructor should be blamed.
Comment 4 Philipe Mulet CLA 2002-11-21 07:51:49 EST
Fixed in latest
Comment 5 David Audel CLA 2002-12-17 10:28:51 EST
Verified.