[type-annos-observers] ordering of annotated array brackets
Markus Keller
markus_keller at ch.ibm.com
Thu Mar 27 15:12:19 UTC 2014
Alex Buckley <alex.buckley at oracle.com> wrote on 2014-03-19 19:33:43:
> I understand the a2[0]=a1 scenario. Since making it well-typed means
> redefining the array type construction rule to consider post-identifier
> [] first, I am happy for a2[0]=a1 to not be well typed. There is a
> simple fix here: declare a1 and a2 in different declarations.
Wasn't it a no-go in the past to require users to rewrite existing code?
http://mail.openjdk.java.net/pipermail/type-annotations-spec-observers/2013-January/000064.html
Not adding new features to deprecated constructs would have been fine, but
adding them in an inconsistent way is really bad.
The too simple "left-to-right" rule also makes simple refactorings a pain,
e.g. replacing a type parameter by a concrete type:
import static java.lang.annotation.ElementType.TYPE_USE;
import java.lang.annotation.*;
@Target(TYPE_USE)
@interface NonEmpty {}
public class Test {
public API<String @NonEmpty []> api;
public API2 api2;
void test() {
api.t = api.ts[0]; // OK
api2.t = api2.ts[0]; // Not OK?
}
}
class API<T> {
public T t, ts[];
void assign() {
t = ts[0]; // OK
}
}
class API2 {
public String @NonEmpty [] t, ts[];
void assign() {
t = ts[0]; // Not OK?
}
}
More information about the type-annotations-spec-observers
mailing list