59 public String getCharContent(boolean ignoreEncodingErrors) {
60 return "class Test1<T extends Thread & Runnable> {}";
61 }
62 }
63 class Test2 extends SimpleJavaFileObject {
64 Test2() {
65 super(URI.create("myfo:///Test2.java"), SOURCE);
66 }
67 @Override
68 public String getCharContent(boolean ignoreEncodingErrors) {
69 return "class Test2<T extends Test2<T> & Runnable> {}";
70 }
71 }
72 task = tool.getTask(null, fm, null, Collections.singleton("-Xlint:all"), null,
73 Arrays.asList(new Test1(), new Test2()));
74 task.setProcessors(Collections.singleton(new MyProcessor()));
75 if (!task.call())
76 throw new AssertionError("Annotation processor failed");
77 }
78 @SupportedAnnotationTypes("*")
79 @SupportedSourceVersion(SourceVersion.RELEASE_6)
80 static class MyProcessor extends AbstractProcessor {
81 void test(TypeElement element, boolean fbound) {
82 TypeParameterElement tpe = element.getTypeParameters().iterator().next();
83 tpe.getBounds().getClass();
84 if (fbound) {
85 DeclaredType type = (DeclaredType)tpe.getBounds().get(0);
86 if (type.asElement() != element)
87 throw error("%s != %s", type.asElement(), element);
88 TypeVariable tv = (TypeVariable)type.getTypeArguments().get(0);
89 if (tv.asElement() != tpe)
90 throw error("%s != %s", tv.asElement(), tpe);
91 }
92 }
93 public boolean process(Set<? extends TypeElement> annotations,
94 RoundEnvironment roundEnv) {
95 test(processingEnv.getElementUtils().getTypeElement("Test1"), false);
96 test(processingEnv.getElementUtils().getTypeElement("Test2"), true);
97 return false;
98 }
99 }
100 public static void main(String... args) {
101 new T6421111().test(args);
102 }
103 public static AssertionError error(String format, Object... args) {
104 return new AssertionError(String.format(format, args));
105 }
106 }
|
59 public String getCharContent(boolean ignoreEncodingErrors) {
60 return "class Test1<T extends Thread & Runnable> {}";
61 }
62 }
63 class Test2 extends SimpleJavaFileObject {
64 Test2() {
65 super(URI.create("myfo:///Test2.java"), SOURCE);
66 }
67 @Override
68 public String getCharContent(boolean ignoreEncodingErrors) {
69 return "class Test2<T extends Test2<T> & Runnable> {}";
70 }
71 }
72 task = tool.getTask(null, fm, null, Collections.singleton("-Xlint:all"), null,
73 Arrays.asList(new Test1(), new Test2()));
74 task.setProcessors(Collections.singleton(new MyProcessor()));
75 if (!task.call())
76 throw new AssertionError("Annotation processor failed");
77 }
78 @SupportedAnnotationTypes("*")
79 static class MyProcessor extends AbstractProcessor {
80 void test(TypeElement element, boolean fbound) {
81 TypeParameterElement tpe = element.getTypeParameters().iterator().next();
82 tpe.getBounds().getClass();
83 if (fbound) {
84 DeclaredType type = (DeclaredType)tpe.getBounds().get(0);
85 if (type.asElement() != element)
86 throw error("%s != %s", type.asElement(), element);
87 TypeVariable tv = (TypeVariable)type.getTypeArguments().get(0);
88 if (tv.asElement() != tpe)
89 throw error("%s != %s", tv.asElement(), tpe);
90 }
91 }
92 public boolean process(Set<? extends TypeElement> annotations,
93 RoundEnvironment roundEnv) {
94 test(processingEnv.getElementUtils().getTypeElement("Test1"), false);
95 test(processingEnv.getElementUtils().getTypeElement("Test2"), true);
96 return false;
97 }
98 @Override
99 public SourceVersion getSupportedSourceVersion() {
100 return SourceVersion.latest();
101 }
102 }
103 public static void main(String... args) {
104 new T6421111().test(args);
105 }
106 public static AssertionError error(String format, Object... args) {
107 return new AssertionError(String.format(format, args));
108 }
109 }
|