Bug 111076

Summary: Compiler accepts illegally placed annotation.
Product: [Eclipse Project] JDT Reporter: Brian Miller <bmiller>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: minor    
Priority: P3 CC: martinae
Version: 3.2   
Target Milestone: 3.2 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Brian Miller CLA 2005-09-29 11:08:36 EDT
According to Sun, the following annotation is illegal,
per http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6294589


------------------ Bug.java --------------
public class Bug {
  { for ( @SuppressWarnings("unusedLocal") Byte i : new Byte[]{} ) ; }
}
Comment 1 Martin Aeschlimann CLA 2005-09-30 06:40:25 EDT
Interesting. Looking at the Language Specification, I can't find anything that
would not allow this.
Comment 2 Philipe Mulet CLA 2005-09-30 06:51:40 EDT
Local variables can be associated modifiers, and thus are eligible for annotations. 
Comment 3 Philipe Mulet CLA 2005-09-30 06:56:09 EDT
Grammar spec says:

EnhancedForStatement:
  for ( VariableModifiersopt Type Identifier: Expression) Statement

VariableModifiers: 
  VariableModifier
  VariableModifiers VariableModifier

VariableModifier: one of
  final Annotation
Comment 4 Olivier Thomann CLA 2005-09-30 08:27:54 EDT
An annotation placed on a local variable is not persisted in the .class file,
but it is perfectly fine in the source.