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

Bug 415399

Summary: [1.8][compiler] Type annotations on constructor results dropped by the code generator
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Andrew Clement <aclement>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 4.4   
Target Milestone: BETA J8   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 409235    
Attachments:
Description Flags
Test and fix none

Description Srikanth Sankaran CLA 2013-08-20 02:08:40 EDT
BETA_JAVA8:

Given the following program:

// ---
import java.lang.annotation.*;
import static java.lang.annotation.ElementType.*; 
@Target(TYPE_USE)
@interface Immutable {}
class Document {}
class X {
	@Immutable X() {
	}
}
// ---

The annotation @Immutable does not make it to the class file.

8b100 emits:

  X();
    descriptor: ()V
    flags: 
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0       
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return        
      LineNumberTable:
        line 7: 0
        line 8: 4
    RuntimeInvisibleTypeAnnotations:
      0: #9(): METHOD_RETURN
Comment 1 Srikanth Sankaran CLA 2013-08-20 02:09:05 EDT
Andy, please take a look. TIA.
Comment 2 Srikanth Sankaran CLA 2013-08-20 02:25:39 EDT
Regression test will be made available via org.eclipse.jdt.core.tests.compiler.regression.JSR308SpecSnippetTests.test013()
(to be released shortly.)
Comment 3 Andrew Clement CLA 2013-08-22 01:34:47 EDT
Created attachment 234649 [details]
Test and fix

Ensure the annotations on the constructor make it to the class file.

Might want to apply after patch on bug 415397
Comment 4 Srikanth Sankaran CLA 2013-08-22 04:04:58 EDT
Fix and tests released here: Thanks Andy.
Comment 5 Andrew Clement CLA 2013-08-22 12:02:54 EDT
This contribution complies with http://www.eclipse.org/legal/CoO.php