|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2022 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2022-2023 IBM Corporation and others. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials |
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0 |
|
10 | 10 | * |
11 | 11 | * Contributors: |
12 | 12 | * Salesforce - copied and adapted from org.eclipse.jdt.core.tests.compiler.regression.BatchCompilerTest |
| 13 | + * SSI Schaefer IT Solutions GmbH - add test_github1654() |
13 | 14 | *******************************************************************************/ |
14 | 15 | package org.eclipse.jdt.apt.tests; |
15 | 16 |
|
@@ -109,6 +110,84 @@ public void test_github844() throws IOException { |
109 | 110 | // @formatter:on |
110 | 111 | } |
111 | 112 |
|
| 113 | + public void test_github1654() throws IOException { |
| 114 | + // @formatter:off |
| 115 | + runTest( |
| 116 | + true /* shouldCompileOK */, |
| 117 | + new String [] { /* sourceFiles */ |
| 118 | + "X.java", """ |
| 119 | + package p1; |
| 120 | + import org.eclipse.jdt.apt.tests.external.annotations.batch.BatchGen; |
| 121 | + @BatchGen |
| 122 | + public class X { |
| 123 | + } |
| 124 | + """, |
| 125 | + "Anno.java", """ |
| 126 | + package p1; |
| 127 | + public @interface Anno { |
| 128 | + public static final String V = "V"; |
| 129 | + String v() default ""; |
| 130 | + } |
| 131 | + """, |
| 132 | + "Breaks.java", """ |
| 133 | + package p2; |
| 134 | + import p1.Anno; |
| 135 | + import p1.gen.Class1; |
| 136 | + @Anno (v = Anno.V) |
| 137 | + public class Breaks { |
| 138 | + public Class1 c1; |
| 139 | + }; |
| 140 | + """, |
| 141 | + "Works1.java", """ |
| 142 | + package p2; |
| 143 | + import p1.Anno; |
| 144 | + import p1.gen.Class1; |
| 145 | + @Anno // (v = Anno.V) |
| 146 | + public class Works1 { |
| 147 | + public Class1 c1; |
| 148 | + }; |
| 149 | + """, |
| 150 | + "Works2.java", """ |
| 151 | + package p2; |
| 152 | + import p1.Anno; |
| 153 | + // import p1.gen.Class1; |
| 154 | + @Anno(v = Anno.V) |
| 155 | + public class Works2 { |
| 156 | + // public Class1 c1; |
| 157 | + public p1.gen.Class1 c1; |
| 158 | + }; |
| 159 | + """, |
| 160 | + }, |
| 161 | + null /* standardJavaFileManager */, |
| 162 | + Arrays.asList( |
| 163 | + "-d", OUTPUT_DIR, |
| 164 | + "-source", "1.6", |
| 165 | + "-g", "-preserveAllLocals", |
| 166 | + "-cp", OUTPUT_DIR + File.pathSeparator + _extJar.getAbsolutePath() , |
| 167 | + "-s", OUTPUT_DIR + File.separator + "src-gen", |
| 168 | + "-processorpath", _extJar.getAbsolutePath(), |
| 169 | + "-XprintProcessorInfo", |
| 170 | + // TODO: after fixing the issue, enable and update expected output of: |
| 171 | + // "-XprintRounds", |
| 172 | + "-proceedOnError" |
| 173 | + ) /* options */, |
| 174 | + new String[] { /* compileFileNames */ |
| 175 | + "X.java", |
| 176 | + "Anno.java", |
| 177 | + "Breaks.java", |
| 178 | + "Works1.java", |
| 179 | + "Works2.java" |
| 180 | + }, |
| 181 | + "Discovered processor service org.eclipse.jdt.apt.tests.external.annotations.batch.BatchGenProcessor\n" + |
| 182 | + " supporting [org.eclipse.jdt.apt.tests.external.annotations.batch.BatchGen]\n" + |
| 183 | + " in jar:" + Path.of(_extJar.getCanonicalPath()).toUri().toURL().toString() + "!/\n" + |
| 184 | + "Processor org.eclipse.jdt.apt.tests.external.annotations.batch.BatchGenProcessor matches [org.eclipse.jdt.apt.tests.external.annotations.batch.BatchGen] and returns true\n" + |
| 185 | + "Processor org.eclipse.jdt.apt.tests.external.annotations.batch.BatchGenProcessor matches [] and returns false\n", |
| 186 | + "" /* expectedErrOutputString */, |
| 187 | + true /* shouldFlushOutputDirectory */ ); |
| 188 | + // @formatter:on |
| 189 | + } |
| 190 | + |
112 | 191 | protected static class CompilerInvocationTestsArguments { |
113 | 192 | StandardJavaFileManager standardJavaFileManager; |
114 | 193 | List<String> options; |
|
0 commit comments