Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 345359

Summary: [1.7][compiler] AIOOB on diamond construct with argument error
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, Olivier_Thomann
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch
none
Proposed patch
none
Additional fix + test none

Description Srikanth Sankaran CLA 2011-05-10 23:27:00 EDT
Top of BETA_JAVA7 branch.

The following code triggers an AIOOB from the compiler.


public class X<T>  {
    X(T t) {}
    X<String> f = new X<>(new Y()); 
}

(Y needs to be undefined to trigger the error)
Comment 1 Srikanth Sankaran CLA 2011-05-11 01:46:16 EDT
Created attachment 195297 [details]
Proposed patch

Patch under test
Comment 2 Srikanth Sankaran CLA 2011-05-11 01:46:50 EDT
Added org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest_1_7.test0029()  as a regression test.
Comment 3 Srikanth Sankaran CLA 2011-05-11 02:02:18 EDT
Created attachment 195299 [details]
Proposed patch

Actually, I like this patch better.
Comment 4 Srikanth Sankaran CLA 2011-05-11 04:27:19 EDT
Released in BETA_JAVA7 branch.
Comment 5 Srikanth Sankaran CLA 2011-05-12 02:10:35 EDT
I meant to fix QAE in a similar manner, but forgot:

Now the following program continues to trigger AIOOB:


public class X {
    class I<T> {
	I(T t) {}
    }
    X.I<String> f = new X().new I<>(new Y()); 
}

Patch will follow shortly.
Comment 6 Srikanth Sankaran CLA 2011-05-12 02:26:56 EDT
Created attachment 195460 [details]
Additional fix + test

This patch addresses QAE. Other subtypes of AllocationExpression will
undergo similar change via bug 343693.
Comment 7 Olivier Thomann CLA 2011-06-28 10:09:03 EDT
Verified using v_B65.