Bug 116028 - annotations only applied to first field in a declaration
Summary: annotations only applied to first field in a declaration
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.2 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-11 11:04 EST by Art Dyer CLA
Modified: 2005-12-12 11:16 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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