test/tools/javac/processing/model/element/TestAnonClassNames.java

changeset 1521
71f35e4b93a5
parent 1466
b52a38d4536c
child 2525
2eb010b6cb22
     1.1 --- a/test/tools/javac/processing/model/element/TestAnonClassNames.java	Wed Jan 23 20:57:40 2013 +0000
     1.2 +++ b/test/tools/javac/processing/model/element/TestAnonClassNames.java	Wed Jan 23 13:27:24 2013 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -78,7 +78,7 @@
    1.11          @Nesting(LOCAL)
    1.12          class LocalClass{};
    1.13  
    1.14 -        Object o =  new /*@Nesting(ANONYMOUS)*/ Object() { // An anonymous annotated class
    1.15 +        Object o =  new @Nesting(ANONYMOUS) Object() { // An anonymous annotated class
    1.16                  public String toString() {
    1.17                      return "I have no name!";
    1.18                  }
    1.19 @@ -96,10 +96,9 @@
    1.20          List<String> names = new ArrayList<String>();
    1.21          for(Class<?> clazz : classes) {
    1.22              String name = clazz.getName();
    1.23 -            Nesting anno = clazz.getAnnotation(Nesting.class);
    1.24              System.out.format("%s is %s%n",
    1.25                                clazz.getName(),
    1.26 -                              anno == null ? "(unset/ANONYMOUS)" : anno.value());
    1.27 +                              clazz.getAnnotation(Nesting.class).value());
    1.28              testClassName(name);
    1.29              names.add(name);
    1.30          }
    1.31 @@ -158,6 +157,7 @@
    1.32      }
    1.33  }
    1.34  
    1.35 +@Target({ElementType.TYPE, ElementType.TYPE_USE})
    1.36  @Retention(RUNTIME)
    1.37  @interface Nesting {
    1.38      NestingKind value();
    1.39 @@ -185,8 +185,8 @@
    1.40                                    typeElt.getQualifiedName().toString(),
    1.41                                    typeElt.getKind().toString(),
    1.42                                    nestingKind.toString());
    1.43 -                Nesting anno = typeElt.getAnnotation(Nesting.class);
    1.44 -                if ((anno == null ? NestingKind.ANONYMOUS : anno.value()) != nestingKind) {
    1.45 +
    1.46 +                if (typeElt.getAnnotation(Nesting.class).value() != nestingKind) {
    1.47                      throw new RuntimeException("Mismatch of expected and reported nesting kind.");
    1.48                  }
    1.49              }

mercurial