Bug 85924 - [1.5][compiler[ code generation error in M5 w/regard to generics
Summary: [1.5][compiler[ code generation error in M5 w/regard to generics
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 blocker (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-19 22:49 EST by Eric Goff CLA
Modified: 2005-03-31 10:01 EST (History)
0 users

See Also:


Attachments
IController.java (79 bytes, text/plain)
2005-03-11 23:20 EST, Eric Goff CLA
no flags Details
IView.java (31 bytes, text/plain)
2005-03-11 23:21 EST, Eric Goff CLA
no flags Details
MatGroup.java (218 bytes, text/plain)
2005-03-11 23:21 EST, Eric Goff CLA
no flags Details
foobar.java (200 bytes, text/plain)
2005-03-11 23:22 EST, Eric Goff CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Goff CLA 2005-02-19 22:49:46 EST
I have the following code snippet:
public void foo() {
for(MatGroup.Ctrl<?,?> glmat: ...) {
	glmat.getView().setTempAppearance() ;
}
}

MatGroup is defined as follows:
public class MatGroup {
    public static class Model extends Figure.Model {...}
    public static class View<T extends Model> {
               public void setTempAppearance() {...}
    }
    public static class Ctrl<T extends Model,U extends View<T>>  {...}
}

I get the following error when I run:
Exception in thread "AWT-EventQueue-0" java.lang.VerifyError: (class:
org/liberatis/sphaera/editor/PointSet$Ctrl, method: foo signature: ()V)
Incompatible object argument for function call
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
	at java.lang.Class.getConstructor0(Class.java:2640)
	at java.lang.Class.getConstructor(Class.java:1629)
	at
org.liberatis.sphaera.mvc.ControllerInstantiatorImpl.<init>(ControllerInstantiatorImpl.java:92)

If I change the snippet slightly to:
public void foo() {
for(MatGroup.Ctrl<?,?> glmat: ...) {
        GLMatGroup view = glmat.getView() ;
	view.setTempAppearance() ;
}
}

It will work okay.

It should be noted that M4 could not even compile this snippet of code
correctly, so it seems like there is perhaps some sort of systemtic
overlook of this area of generics and needs more tests.
Comment 1 Eric Goff CLA 2005-02-19 22:52:11 EST
I meant to say...............

If I change the snippet slightly to:
public void foo() {
for(MatGroup.Ctrl<?,?> glmat: ...) {
        GLMatGroup.View<?,?> view = glmat.getView() ;
	view.setTempAppearance() ;
}
}

Comment 2 Eric Goff CLA 2005-02-19 22:52:51 EST
I really really really meant to say...............

If I change the snippet slightly to:
public void foo() {
for(MatGroup.Ctrl<?,?> glmat: ...) {
        MatGroup.View<?,?> view = glmat.getView() ;
	view.setTempAppearance() ;
}
}
Comment 3 Philipe Mulet CLA 2005-02-20 06:53:16 EST
Cannot reproduce in M5. 
Tried the following and it worked fine:
import java.io.PrintStream;
import java.util.List;
  
public class X {
	public static void main(String argv[]) {
		System.out.println("SUCCESS");

	}
	public void foo(List<MatGroup.Ctrl<?,?>> list) {
		for(MatGroup.Ctrl<?,?> glmat: list) {
				 glmat.getView().setTempAppearance() ;
		}
	}
}
class MatGroup {
    static class Model {}
    static class View<T extends Model> { 
               public void setTempAppearance() {}
    }
    static class Ctrl<T extends Model,U extends View<T>>  {
		View getView() { return null; }
    }
}


Please provide exact steps to reproduce, then reopen
Comment 4 Philipe Mulet CLA 2005-02-20 06:53:52 EST
Reopen once steps are available
Comment 5 Eric Goff CLA 2005-02-22 00:48:37 EST
I regret that I do not have the time to get a small test case.
However..........
The very fact that I got that stack trace absolutely shows that
there is a bug in eclipse.   that error should never ever ever occur.
I was really hoping someone could actually analyze the error and see how it
*could* happen.

I urge you to take a second glance and not dismiss the bug simply for lack
of a test case.  It is 100% a bug and a bug of the very worst kind (generating
bad byte code).
Comment 6 Philipe Mulet CLA 2005-02-22 04:25:51 EST
Closing REMIND doesn't mean there is no bug, it simply mean that we request the
reporter more information. 

This defect is interesting, however the steps are inaccurate, and do not
reproduce. We have quite a few other defects which can be solved today, and thus
closing REMIND helps to focus on bugs for which we can take immediate actions.

You seem to be able to reproduce it, and you need to communicate better steps
for this defect to be addressed (again not saying we have no bug)
Comment 7 Eric Goff CLA 2005-03-11 23:20:37 EST
Created attachment 18733 [details]
IController.java
Comment 8 Eric Goff CLA 2005-03-11 23:21:06 EST
Created attachment 18734 [details]
IView.java
Comment 9 Eric Goff CLA 2005-03-11 23:21:40 EST
Created attachment 18735 [details]
MatGroup.java
Comment 10 Eric Goff CLA 2005-03-11 23:22:04 EST
Created attachment 18736 [details]
foobar.java
Comment 11 Eric Goff CLA 2005-03-11 23:23:53 EST
Compile the 4 attached java files with 3.1M5a and you get:
Exception in thread "main" java.lang.VerifyError: (class: foobar, method: main
signature: ([Ljava/lang/String;)V) Incompatible object argument for function call

cheers
Comment 12 Eric Goff CLA 2005-03-11 23:25:44 EST
You get the error when you run, not when you compile.  sorry.
Comment 13 Philipe Mulet CLA 2005-03-12 17:34:47 EST
Reproduced. Thanks for the testcase.
Comment 14 Philipe Mulet CLA 2005-03-12 18:29:27 EST
#getView() invocation is missing trailing generic cast to View.
This is due to optimization for unbound/super wildcards.
Fixed.

Added GenericTypeTest#test560
Comment 15 David Audel CLA 2005-03-31 10:01:21 EST
Verified in I20050330-0500