Bug 277643 - Generics compile error
Summary: Generics compile error
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All Mac OS X - Carbon (unsup.)
: P3 blocker with 4 votes (vote)
Target Milestone: 3.5.2   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 268798 280054 280809 281993 283306 283575 294724 299104 299367 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-05-25 03:35 EDT by Soren Mathiasen CLA
Modified: 2014-10-07 18:57 EDT (History)
16 users (show)

See Also:
daniel_megert: pmc_approved+


Attachments
Test case for the error (1.03 KB, text/plain)
2009-05-26 02:28 EDT, Soren Mathiasen CLA
no flags Details
Proposed patch (6.41 KB, patch)
2009-11-24 05:33 EST, Srikanth Sankaran CLA
no flags Details | Diff
New and changed tests (20.01 KB, patch)
2009-11-24 05:35 EST, Srikanth Sankaran CLA
no flags Details | Diff
Source + Tests cumulative patch for 3.5.2 stream. (25.86 KB, patch)
2009-11-25 01:25 EST, Srikanth Sankaran CLA
no flags Details | Diff
Source only patch for 3.5.2 stream (6.42 KB, patch)
2009-11-25 01:31 EST, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Soren Mathiasen CLA 2009-05-25 03:35:12 EDT
public final void addShortDescription(Object object, StringBuffer buf) {
		try {
			W_Description wdescription = get(W_Description.class,object); 
// GIVES AN ERROR
// Type mismatch: cannot convert from WrapperLogic to W_Description


			wdescription.setVerbosity(Verbosity.terse);
			wdescription.setIncludeSubDescriptions(false);
			wdescription.getDescription(buf);
		} catch (Exception e) {
		}
}


public <T, W extends WrapperLogic<? super T>> W get(Class<W> wrapperClass, T entity) {
	return getLogicFactory().get(wrapperClass, entity);
}

It seems the compiler is unable to recognise that the get method return a W.

The code compiles fine with ant, and it works in Eclipse 3.4 and below.
Comment 1 Kent Johnson CLA 2009-05-25 11:29:20 EDT
How can we reproduce this without the source for WrapperLogic & W_Description ?


Please attach a complete reproduceable testcase.
Comment 2 Soren Mathiasen CLA 2009-05-26 02:26:20 EDT
Hi,

Sorry here you go, should illustrate the problem :)

public class Test {
	public final void addShortDescription(Object object, StringBuffer buf) {
		try {
			W_Description wdescription = get(W_Description.class, object); // ERROR Type mismatch: cannot convert from Test.WrapperLogic to Test.W_Description
		} catch (Exception e) {
		}
	}

	public abstract class W_Description<WRAPPED> extends WrapperLogic<WRAPPED> {

	}

	public <T, W extends WrapperLogic<? super T>> W get(Class<W> wrapperClass, T entity) {
		return getLogicFactory().get(wrapperClass, entity);
	}

	private LogicFactory logicFactory;

	public final LogicFactory getLogicFactory() {
		return logicFactory;
	}

	public interface LogicFactory {
		<LOGIC extends Logic> LOGIC get(Class<LOGIC> logicClass);

		<WRAPPED, WRAPPER_LOGIC extends WrapperLogic<? super WRAPPED>> WRAPPER_LOGIC get(Class<WRAPPER_LOGIC> wrapperLogicClass, WRAPPED entityToWrap);
	}

	public abstract class WrapperLogic<WRAPPED> extends AbstractLogic implements Wrapper<WRAPPED> {

	}

	public abstract class AbstractLogic {
	}

	public interface Wrapper<WRAPPED> {
		WRAPPED getWrapped();
	}

	public abstract class Logic extends AbstractLogic {

	}

}
Comment 3 Soren Mathiasen CLA 2009-05-26 02:28:38 EDT
Created attachment 137110 [details]
Test case for the error

Now as an attachment :o)
Comment 4 Kent Johnson CLA 2009-05-26 11:17:00 EDT
Simpler case :

class Test {
	A a = get(A.class);

	<T, U extends B<? super T>> U get(Class<U> c) { return null; }
}

class A<T> extends B<T> {}

class B<U> {}


javac issues an unchecked method invocation: method get in class Test is applied to given types
  required: java.lang.Class<U>
  found: java.lang.Class<A>


In 3.4.x we do not report an error or an unchecked method invocation.

In 3.5RC2, we report both an unchecked method invocation & type mismatch error: cannot convert from B to A
Comment 5 Kent Johnson CLA 2009-05-26 11:45:58 EDT
Philippe - can you explain this code in MesssageSend.resolveType() ?


TypeBinding returnType;
if ((this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null) {
 returnType = this.binding.original().returnType;
 if (returnType != null) {
  returnType = scope.environment().convertToRawType(returnType.erasure(), true);
 }
} else {
 returnType = this.binding.returnType;
 if (returnType != null) {
   returnType = returnType.capture(scope, this.sourceEnd);
 }
}
this.resolvedType = returnType;


When the inferred return type is already a raw type, why ignore it & use the original's return type ?
Comment 6 Philipe Mulet CLA 2009-05-26 11:54:07 EDT
JLS 15.12.2.6 requires to surface the original method type in raw form, as opposed to reusing the inferred return type (in raw form) (which javac is using by mistake). This is why though you inferred A, you have to surface B for unchecked invocations.
Comment 7 Kent Johnson CLA 2009-05-26 14:25:53 EDT
Soren, we believe this is a bug in javac as Philippe described.

Closing as NOT_ECLIPSE
Comment 8 Soren Mathiasen CLA 2009-05-27 03:48:52 EDT
(In reply to comment #7)
> Soren, we believe this is a bug in javac as Philippe described.
> 
> Closing as NOT_ECLIPSE
> 


It might well be that the spec is right, and javac is wrong, but is it possible to make a flag to enable the old stlye ?
From my point of view the old style seems to make more sense, you have the information about the class to return, why throw that away ?

We can't be the only ones that have used this "feature" in 3.4, and now it's an error. Seems to me that perhaps alot of people wil complain about this :o(
Comment 9 Kent Johnson CLA 2009-05-27 09:57:15 EDT
You do not have to reopen the bug to add a comment.


It wasn't a 'feature' or 'style' in 3.4 - it was a bug that has been fixed.

And we do not get to pick and choose which aspects of the spec we follow.

> From my point of view the old style seems to make more sense, you have the
> information about the class to return, why throw that away ?

Because its a raw type. If you replace the raw type reference, you will not see this problem.
Comment 10 Olivier Thomann CLA 2009-05-27 15:28:32 EDT
Verified for 3.5RC3 using I20090526-2000.
Comment 11 Kent Johnson CLA 2009-06-12 14:26:05 EDT
*** Bug 280054 has been marked as a duplicate of this bug. ***
Comment 12 Kent Johnson CLA 2009-06-18 15:56:55 EDT
*** Bug 280809 has been marked as a duplicate of this bug. ***
Comment 13 Michael Giroux CLA 2009-06-18 16:36:26 EDT
(In reply to comment #9)

> And we do not get to pick and choose which aspects of the spec we follow.

Has anyone contacted Sun on this?  

I'm not sure how the JLS is managed, but this might be one of those areas where the spec needs to be revised to match the popular implementations (including javac).



Comment 14 Michael Giroux CLA 2009-06-18 17:13:52 EDT
(In reply to comment #8)
> We can't be the only ones that have used this "feature" in 3.4, and now it's an
> error. Seems to me that perhaps alot of people wil complain about this :o(

You are not alone.  Ran into the problem on the first project I tried to checkout into 3.5RC4.



Comment 15 Michael Giroux CLA 2009-06-24 13:37:38 EDT
(In reply to comment #9)
> If you replace the raw type reference, you will not see
> this problem.

Could you illustrate how to do this with the example:

package bugs.eclipse;
class Test2 {
    A a = get(A.class);  // this statement gets error

    // how should the next method be defined?
    <T, U extends B<? super T>> U get(Class<U> c) { return null; }
}

class A<T> extends B<T> {}

class B<U> {}



Comment 16 Michael Giroux CLA 2009-06-24 15:54:12 EDT
FWIW, the sample in #15 compiles w/ JDK 1.7 and w/ NetBeans 6.5.1.
Comment 17 Michael Giroux CLA 2009-06-26 10:25:07 EDT
(In reply to comment #9)

> And we do not get to pick and choose which aspects of the spec we follow.

But it appears to be possible to pass the TCK with the preious behaviour.  I have tested with JROCKIT 1.6, Sun JDK 1.6 and 1.7, and NetBeans 6.5.1, and they all compile the simple sample.

Is it really necessary to be this strict when the rest of the industry does not appear to be?


Comment 18 Michael Giroux CLA 2009-07-06 09:48:20 EDT
(In reply to comment #9)
> You do not have to reopen the bug to add a comment.

But nobody seems to follow up on posts after this has been closed.

> Because its a raw type. If you replace the raw type reference, you will not see
> this problem.

Would someone who understands what this means please explain how to resolve the issue using the simple example that was posted in #4?

Thanks.
Comment 19 Kent Johnson CLA 2009-07-06 09:57:16 EDT
Michael - please read comment #6

From our understanding of the spec, you cannot write :

A a = get(A.class);
<T, U extends B<? super T>> U get(Class<U> c) { return null; }

and expect A as the answer.


I accept this is frustrating/annoying for people who have existing code which uses this pattern, but we cannot ignore the spec.
Comment 20 Michael Giroux CLA 2009-07-06 10:10:50 EDT
(In reply to comment #19)

Kent,

Thanks for the quick response.

> From our understanding of the spec, you cannot write :

I am in no position to challenge anyone on the spec.  I assume that your reading is correct, and that the change for 3.5 is indeed a correction.  That said, I cannot find another compiler that raises this as an error.  The Eclipse 3.5 compiler is the only one that will not compile our code.

Sun's own JDKs (including the current 1.7 builds) compile this code without error.  It really seems strange to me that no other vendor has taken the position that Eclipse has on this item in the spec.

Has anyone at Eclipse contacted Sun on this?  Perhaps raised it as a bug with the Sun implementation to see how they respond.  Is it possible that the spec is incorrect?  How is it possible for other JDKs to pass the TCK?

Michael
Comment 21 Kent Johnson CLA 2009-07-06 14:48:39 EDT
*** Bug 281993 has been marked as a duplicate of this bug. ***
Comment 22 Kent Johnson CLA 2009-07-07 12:20:20 EDT
To provide some more info - the original change to MesssageSend.resolveType() was from bug 258798
Comment 23 Kent Johnson CLA 2009-07-20 12:37:33 EDT
*** Bug 283306 has been marked as a duplicate of this bug. ***
Comment 24 Kent Johnson CLA 2009-07-20 12:55:30 EDT
*** Bug 283575 has been marked as a duplicate of this bug. ***
Comment 25 Michael Giroux CLA 2009-07-20 14:57:09 EDT
(In reply to comment #4)
The current JDK 1.7 only gives a warning:

$ java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b65)
Java HotSpot(TM) Client VM (build 16.0-b06, mixed mode, sharing)



$ java  -Xlint:unchecked Test.java
Test.java:2: warning: [unchecked] unchecked method invocation: method get in class Test is applied to given types
        A a = get(A.class);
                 ^
  required: Class<U>
  found: Class<A>
  where U,T are type-variables:
    U extends B<? super T> declared in method <T,U>get(Class<U>)
    T extends Object declared in method <T,U>get(Class<U>)
1 warning



> Simpler case :
> class Test {
>         A a = get(A.class);
>         <T, U extends B<? super T>> U get(Class<U> c) { return null; }
> }
> class A<T> extends B<T> {}
> class B<U> {}
> javac issues an unchecked method invocation: method get in class Test is
> applied to given types
>   required: java.lang.Class<U>
>   found: java.lang.Class<A>
> In 3.4.x we do not report an error or an unchecked method invocation.
> In 3.5RC2, we report both an unchecked method invocation & type mismatch error:
> cannot convert from B to A

Comment 26 Soren Mathiasen CLA 2009-11-10 07:55:39 EST
Anything new on this, or should we consider switching to another ide ie. netbeans, that can compile the code via suns jdk.

I still feel that eclispe should bent the implementation to follow the de facto standard, it's not just one jdk that can compile the code it's all but eclipse..
Comment 27 Olivier Thomann CLA 2009-11-11 10:06:48 EST
(In reply to comment #26)
> I still feel that eclispe should bent the implementation to follow the de facto
> standard, it's not just one jdk that can compile the code it's all but
> eclipse..
As far as I know, there are two Java compilers: javac and the Eclipse compiler. If you know another one, please let me know.
We will contact Sun to sort this out. Meanwhile I keep this bug closed as it is not sure that anything will change. If it ends up being an problem with our compiler, you can be sure we will reopen and fix accordingly.
Comment 28 Srikanth Sankaran CLA 2009-11-12 00:36:53 EST
*** Bug 294724 has been marked as a duplicate of this bug. ***
Comment 29 Srikanth Sankaran CLA 2009-11-12 03:23:32 EST
Please see 
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6791481

where it is acknowledged that sun's implementation
diverges from JLS 15.12.2.6.

In particular this program compiles with unchecked conversion
warning but with no errors on javac 5,6,7 :

class Test<X> {
	X m(Class<X> c) {return null;}
	X x = m((Class)String.class);
}

Note: Eclipse HEAD also compiles the programs without the unchecked
warning, but that is a bug: I have raised bug# 294944.

Stay tuned as this gets investigated further.
Comment 30 Srikanth Sankaran CLA 2009-11-12 05:27:14 EST
(In reply to comment #29)
> Please see 
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6791481
> where it is acknowledged that sun's implementation
> diverges from JLS 15.12.2.6.

The particular manner in which javac is documented to diverge
is somewhat different though:

"Only generic methods are considered when checking as to whether
return/thrown types should be erased or not following an unchecked
conversion"

The current issue is at hand is around the phrase "erasure of the
method's declared return type" in the sentence:
         ^^^^^^^^
"Otherwise, if unchecked conversion was necessary for the method
to be applicable then the result type is the erasure (§4.6) of the
method’s declared return type."

> In particular this program compiles with unchecked conversion
> warning but with no errors on javac 5,6,7 :
> class Test<X> {
>     X m(Class<X> c) {return null;}
>     X x = m((Class)String.class);
> }
> Note: Eclipse HEAD also compiles the programs without the unchecked
> warning, but that is a bug: I have raised bug# 294944.
> Stay tuned as this gets investigated further.

Actually, the unchecked warning does come with eclipse, but the needed
erasure per 15.12.2.6 doesn't kick in resulting in this program being
compiled without error (as would be required per JLS). I'll leave this
behavior as it is for now until further investigation throws more light.
Comment 31 Srikanth Sankaran CLA 2009-11-12 22:39:45 EST
(In reply to comment #30)
> (In reply to comment #29)
> > Please see 
> > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6791481
> > where it is acknowledged that sun's implementation
> > diverges from JLS 15.12.2.6.
> The particular manner in which javac is documented to diverge
> is somewhat different though:

We have acknowledgement from Sun that javac's implementation
pertaining to JLS 15.12.2.6 is incorrect and deviates from 
JLS 15.12.2.6.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6791481 while
not identical is similar enough that the current issue would
fall under the same sun bug.

The last words on http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6791481
reads:

"TODO: investigate the compatibility risk of this change as it could cause compilation errors on programs that used to be accepted.
Posted Date : 2009-01-08 13:49:01.0"

Olivier, what do you suggest ? 

Philippe, a couple of questions:

1. Do you remember what was the driver behind bug# 258798 ? Was this
internally raised ? 

2. Quoted from bug# 258798 comment#0 : 

class Foo<T> {}
public class X {
    public void test() {
        Integer i = m(new Foo<Foo<Integer>>(), new Foo());
    }
    public <T> T m(Foo<T> x, T t) {
        return t;
    }
}


should surface an error where the return type got erased:
   Type mismatch: cannot convert from Foo to Integer
instead of:
   Type mismatch: cannot convert from Foo<Integer> to Integer

--- Did you mean to say : 
   Type mismatch: cannot convert from Object to Integer ? 

-- Thanks.
Comment 32 Philipe Mulet CLA 2009-11-13 03:30:29 EST
The generic inference was not complying to JLS 15.12.2.6 prior to this fix. It would simply answer a raw method substitution, losing the fact certain elements could be better inferred than raw types.
We had several symptoms of this, which got taken care by bug 258798, and it should not be reverted for that matter.
Now, it could be tuned a bit if not reconciliable with javac. For instance, we currently answer a raw form of the type original variable erasure, as opposed to simply erasing the 
inferred return type (a la javac). While this is acknowledged as a bug, until Sun fixes it, I understand this being problematic.

My vote would be to ask them whether they will act on it or not given the "TODO: investigate...", and align accordingly.

> --- Did you mean to say : 
>   Type mismatch: cannot convert from Object to Integer ? 
Well, at the time I wrote that, I probably had not yet realized that we were supposed to erase original variable, but was only erasing the inferred return type.

NOTE: from conversations back then, I remember that such semantics were also to apply to non generic method invocations as well (which we are not doing, but JLS 15.12.2.6 is not only for generic invocations).
The reasoning being that raw types were not to be forgiving...
Comment 33 Srikanth Sankaran CLA 2009-11-17 02:12:18 EST
javac team is "not actively investigating this issue anymore".

In looking at the test case attached to this defect as well as the
myriad duplicates, it appears that inserting a simple cast should
make the programs compile alright in all the cases retaining the same
meaning as they had/have under javac and eclipse 3.4. After all, the
erasure of the declared return type vs the inferred return type which
javac is admittedly erroneously using does not change the dynamic type
of the object -- only the compile time notion.

Granted, this is ugly, inelegant and cumbersome, but will unblock us.

Is something being overlooked or oversimplified here ?
Comment 34 Philipe Mulet CLA 2009-11-17 09:59:54 EST
> it appears that inserting a simple cast ...
Can you give an example of what you have in mind ?
I was thinking of changing the way we erase in that scenario.
Comment 35 Srikanth Sankaran CLA 2009-11-18 00:42:41 EST
(In reply to comment #34)
> > it appears that inserting a simple cast ...
> Can you give an example of what you have in mind ?
> I was thinking of changing the way we erase in that scenario.


What I had in mind was given:

class Test {
    A a = get(A.class); // fails to compile with 3.5 as get is seen
                        // to return a B and not A as was with 3.4
    <T, U extends B<? super T>> U get(Class<U> c) { return null; }
}

class A<T> extends B<T> {}
class B<U> {}

if the offending line was changed to

    A a = (A) get(A.class);

the program should be semantically identical to the code generated
by 3.4 and javac.

But that is simplistic - the altered return type could have ripple
effects and influence other things as the program below shows: so 
my suggestion that a simple cast should fix the problem is not valid.

class Test {
    A a = (A) get(A.class);
    int f = m(get(A.class));
    <T, U extends B<? super T>> U get(Class<U> c) { 
    	return null;
    }
    public int m(A a) {
    	return 0;
    }
    public int m(B b) {
	return 1;
    }
    public static void main(String [] args) {
	Test t = new Test();
	System.out.println(t.f);  // prints 0 with 3.4 and 1 with 3.5
    }
}

class A<T> extends B<T> {}

class B<U> {}
Comment 36 Philipe Mulet CLA 2009-11-18 08:00:09 EST
The change I have in mind is the following:
in MessageSend#resolveType(...) locate the following lines near the bottom:

[...]
TypeBinding returnType;
if ((this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null) {
>>	returnType = this.binding.original().returnType;
	if (returnType != null) {
		returnType = scope.environment().convertToRawType(returnType.erasure(), true);
	}
} else {
[...]

and replace:
>>	returnType = this.binding.original().returnType;
with:
>>	returnType = this.binding.returnType;

Sorry I need to recreate a dev environment to create a patch...
Comment 37 Srikanth Sankaran CLA 2009-11-19 00:08:35 EST
(In reply to comment #36)
> The change I have in mind is the following:
> in MessageSend#resolveType(...) locate the following lines near the bottom:
> [...]
> TypeBinding returnType;
> if ((this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null)
> {
> >>	returnType = this.binding.original().returnType;
>     if (returnType != null) {
>         returnType = scope.environment().convertToRawType(returnType.erasure(),
> true);
>     }
> } else {
> [...]
> and replace:
> >>	returnType = this.binding.original().returnType;
> with:
> >>	returnType = this.binding.returnType;
> Sorry I need to recreate a dev environment to create a patch...

Philippe, Thanks, I had already tested such a version and it works ok.
Other than a handful of failures in GenericTypeTests all seem to be ok.
These "failures" are along the expected lines due to the changed behavior
in the experimental fix and would call for remastering the test case.
Comment 38 Philipe Mulet CLA 2009-11-19 08:53:20 EST
You also need to apply a similar change for thrown exceptions:

org.eclipse.jdt.internal.compiler.ast - compiler - org.eclipse.jdt.core
AllocationExpression#analyseCode(BlockScope, FlowContext, FlowInfo)
ExplicitConstructorCall#analyseCode(BlockScope, FlowContext, FlowInfo)
MessageSend#analyseCode(BlockScope, FlowContext, FlowInfo)
QualifiedAllocationExpression#analyseCode(BlockScope, FlowContext, FlowInfo)

and also make the same change in code snippet support:

org.eclipse.jdt.internal.eval - eval - org.eclipse.jdt.core
CodeSnippetMessageSend#resolveType(BlockScope)
Comment 39 Philipe Mulet CLA 2009-11-19 08:54:41 EST
Feels also this should be propagated back to 3.5.x stream given community reactions.
Comment 40 Olivier Thomann CLA 2009-11-19 09:01:41 EST
Daniel, once the patch is ready we would like to release a fix for 3.5.2.
+1 ?
Comment 41 Michael Giroux CLA 2009-11-19 09:03:14 EST
(In reply to comment #39)

+1
Comment 42 Dani Megert CLA 2009-11-23 11:51:22 EST
I tend to +1 for backporting but I'd like to see a patch before deciding: if it's too big and/or risky then we might not do it.
Comment 43 Srikanth Sankaran CLA 2009-11-24 03:41:15 EST
While working on this, I tripped into another defective behavior
and have raised bug# 295964. The related tests are passing as of
now, but only fortuitously so.
Comment 44 Srikanth Sankaran CLA 2009-11-24 05:33:03 EST
Created attachment 152933 [details]
Proposed patch

Proposed patch to align with javac behavior.
Comment 45 Srikanth Sankaran CLA 2009-11-24 05:35:55 EST
Created attachment 152934 [details]
New and changed tests 

Patch for new and changed tests.
Comment 46 Srikanth Sankaran CLA 2009-11-24 23:54:02 EST
Fix and tests released in HEAD for 3.6M4.
3.5.2 patch to be posted shortly.
Comment 47 Srikanth Sankaran CLA 2009-11-25 01:25:58 EST
Created attachment 153032 [details]
Source + Tests cumulative patch for 3.5.2 stream.

Patch to backport to 3.5.2 stream.
Comment 48 Srikanth Sankaran CLA 2009-11-25 01:31:16 EST
Created attachment 153033 [details]
Source only patch for 3.5.2 stream

Dani, please take a look at this proposed backport to 3.5.2
Comment 49 Dani Megert CLA 2009-11-26 09:06:00 EST
Good work!
+1 for 3.5.2.
Comment 50 Srikanth Sankaran CLA 2009-11-27 04:09:41 EST
Released in 3.5.2 maintenance stream. Thanks everybody for your patience.
Comment 51 Michael Giroux CLA 2009-11-30 08:48:47 EST
(In reply to comment #50)
> Released in 3.5.2 maintenance stream. Thanks everybody for your patience.

This is great news.  The effort is appreciated.

This was the only issue blocking my teams migration to Galileo.  I see the release plan for 3.5.2 is 2010-02-26.  What is the best option for a stable build prior to 3.5.2?
Comment 52 Soren Mathiasen CLA 2009-12-01 02:52:31 EST
HI, 

Great work guys !
But I still have a issue :(

The following code gives me an error saying that the get methods have the same erasure.
The code below compiles in Suns JDK

public class Testing {
	public <L extends Logic> L get(Class<L> logicClass) {
		return null;
	}
	
	public <L extends SingletonWrapperLogic<?>> L get(Class<L> logicClass) {
		return null;
	}

}

class AbstractLogic {	
}

class Logic extends AbstractLogic {
}

class SingletonWrapperLogic<WRAPPED>  {
}
Comment 53 Dani Megert CLA 2009-12-01 03:00:33 EST
Soren this bug as initially reported is fixed and backported to 3.5.2. Please open a new bug report for your problem and lets discuss it there.
Comment 54 Srikanth Sankaran CLA 2009-12-01 03:11:01 EST
(In reply to comment #53)
> Soren this bug as initially reported is fixed and backported to 3.5.2. Please
> open a new bug report for your problem and lets discuss it there.

To save everyone some cycles, I believe this latest issue reported is
a duplicate of 

https://bugs.eclipse.org/bugs/show_bug.cgi?id=289247
https://bugs.eclipse.org/bugs/show_bug.cgi?id=273862

See the sun bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
fixed and released in 7b55 release of javac.

So this code will be rejected by more recent versions of javac.

When fed to 7b75 I get:

C:\jtests>C:\jdk-7-ea-bin-b75-windows-i586-30_oct_2009\jdk7\bin\javac -Xlint:unc
hecked -sourcepath c:\jtests Testing.java
Testing.java:6: name clash: <L#1>get(Class<L#1>) and <L#2>get(Class<L#2>) have t
he same erasure
    public <L extends SingletonWrapperLogic<?>> L get(Class<L> logicClass) {
                                                  ^
  where L#1,L#2 are type-variables:
    L#1 extends SingletonWrapperLogic<?> declared in method <L#1>get(Class<L#1>)

    L#2 extends Logic declared in method <L#2>get(Class<L#2>)
1 error

C:\jtests>
Comment 55 Srikanth Sankaran CLA 2009-12-01 21:10:10 EST
(In reply to comment #51)
> (In reply to comment #50)
> > Released in 3.5.2 maintenance stream. Thanks everybody for your patience.
> This is great news.  The effort is appreciated.
> This was the only issue blocking my teams migration to Galileo.  I see the
> release plan for 3.5.2 is 2010-02-26.  What is the best option for a stable
> build prior to 3.5.2?

While there will be several periodic builds and release candidates builds
in the 3.5.2 branch leading upto 3.5.2 release that you can use to test,
3.5.2 is the next full release.
Comment 56 Jay Arthanareeswaran CLA 2009-12-08 01:23:45 EST
Verified for 3.6M4 using build I20091207-1800
Comment 57 Srikanth Sankaran CLA 2010-01-08 07:06:06 EST
*** Bug 299104 has been marked as a duplicate of this bug. ***
Comment 58 Srikanth Sankaran CLA 2010-01-13 01:26:02 EST
*** Bug 299367 has been marked as a duplicate of this bug. ***
Comment 59 Satyam Kandula CLA 2010-01-21 06:27:53 EST
Verified for 3.5.2 RC2 using build M20100120-0800
Comment 60 Srikanth Sankaran CLA 2010-01-21 07:00:13 EST
Verified.
Comment 61 Srikanth Sankaran CLA 2010-02-24 23:53:43 EST
*** Bug 268798 has been marked as a duplicate of this bug. ***
Comment 63 Srikanth Sankaran CLA 2014-10-07 18:54:30 EDT
(In reply to Jigar Joshi from comment #62)
> Originally discussed here
> 
> http://stackoverflow.com/questions/26186767/generics-function-call-not-
> compiling-in-java-8-extending-multiple-interfaces

Couldn't be. Unless you guys at Stackoverflow are time travellers.
I think you meant to add this comment at https://bugs.eclipse.org/bugs/show_bug.cgi?id=446223
Comment 64 Jigar Joshi CLA 2014-10-07 18:57:15 EDT
Sorry, commented in wrong thread