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

Bug 417660

Summary: [1.8][compiler] Incorrect parsing of Annotations with array dimensions in arguments
Product: [Eclipse Project] JDT Reporter: Manoj N Palat <manoj.palat>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: manoj.palat, shankhba, srikanth_sankaran
Version: 4.4   
Target Milestone: BETA J8   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 413569    
Attachments:
Description Flags
Test code to reproduce the issue none

Description Manoj N Palat CLA 2013-09-20 00:13:22 EDT
Created attachment 235645 [details]
Test code to reproduce the issue

ArrayTypeReference generated for argument is incorrect.

Expected: int [] @TakeType(int[].class) [] 
Actual: int @TakeType(int[][].class) []

(only 1 dimension shown in actual, while the 2nd dimension is shown as part of annotations).
Comment 1 Manoj N Palat CLA 2013-09-20 02:19:11 EDT
(In reply to Manoj Palat from comment #0)
public class X {
  int bar(int [] @TakeType(int[].class)[] a) { return 0; }
}

@Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@interface TakeType {
	Class value() default int[].class;
}

Note: there is a parameter "a" in bar. The modified test case inlined above.
Comment 2 Srikanth Sankaran CLA 2013-09-20 02:21:07 EDT
(In reply to Manoj Palat from comment #1)

> Note: there is a parameter "a" in bar. The modified test case inlined above.

Good catch, thanks. It helps always to provide a full test case that does
not show any errors outside of what it is supposed to show. Here it is:

Good catch. I'll take this one:

Test case:

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

public class X {
  int bar(int [] @TakeType(int[].class)[] x) { return 0; }      
}

@Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@interface TakeType {
	Class value() default int[].class;
}