T
Tom Anderson
Hi all,
Stupid question - where's the definition of the syntax, at the lexical
level, of annotations in the JLS? I mean the application of annotations,
specifically to classes - the rules that make this:
@Foo
public class Bar {}
legal.
There's nothing in chapter 3 about them, and nothing in the relevant bits
of chapter 9 about syntax.
I came across something weird the other day, where the Eclipse and Sun
compilers seem to differ over whether a comma is permitted after the last
item in a literal array of classes that's used as an annotation value.
Normally, java permits the bonus comma after the last item:
int[] a = new int[] {1, 2, 3,}; // legal
But javac seemed to be rejecting this:
import org.junit.Suite;
@Suite.SuiteClasses({
Foo.class,
Bar.class, // illegal!
})
public class MySuite {}
I'm a bit puzzled over the lexical status of the structure comprising the
curly brackets and their contents (the comma, and why a "new Class[]"
isn't needed), and would like to see what the letter of the law is, but
can't find it.
tom
Stupid question - where's the definition of the syntax, at the lexical
level, of annotations in the JLS? I mean the application of annotations,
specifically to classes - the rules that make this:
@Foo
public class Bar {}
legal.
There's nothing in chapter 3 about them, and nothing in the relevant bits
of chapter 9 about syntax.
I came across something weird the other day, where the Eclipse and Sun
compilers seem to differ over whether a comma is permitted after the last
item in a literal array of classes that's used as an annotation value.
Normally, java permits the bonus comma after the last item:
int[] a = new int[] {1, 2, 3,}; // legal
But javac seemed to be rejecting this:
import org.junit.Suite;
@Suite.SuiteClasses({
Foo.class,
Bar.class, // illegal!
})
public class MySuite {}
I'm a bit puzzled over the lexical status of the structure comprising the
curly brackets and their contents (the comma, and why a "new Class[]"
isn't needed), and would like to see what the letter of the law is, but
can't find it.
tom