Community
Participate
Working Groups
I20080528-2000 With a JRE from Java 1.6, create an AST for this class: class TrivialClass { void m(Object someObject, Integer intObject) { Exception class1 = someObject.getClass(); Exception class2 = intObject.getClass(); } } Now call resolveTypeBinding() on the MethodInvocations: - For 'someObject.getClass()', it's 'Class<capture#1-of ?>'. - For 'intObject.getClass()', it's 'Class<capture#2-of ? extends Integer>'. I would expect to get 'Class<capture#1-of ? extends Object>' in the first case as well, since JLS3 says: 'The type of a method invocation e.getClass(), where the expression e has the static type T, is Class<? extends |T|>.' With a 1.5 JRE, the binding is as expected (probably because Object#getClass() had declared return type Class<? extends Object> in 1.5, but Class<?> in 1.6).
I would expect this too.
Added GenericTypeTest#test1338
Created attachment 102685 [details] Proposed patch
Created attachment 102689 [details] Better patch Should not discriminate on Object declaring class, since it prevents from ignoring bogus override of Object#getClass()
Markus - is this any critical for 3.4 ?
The fix looks good and solves bug 211037 (better than my workaround, which only prevents the runtime exception). It makes the bindings look the same as with a 1.5 JRE, so I don't expect that any client could have a problem with the fix. +1 from my side for RC3, but I could also live with the workaround for 3.4.
Given it is not super critical, and presence of a workaround, would rather not put it in by the end game rules for RC3. Will defer it until 3.4.1 (or 3.5).
Also added GenericTypeTest#test1339
Created attachment 102849 [details] Patch for 3.3.x
Targeting for 3.4.1. Also released to 3.3.x maintenance
In 3.5 stream, tests are actually GenericTypeTest#test1339 & test1342
Ignore comment 11
Released for 3.5M1
Released to 3.4 maintenance branch Fixed
Released for 3.4.1
Verified for 3.5M1 using I20080805-1307
Verified for 3.4.1 using build M20080827-2000.