Bug 141800

Summary: [1.5][compiler] Necessary cast is marked as "unnecessary" for cast check in 3.2RC4
Product: [Eclipse Project] JDT Reporter: John Liu <john.liu>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, darin.eclipse, martinae, Mike_Wilson, Olivier_Thomann, thanson
Version: 3.2   
Target Milestone: 3.2 RC5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description John Liu CLA 2006-05-15 12:40:05 EDT
For the below application the ((Object[])test) is line is marked as unnecessay.  This seemed to happen only in 3.2RC4 and not in previous builds.

import java.util.Arrays;
class Test {
   public static void main( String args[] ) {
      Object test = new Object[] { "Hello", "World" };
      System.out.println(Arrays.asList(test));
      System.out.println(Arrays.asList((Object[])test)); // Warning here
   }
}

If the application is run.. the results are quite different

[[Ljava.lang.Object;@1372a1a]
[Hello, World]
Comment 1 Olivier Thomann CLA 2006-05-15 12:44:48 EDT
Reproduced with RC4.
Comment 2 Philipe Mulet CLA 2006-05-15 12:55:40 EDT
Regression. 3.2RC2 didn't report the problem (haven't checked RC3 yet).
Comment 3 Philipe Mulet CLA 2006-05-17 09:28:57 EDT
Problem got introduced in RC4. Consequence of fix for bug 139931
Comment 4 Philipe Mulet CLA 2006-05-17 12:08:44 EDT
Created attachment 41743 [details]
Proposed patch

The patch is nuking the cast warning in case there is a dimension mismatch (ie. less warnings are going to be emitted no matter what). Thus it is safe. An extra warning is causing grief, since quickfix is going to clean code which it shouldn't.

The patch has no influence on codegen, which always was correct here. Just an inacurrate warning notification.
Comment 5 Philipe Mulet CLA 2006-05-17 12:09:54 EDT
Given the regression was quickly spotted, and it may affect quickfix; we may want to consider it for 3.2RC5.

Martin - what is your vote ?
Comment 6 Philipe Mulet CLA 2006-05-17 12:10:35 EDT
Olivier - pls review the patch
Comment 7 Philipe Mulet CLA 2006-05-17 12:11:00 EDT
Dani - what is your vote ?
Comment 8 Philipe Mulet CLA 2006-05-17 12:11:49 EDT
Mike - what is your vote ?
Comment 9 Mike Wilson CLA 2006-05-17 12:47:14 EDT
+1 
Comment 10 Philipe Mulet CLA 2006-05-17 12:50:40 EDT
+1 for 3.2RC5. As said earlier, only possible downside of this fix is that we could nuke too many warnings (only for varargs method) if we got the fix wrong. 
Comment 11 Martin Aeschlimann CLA 2006-05-17 12:57:25 EDT
+1
Comment 12 Philipe Mulet CLA 2006-05-18 06:41:46 EDT
Actually, since dani went away.
Darin - would you please vote instead ?
Comment 13 Philipe Mulet CLA 2006-05-18 06:43:09 EDT
Tim - what do you think ? 
Comment 14 Darin Wright CLA 2006-05-18 10:19:51 EDT
+1
Comment 15 Philipe Mulet CLA 2006-05-18 10:25:59 EDT
Released for 3.2RC5
Comment 16 Olivier Thomann CLA 2006-05-19 11:16:37 EDT
Verified with I20060519-0010 for 3.2RC5