test/tools/javac/processing/model/util/elements/TestGetPackageOf.java

changeset 699
d2aaaec153e8
parent 554
9d9f26857129
child 1466
b52a38d4536c
equal deleted inserted replaced
698:f94af0667151 699:d2aaaec153e8
1 /* 1 /*
2 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
24 /* 24 /*
25 * @test 25 * @test
26 * @bug 6453386 26 * @bug 6453386
27 * @summary Test Elements.getPackageOf 27 * @summary Test Elements.getPackageOf
28 * @author Joseph D. Darcy 28 * @author Joseph D. Darcy
29 * @build TestGetPackageOf 29 * @library ../../../../lib
30 * @build JavacTestingAbstractProcessor TestGetPackageOf
30 * @compile -processor TestGetPackageOf -proc:only TestGetPackageOf.java 31 * @compile -processor TestGetPackageOf -proc:only TestGetPackageOf.java
31 */ 32 */
32 33
33 import java.util.Set; 34 import java.util.Set;
34 import javax.annotation.processing.*; 35 import javax.annotation.processing.*;
41 import static javax.tools.StandardLocation.*; 42 import static javax.tools.StandardLocation.*;
42 43
43 /** 44 /**
44 * Test basic workings of Elements.getPackageOf 45 * Test basic workings of Elements.getPackageOf
45 */ 46 */
46 @SupportedAnnotationTypes("*") 47 public class TestGetPackageOf extends JavacTestingAbstractProcessor {
47 public class TestGetPackageOf extends AbstractProcessor {
48 private Elements eltUtils;
49
50 /** 48 /**
51 * Check expected behavior on classes and packages. 49 * Check expected behavior on classes and packages.
52 */ 50 */
53 public boolean process(Set<? extends TypeElement> annotations, 51 public boolean process(Set<? extends TypeElement> annotations,
54 RoundEnvironment roundEnv) { 52 RoundEnvironment roundEnv) {
67 if (!unnamedPkg.equals(pkg=eltUtils.getPackageOf(unnamedPkg) ) ) 65 if (!unnamedPkg.equals(pkg=eltUtils.getPackageOf(unnamedPkg) ) )
68 throw new RuntimeException("Unexpected package for unnamed pkg: " + pkg); 66 throw new RuntimeException("Unexpected package for unnamed pkg: " + pkg);
69 } 67 }
70 return true; 68 return true;
71 } 69 }
72
73 public SourceVersion getSupportedSourceVersion() {
74 return SourceVersion.latest();
75 }
76
77 public void init(ProcessingEnvironment processingEnv) {
78 super.init(processingEnv);
79 eltUtils = processingEnv.getElementUtils();
80 }
81 } 70 }

mercurial