Bug 101779 - [1.5][compiler] VerifyError using -- operator on unboxed generic Integer type
Summary: [1.5][compiler] VerifyError using -- operator on unboxed generic Integer type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P3 major (vote)
Target Milestone: 3.1.1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 105524 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-25 17:45 EDT by Tim Moreton CLA
Modified: 2005-09-26 10:05 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Moreton CLA 2005-06-25 17:45:05 EDT
I am getting VerifyErrors on 3.1 RC3 (I20050617-1618). This looks similar to bug
69776. I believe that this is due to incorrect bytecode being generated, missing
casts, to deal with unboxing and reboxing a generic Integer with a "--"
operation (I presume this is valid java!?- if not, i should be warned, and it
should not appear to compile fine!). Test case:

public final class Pair<F,S> {
    public F first;
    public S second;

    public static <F,S> Pair<F,S> create(F f, S s) {
	return new Pair<F,S>(f,s);
    }
	
    public Pair(final F f, final S s) {
        first = f;
        second = s;
    }
}

public class A {
	public void a() {
		Pair<Integer,Integer> p = Pair.create(1,3);
		p.first--;
	}
	
	public static void main(final String[] args) {
		new A().a();
	}
}

I get: 
Exception in thread "main" java.lang.VerifyError: (class: A, method: a
signature: ()V) Incompatible object argument for function call
Comment out the line "p.first--;" and it runs fine.

linux-gtk x86 32bit

java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition
java.runtime.version=1.5.0-b64

Thanks, Tim
Comment 1 Philipe Mulet CLA 2005-06-26 09:07:49 EDT
Reproduced.
Comment 2 Philipe Mulet CLA 2005-06-26 09:17:18 EDT
Offending sequence is in method a()

    12  aload_1 [p]
    13  dup
    14  getfield Pair.first : Object [30]
    17  invokevirtual Integer.intValue() : int  [34]
    20  iconst_1
    21  isub
    22  invokestatic Integer.valueOf(int) : Integer  [20]
    25  putfield Pair.first : Object [30]
    28  return

before bytecode at 17, a checkcast Integer should be issue.
Comment 3 Philipe Mulet CLA 2005-06-27 05:07:41 EDT
Similar weaknesses spotted for prefix operators as well, and for all
single/qualified/field references.

Added AutoboxingTest#test105-109.
Comment 4 Philipe Mulet CLA 2005-06-27 05:13:53 EDT
Actually regression tests are: AutoboxingTest#test105-108.
Comment 5 Philipe Mulet CLA 2005-06-29 04:13:11 EDT
Fixed in 3.1 maintenance branch
Comment 6 Philipe Mulet CLA 2005-07-28 18:19:28 EDT
*** Bug 105524 has been marked as a duplicate of this bug. ***
Comment 7 Maxime Daniel CLA 2005-08-09 10:04:55 EDT
Verified in 3.2 M1 with build I20050808-2000.
Comment 8 David Audel CLA 2005-09-26 10:05:43 EDT
Verified using M20050923-1430 for 3.1.1