Skip to content

Commit 3cea1a7

Browse files
Avoid dependency on org.eclipse.jdt.annotation_v1 (#1712)
+ replace by a local copy used in tests See eclipse-jdt/eclipse.jdt.core#3027
1 parent f4ed0c2 commit 3cea1a7

File tree

5 files changed

+34
-43
lines changed

5 files changed

+34
-43
lines changed

org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Require-Bundle:
4848
org.eclipse.debug.ui,
4949
org.eclipse.jdt.core,
5050
org.eclipse.jdt.core.manipulation,
51-
org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)";resolution:=optional,
5251
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
5352
org.eclipse.jdt.junit,
5453
org.eclipse.jdt.junit.runtime,

org.eclipse.jdt.ui.tests/build.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ bin.includes = plugin.xml,\
1717
testresources/,\
1818
.,\
1919
META-INF/,\
20-
plugin.properties
20+
plugin.properties,\
21+
lib/org.eclipse.jdt.annotation_1.2.100.v20241001-0914.jar
2122
source.. = examples/,\
2223
chkpii/,\
2324
test plugin/,\
Binary file not shown.

org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
import static org.junit.Assert.assertFalse;
1919
import static org.junit.Assert.assertTrue;
2020

21-
import java.io.File;
21+
import java.io.IOException;
22+
import java.net.URL;
2223
import java.util.ArrayList;
2324
import java.util.Hashtable;
2425

2526
import org.junit.After;
2627
import org.junit.Before;
2728
import org.junit.Rule;
2829
import org.junit.Test;
29-
import org.osgi.framework.Bundle;
3030

3131
import org.eclipse.jdt.testplugin.JavaProjectHelper;
3232
import org.eclipse.jdt.testplugin.TestOptions;
@@ -111,19 +111,19 @@ public void setUp() throws Exception {
111111
fJProject1= projectSetup.getProject();
112112

113113
if (ANNOTATION_JAR_PATH == null) {
114-
String version= "[1.1.0,2.0.0)"; // tests run at 1.5, need the "old" null annotations
115-
Bundle[] bundles= Platform.getBundles("org.eclipse.jdt.annotation", version);
116-
File bundleFile= FileLocator.getBundleFileLocation(bundles[0]).get();
117-
if (bundleFile.isDirectory())
118-
ANNOTATION_JAR_PATH= bundleFile.getPath() + "/bin";
119-
else
120-
ANNOTATION_JAR_PATH= bundleFile.getPath();
114+
// these tests us the "old" null annotations
115+
ANNOTATION_JAR_PATH= getAnnotationV1LibPath();
121116
}
122117
JavaProjectHelper.addLibrary(fJProject1, new Path(ANNOTATION_JAR_PATH));
123118

124119
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
125120
}
126121

122+
public static String getAnnotationV1LibPath() throws IOException {
123+
URL libEntry = Platform.getBundle("org.eclipse.jdt.ui.tests").getEntry("/lib/org.eclipse.jdt.annotation_1.2.100.v20241001-0914.jar");
124+
return FileLocator.toFileURL(libEntry).getPath();
125+
}
126+
127127
@After
128128
public void tearDown() throws Exception {
129129
JavaProjectHelper.clear(fJProject1, projectSetup.getDefaultClasspath());

org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest1d8Mix.java

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,18 @@
1313
*******************************************************************************/
1414
package org.eclipse.jdt.ui.tests.quickfix;
1515

16-
import java.io.File;
1716
import java.util.ArrayList;
1817
import java.util.Hashtable;
1918

2019
import org.junit.After;
2120
import org.junit.Before;
2221
import org.junit.Rule;
2322
import org.junit.Test;
24-
import org.osgi.framework.Bundle;
2523

2624
import org.eclipse.jdt.testplugin.JavaProjectHelper;
2725
import org.eclipse.jdt.testplugin.TestOptions;
2826

29-
import org.eclipse.core.runtime.FileLocator;
3027
import org.eclipse.core.runtime.Path;
31-
import org.eclipse.core.runtime.Platform;
3228

3329
import org.eclipse.jface.preference.IPreferenceStore;
3430

@@ -94,13 +90,8 @@ public void setUp() throws Exception {
9490
fJProject1= projectSetup.getProject();
9591

9692
if (ANNOTATION_JAR_PATH == null) {
97-
String version= "[1.1.0,2.0.0)"; // tests run at 1.8, but still use "old" null annotations
98-
Bundle[] bundles= Platform.getBundles("org.eclipse.jdt.annotation", version);
99-
File bundleFile= FileLocator.getBundleFileLocation(bundles[0]).get();
100-
if (bundleFile.isDirectory())
101-
ANNOTATION_JAR_PATH= bundleFile.getPath() + "/bin";
102-
else
103-
ANNOTATION_JAR_PATH= bundleFile.getPath();
93+
// tests run at 1.8, but still use "old" null annotations:
94+
ANNOTATION_JAR_PATH= NullAnnotationsQuickFixTest.getAnnotationV1LibPath();
10495
}
10596
JavaProjectHelper.addLibrary(fJProject1, new Path(ANNOTATION_JAR_PATH));
10697

@@ -121,9 +112,9 @@ public void testBug473068_elided() throws Exception {
121112
IPackageFragment pack1= fSourceFolder.createPackageFragment("testNullAnnotations", false, null);
122113
String str= """
123114
package testNullAnnotations;
124-
115+
125116
import org.eclipse.jdt.annotation.NonNull;
126-
117+
127118
interface Consumer<T> {
128119
void accept(T t);
129120
}
@@ -134,7 +125,7 @@ public void select(final double min, final double max) {
134125
}
135126
\t
136127
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
137-
128+
138129
}
139130
private void updateSelectionData(final @NonNull Object data) {
140131
}
@@ -152,10 +143,10 @@ private void updateSelectionData(final @NonNull Object data) {
152143

153144
String str1= """
154145
package testNullAnnotations;
155-
146+
156147
import org.eclipse.jdt.annotation.NonNull;
157148
import org.eclipse.jdt.annotation.Nullable;
158-
149+
159150
interface Consumer<T> {
160151
void accept(T t);
161152
}
@@ -166,7 +157,7 @@ public void select(final double min, final double max) {
166157
}
167158
\t
168159
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
169-
160+
170161
}
171162
private void updateSelectionData(final @Nullable Object data) {
172163
}
@@ -179,9 +170,9 @@ private void updateSelectionData(final @Nullable Object data) {
179170

180171
String str2= """
181172
package testNullAnnotations;
182-
173+
183174
import org.eclipse.jdt.annotation.NonNull;
184-
175+
185176
interface Consumer<T> {
186177
void accept(T t);
187178
}
@@ -193,7 +184,7 @@ public void select(final double min, final double max) {
193184
}
194185
\t
195186
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
196-
187+
197188
}
198189
private void updateSelectionData(final @NonNull Object data) {
199190
}
@@ -212,9 +203,9 @@ public void testBug473068_explicit_type() throws Exception {
212203
IPackageFragment pack1= fSourceFolder.createPackageFragment("testNullAnnotations", false, null);
213204
String str= """
214205
package testNullAnnotations;
215-
206+
216207
import org.eclipse.jdt.annotation.NonNull;
217-
208+
218209
interface Consumer<T> {
219210
void accept(T t);
220211
}
@@ -225,7 +216,7 @@ public void select(final double min, final double max) {
225216
}
226217
\t
227218
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
228-
219+
229220
}
230221
private void updateSelectionData(final @NonNull Object data) {
231222
}
@@ -243,9 +234,9 @@ private void updateSelectionData(final @NonNull Object data) {
243234

244235
String str1= """
245236
package testNullAnnotations;
246-
237+
247238
import org.eclipse.jdt.annotation.NonNull;
248-
239+
249240
interface Consumer<T> {
250241
void accept(T t);
251242
}
@@ -256,7 +247,7 @@ public void select(final double min, final double max) {
256247
}
257248
\t
258249
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
259-
250+
260251
}
261252
private void updateSelectionData(final @NonNull Object data) {
262253
}
@@ -269,10 +260,10 @@ private void updateSelectionData(final @NonNull Object data) {
269260

270261
String str2= """
271262
package testNullAnnotations;
272-
263+
273264
import org.eclipse.jdt.annotation.NonNull;
274265
import org.eclipse.jdt.annotation.Nullable;
275-
266+
276267
interface Consumer<T> {
277268
void accept(T t);
278269
}
@@ -283,7 +274,7 @@ public void select(final double min, final double max) {
283274
}
284275
\t
285276
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
286-
277+
287278
}
288279
private void updateSelectionData(final @Nullable Object data) {
289280
}
@@ -296,9 +287,9 @@ private void updateSelectionData(final @Nullable Object data) {
296287

297288
String str3= """
298289
package testNullAnnotations;
299-
290+
300291
import org.eclipse.jdt.annotation.NonNull;
301-
292+
302293
interface Consumer<T> {
303294
void accept(T t);
304295
}
@@ -310,7 +301,7 @@ public void select(final double min, final double max) {
310301
}
311302
\t
312303
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
313-
304+
314305
}
315306
private void updateSelectionData(final @NonNull Object data) {
316307
}

0 commit comments

Comments
 (0)