Bug 116028

Summary: annotations only applied to first field in a declaration
Product: [Eclipse Project] JDT Reporter: Art Dyer <art.dyer>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.2 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Art Dyer CLA 2005-11-11 11:04:30 EST
When multiple fields are declared in a single statement, annotations are only 
applied to the first of them.

Compare the behavior of the following program when compiled with javac and with 
the JDT compiler.

import java.lang.reflect.*;
import java.lang.annotation.*;

public class Foo
{
  @Deprecated public static Object x, y, z;

  public static void main(String[] args) throws Throwable
  {
    Class c = Foo.class;
    for (Field f : c.getFields())
    {
      System.out.println(f.getName());
      for (Annotation a : f.getDeclaredAnnotations())
      {
        System.out.println("  " + a);
      }
    }
  }
}
Comment 1 Olivier Thomann CLA 2005-11-11 18:43:21 EST
Fixed and released in HEAD.
Regression test in
org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest.test180
Comment 2 Frederic Fusier CLA 2005-12-12 11:16:53 EST
Verified for 3.2 M4 using build I20051212-0010