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

Bug 414384

Summary: [1.8] type annotation on abbreviated inner class is not marked as inner type
Product: [Eclipse Project] JDT Reporter: Stephan Herrmann <stephan.herrmann>
Component: CoreAssignee: Andrew Clement <aclement>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: srikanth_sankaran
Version: 4.3Flags: srikanth_sankaran: review+
Target Milestone: BETA J8   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on:    
Bug Blocks: 409235    
Attachments:
Description Flags
test and fix none

Description Stephan Herrmann CLA 2013-08-04 12:21:13 EDT
Given the following class:

package p;
import org.foo.*; // here we have type annotations for nullity
public abstract class X1 {
    public class Inner {}
    public void nesting(@NonNull Inner i1, @NonNull X1.@Nullable Inner i2) { }
}

This currently generates the following byte code:

  public void nesting(p.X1$Inner, p.X1$Inner);

  ...

  RuntimeInvisibleTypeAnnotations:
      0: #19(): METHOD_FORMAL_PARAMETER, param_index=0
      1: #19(): METHOD_FORMAL_PARAMETER, param_index=1
      2: #27(): METHOD_FORMAL_PARAMETER, param_index=1, location=[INNER_TYPE]
  ...

AFAICS the first annotation is wrong, it should have the same shape as the last one.

In 3.4 the spec says:
"The type path that is stored in the class file is with respect to the full type, not the source code representation. ..."
... and goes on explaining.

The full type of the first formal parameter is correctly rendered as p.X1$Inner (see 
the method signature), accordingly the type annotation for Inner should be marked with
"location=[INNER_TYPE]", no?
Comment 1 Stephan Herrmann CLA 2013-08-04 12:23:50 EDT
Andy, do you want to take a look?

I'll check in the test case in a little while (as part of bug 392384).
Comment 2 Srikanth Sankaran CLA 2013-08-16 07:07:43 EDT
If you think the bug is a must fix for the GA, please set the target to "BETA J8"
show this bug shows up in various cached queries that may use target milestone
in criteria.
Comment 3 Srikanth Sankaran CLA 2013-08-16 08:38:53 EDT
Andy, as of date, this is the only bug open against your name. Thanks.
Comment 4 Andrew Clement CLA 2013-08-22 11:53:47 EDT
Created attachment 234668 [details]
test and fix

Variation of testcode created as a test case. Small fix addresses it.
Comment 5 Andrew Clement CLA 2013-08-22 11:54:50 EDT
apply fix after patch on bug 415470 (to minimize chance of merge conflicts)
Comment 6 Andrew Clement CLA 2013-08-22 12:03:27 EDT
This contribution complies with http://www.eclipse.org/legal/CoO.php
Comment 7 Srikanth Sankaran CLA 2013-08-23 01:31:43 EDT
Patch looks good. Fixed a new compile time warning that inadvertently got
introduced by the patch and released the fix and tests here:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=8499ee1311c075235e045f23469dcc5f2d30119d,


Thanks Andy.