Bug 26195 - JDT compiler doesn't report recursive constructor invocation
Summary: JDT compiler doesn't report recursive constructor invocation
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-13 15:42 EST by Craig Miskell CLA
Modified: 2002-12-17 10:28 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.