Bug 211755

Summary: [push down] Push down method changes program behavior
Product: [Eclipse Project] JDT Reporter: Torbjörn Ekman <Torbjorn.Ekman>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, deepakazad, gsoares, markus.kell.r, martinae, stephan.herrmann, xiemaisi
Version: 3.3.1Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug

Description Torbjörn Ekman CLA 2007-12-03 09:50:22 EST
Build ID: M20071023-1652

Steps To Reproduce:
Pushing down the method y() from X to SubX succeeds but does not preserve the behaviour.

class SuperX {
	void x() { System.out.println("SuperX: x()"); }
}
class X extends SuperX {
	void x() { System.out.println("X: x()"); }
	void y() {
		super.x();
	}
}
class SubX extends X {
	public static void main(String[] args) {
		new SubX().y();
	}

}


More information:
Comment 1 Torbjörn Ekman CLA 2007-12-03 10:02:41 EST
Here is another example that does not preserve behaviour. Pushing down x() from X to SubX changes the printed message from 1 to 2.

class X {
	void x() { System.out.println(y); }
	public int y = 1;
}
class SubX extends X {
	public int y = 2;
	public static void main(String[] args) {
		new SubX().x();
	}
}
Comment 2 Deepak Azad CLA 2010-06-15 15:55:28 EDT
*** Bug 211860 has been marked as a duplicate of this bug. ***
Comment 3 Deepak Azad CLA 2010-06-15 15:56:14 EDT
*** Bug 316828 has been marked as a duplicate of this bug. ***
Comment 4 Deepak Azad CLA 2010-06-15 15:59:55 EDT
Though you can argue that user wants to change the program behavior, a warning on the preview page would be nice.
Comment 5 Dani Megert CLA 2010-06-16 03:08:11 EDT
>Though you can argue that user wants to change the program behavior, a warning
>on the preview page would be nice.
The point (and main difference to a quick assist) is that it must be preserving. In the past we started to lift that a little bit but in all those cases we switch to the preview page and show a warning.
Comment 6 Markus Keller CLA 2011-09-05 12:21:30 EDT
*** Bug 356684 has been marked as a duplicate of this bug. ***
Comment 7 Markus Keller CLA 2011-09-05 12:23:11 EDT
*** Bug 356698 has been marked as a duplicate of this bug. ***
Comment 8 Raksha Vasisht CLA 2011-10-24 13:03:48 EDT
*** Bug 355324 has been marked as a duplicate of this bug. ***
Comment 9 Eclipse Genie CLA 2018-10-01 05:37:00 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 10 Stephan Herrmann CLA 2018-10-01 14:53:59 EDT
Statements that could cause changes in behaviour:

- super calls (comment 0)

- access to a field that is hidden in the subclass (comment 1)

See also the duplicates for additional relevant situations.

Anyone up to the task to implement corresponding warnings?
Comment 11 Eclipse Genie CLA 2020-10-09 19:05:47 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 12 Eclipse Genie CLA 2023-01-24 18:49:34 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.