Bug 111076 - Compiler accepts illegally placed annotation.
Summary: Compiler accepts illegally placed annotation.
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.2 M3   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-29 11:08 EDT by Brian Miller CLA
Modified: 2005-09-30 08:27 EDT (History)
1 user (show)

See Also:


Attachments

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