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 6423972 |
26 * @bug 6423972 |
27 * @summary Tests TypeParameter.getBounds. |
27 * @summary Tests TypeParameter.getBounds. |
28 * @author Scott Seligman |
28 * @author Scott Seligman |
29 * @build TypeParamBounds |
29 * @library ../../../lib |
|
30 * @build JavacTestingAbstractProcessor TypeParamBounds |
30 * @compile -processor TypeParamBounds -proc:only TypeParamBounds.java |
31 * @compile -processor TypeParamBounds -proc:only TypeParamBounds.java |
31 */ |
32 */ |
32 |
33 |
33 import java.util.HashMap; |
34 import java.util.HashMap; |
34 import java.util.List; |
35 import java.util.List; |
38 import javax.lang.model.SourceVersion; |
39 import javax.lang.model.SourceVersion; |
39 import javax.lang.model.element.*; |
40 import javax.lang.model.element.*; |
40 import javax.lang.model.type.*; |
41 import javax.lang.model.type.*; |
41 import javax.lang.model.util.*; |
42 import javax.lang.model.util.*; |
42 |
43 |
43 @SupportedAnnotationTypes("*") |
44 public class TypeParamBounds extends JavacTestingAbstractProcessor { |
44 public class TypeParamBounds extends AbstractProcessor { |
|
45 |
|
46 Elements elements; |
|
47 Types types; |
|
48 |
|
49 public void init(ProcessingEnvironment penv) { |
|
50 super.init(penv); |
|
51 elements = penv.getElementUtils(); |
|
52 types = penv.getTypeUtils(); |
|
53 } |
|
54 |
|
55 public boolean process(Set<? extends TypeElement> annoTypes, |
45 public boolean process(Set<? extends TypeElement> annoTypes, |
56 RoundEnvironment round) { |
46 RoundEnvironment round) { |
57 if (!round.processingOver()) |
47 if (!round.processingOver()) |
58 doit(annoTypes, round); |
48 doit(annoTypes, round); |
59 return true; |
49 return true; |
60 } |
|
61 |
|
62 @Override |
|
63 public SourceVersion getSupportedSourceVersion() { |
|
64 return SourceVersion.latest(); |
|
65 } |
50 } |
66 |
51 |
67 private void doit(Set<? extends TypeElement> annoTypes, |
52 private void doit(Set<? extends TypeElement> annoTypes, |
68 RoundEnvironment round) { |
53 RoundEnvironment round) { |
69 TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen"); |
54 TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen"); |
89 } |
74 } |
90 } |
75 } |
91 |
76 |
92 |
77 |
93 // Fodder for the processor |
78 // Fodder for the processor |
94 |
|
95 static class Gen<T, U extends Object, V extends Number, W extends U, |
79 static class Gen<T, U extends Object, V extends Number, W extends U, |
96 X extends Runnable, Y extends CharSequence & Runnable, |
80 X extends Runnable, Y extends CharSequence & Runnable, |
97 Z extends Object & Runnable> { |
81 Z extends Object & Runnable> { |
98 |
82 |
99 // The names of the bounds of each type parameter of Gen. |
83 // The names of the bounds of each type parameter of Gen. |