Bug 84669

Summary: [1.5] VerifyError: Expecting to find object/array on stack
Product: [Eclipse Project] JDT Reporter: Johan Compagner <jcompagner>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Johan Compagner CLA 2005-02-08 06:24:44 EST
In my build of eclipse: I20050201-0800 i have this test file:

public class Test
{
	public Test()
	{
		super();
	}

	public Object convert(Object value)
	{
		Double d = (Double)value;
		d = (d/100);
		return d;
	}

	public static void main(String[] args)
	{
		Test test = new Test();
		Object value = test.convert(new Double(50));
	}
}

eclipse generates the wrong byte code for that:

5:   aload_2
6:   invokevirtual   #21; //Method java/lang/Double.doubleValue:()D
9:   ldc2_w  #22; //double 100.0d
12:  ddiv
13:  invokevirtual   #21; //Method java/lang/Double.doubleValue:()D
16:  astore_2

javac:

   5:   aload_2
   6:   invokevirtual   #3; //Method java/lang/Double.doubleValue:()D
   9:   ldc2_w  #4; //double 100.0d
   12:  ddiv
   13:  invokestatic    #6; //Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
   16:  astore_2

and that is logical because the double must be converted to a Double again and
that shouldn't be done with a doubleValue() method (that a double doesn't have)
Comment 1 Johan Compagner CLA 2005-02-08 06:26:02 EST
this does work:

d /= 100;
instead of 
d = d/100;
Comment 2 Philipe Mulet CLA 2005-02-08 06:36:42 EST
Reproduced
Comment 3 Philipe Mulet CLA 2005-02-08 06:41:54 EST
We should indeed box the result of #doubleValue()->double into Double.
I am wondering where the #doubleValue()->Double is defined; javac uses it but it
isn't defined in Number/Double.
Comment 4 Philipe Mulet CLA 2005-02-08 06:44:28 EST
Oops, ignore my previous comment. We simply misgenerate the boxing conversion.
Comment 5 Philipe Mulet CLA 2005-02-08 07:08:40 EST
Added AutoboxingTest#test092.

Problem comes from optimization for converting d=d/100 into d/=100, passing
along wrong implicitConversion value; and thus losing need for boxing conversion.

Fixed
Comment 6 Jerome Lanneluc CLA 2005-02-15 07:24:44 EST
Verified in I20050214