Bug 40442 - Abstract class fails to invoke interface-defined method in 1.4 compliance mode.
Summary: Abstract class fails to invoke interface-defined method in 1.4 compliance mode.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1.2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-17 20:34 EDT by Patrick Linehan CLA
Modified: 2003-10-23 06:31 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Linehan CLA 2003-07-17 20:34:40 EDT
Platform: Eclipse 1.2.1 Build id: 200306271545.

Assuming the following interfaces/classes:

=============================================
public interface ObjectAlgorithm {
    void operate(Object pObject);
}
public interface DoubleAlgorithm extends ObjectAlgorithm {
    void operate(Double pDouble);
}
public abstract class AbstractDoubleAlgorithm implements DoubleAlgorithm {
    public void operate(Object pObject)
    {
        operate((Double)pObject);
    }
    // uncomment the next line for correct 1.4 operation
    // public abstract void operate(Double pDouble);
}
public class ConcreteDoubleAlgorithm extends AbstractDoubleAlgorithm {
    public void operate(Double pDouble)
    {
        System.out.println("method correctly invoked.");
    }
}
=============================================

The following line of code causes a stack overflow:

((ObjectAlgorithm)(new ConcreteDoubleAlgorithm())).operate(new Double(0));

Uncommenting the marked line above (for obvious reasons) clears up the problem.
 This problem seesm similar to bug 30856, but not quite the same.

Thanks for any help!
Comment 1 Philipe Mulet CLA 2003-07-18 07:29:37 EDT
Reproduced in 1.4 compliant mode in build 20030717.
Comment 2 Philipe Mulet CLA 2003-07-18 08:14:45 EDT
In 1.4 mode, we incorrectly bind message send in AbstractDoubleAlgorithm 

    public void operate(Object pObject)
    {
        operate((Double)pObject); ---> bound to #operate(Object) instead of 
#operate(Double)
    }
Comment 3 Philipe Mulet CLA 2003-07-18 08:44:26 EDT
In 1.4 mode, since AbstractDoubleAlgorithm doesn't get default abstract operate
(Double) for free, our lookup algorithm got fooled into thinking operate
(Object) was good enough, causing the recursion. It should still have 
considered inherited default abstracts with better match.

Scope.findMethod was wrong, misplaced closing curly brace.

Fixed, added compliance regression tests.
Comment 4 Philipe Mulet CLA 2003-07-18 09:07:27 EDT
Still have an issue on following variation, with extra signature operate(X):

public class X extends AbstractDoubleAlgorithm {
	
	public static void main(String[] args) {
		((ObjectAlgorithm)(new X())).operate(new Double(0));
	}
    public void operate(Double pDouble)
    {
        System.out.println("method correctly invoked.");
    }
}
abstract class AbstractDoubleAlgorithm implements DoubleAlgorithm {
    public void operate(Object pObject)
    {
        operate((Double)pObject);
    }
    public void operate(X x) {
    }
}
interface DoubleAlgorithm extends ObjectAlgorithm {
    void operate(Double pDouble);
}
interface ObjectAlgorithm {
    void operate(Object pObject);
}
Comment 5 Philipe Mulet CLA 2003-07-18 12:43:30 EDT
Fixed last scenario as well.
Comment 6 David Audel CLA 2003-08-28 04:48:12 EDT
Verified.
Comment 7 Philipe Mulet CLA 2003-09-04 12:43:46 EDT
Candidate for 2.1.2
Comment 8 Frederic Fusier CLA 2003-10-17 05:53:17 EDT
Verified with build 2.1.2 RC1
Comment 9 Jerome Lanneluc CLA 2003-10-23 06:31:43 EDT
Verified with build 2.1.2 RC2