Skip to content

Commit

Permalink
Avoid dependency on org.eclipse.jdt.annotation_v1
Browse files Browse the repository at this point in the history
+ replace by a local copy used in tests

See eclipse-jdt/eclipse.jdt.core#3027
  • Loading branch information
stephan-herrmann committed Oct 13, 2024
1 parent 5da0735 commit afba14e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 43 deletions.
1 change: 0 additions & 1 deletion org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Require-Bundle:
org.eclipse.debug.ui,
org.eclipse.jdt.core,
org.eclipse.jdt.core.manipulation,
org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)";resolution:=optional,
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
org.eclipse.jdt.junit,
org.eclipse.jdt.junit.runtime,
Expand Down
3 changes: 2 additions & 1 deletion org.eclipse.jdt.ui.tests/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ bin.includes = plugin.xml,\
testresources/,\
.,\
META-INF/,\
plugin.properties
plugin.properties,\
lib/org.eclipse.jdt.annotation_1.2.100.v20241001-0914.jar
source.. = examples/,\
chkpii/,\
test plugin/,\
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Hashtable;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.osgi.framework.Bundle;

import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestOptions;
Expand Down Expand Up @@ -111,19 +111,19 @@ public void setUp() throws Exception {
fJProject1= projectSetup.getProject();

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

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

public static String getAnnotationV1LibPath() throws IOException {
URL libEntry = Platform.getBundle("org.eclipse.jdt.ui.tests").getEntry("/lib/org.eclipse.jdt.annotation_1.2.100.v20241001-0914.jar");
return FileLocator.toFileURL(libEntry).getPath();
}

@After
public void tearDown() throws Exception {
JavaProjectHelper.clear(fJProject1, projectSetup.getDefaultClasspath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,18 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.quickfix;

import java.io.File;
import java.util.ArrayList;
import java.util.Hashtable;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.osgi.framework.Bundle;

import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestOptions;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;

import org.eclipse.jface.preference.IPreferenceStore;

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

if (ANNOTATION_JAR_PATH == null) {
String version= "[1.1.0,2.0.0)"; // tests run at 1.8, but still use "old" null annotations
Bundle[] bundles= Platform.getBundles("org.eclipse.jdt.annotation", version);
File bundleFile= FileLocator.getBundleFileLocation(bundles[0]).get();
if (bundleFile.isDirectory())
ANNOTATION_JAR_PATH= bundleFile.getPath() + "/bin";
else
ANNOTATION_JAR_PATH= bundleFile.getPath();
// tests run at 1.8, but still use "old" null annotations:
ANNOTATION_JAR_PATH= NullAnnotationsQuickFixTest.getAnnotationV1LibPath();
}
JavaProjectHelper.addLibrary(fJProject1, new Path(ANNOTATION_JAR_PATH));

Expand All @@ -121,9 +112,9 @@ public void testBug473068_elided() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("testNullAnnotations", false, null);
String str= """
package testNullAnnotations;
import org.eclipse.jdt.annotation.NonNull;
interface Consumer<T> {
void accept(T t);
}
Expand All @@ -134,7 +125,7 @@ public void select(final double min, final double max) {
}
\t
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
}
private void updateSelectionData(final @NonNull Object data) {
}
Expand All @@ -152,10 +143,10 @@ private void updateSelectionData(final @NonNull Object data) {

String str1= """
package testNullAnnotations;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
interface Consumer<T> {
void accept(T t);
}
Expand All @@ -166,7 +157,7 @@ public void select(final double min, final double max) {
}
\t
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
}
private void updateSelectionData(final @Nullable Object data) {
}
Expand All @@ -179,9 +170,9 @@ private void updateSelectionData(final @Nullable Object data) {

String str2= """
package testNullAnnotations;
import org.eclipse.jdt.annotation.NonNull;
interface Consumer<T> {
void accept(T t);
}
Expand All @@ -193,7 +184,7 @@ public void select(final double min, final double max) {
}
\t
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
}
private void updateSelectionData(final @NonNull Object data) {
}
Expand All @@ -212,9 +203,9 @@ public void testBug473068_explicit_type() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("testNullAnnotations", false, null);
String str= """
package testNullAnnotations;
import org.eclipse.jdt.annotation.NonNull;
interface Consumer<T> {
void accept(T t);
}
Expand All @@ -225,7 +216,7 @@ public void select(final double min, final double max) {
}
\t
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
}
private void updateSelectionData(final @NonNull Object data) {
}
Expand All @@ -243,9 +234,9 @@ private void updateSelectionData(final @NonNull Object data) {

String str1= """
package testNullAnnotations;
import org.eclipse.jdt.annotation.NonNull;
interface Consumer<T> {
void accept(T t);
}
Expand All @@ -256,7 +247,7 @@ public void select(final double min, final double max) {
}
\t
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
}
private void updateSelectionData(final @NonNull Object data) {
}
Expand All @@ -269,10 +260,10 @@ private void updateSelectionData(final @NonNull Object data) {

String str2= """
package testNullAnnotations;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
interface Consumer<T> {
void accept(T t);
}
Expand All @@ -283,7 +274,7 @@ public void select(final double min, final double max) {
}
\t
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
}
private void updateSelectionData(final @Nullable Object data) {
}
Expand All @@ -296,9 +287,9 @@ private void updateSelectionData(final @Nullable Object data) {

String str3= """
package testNullAnnotations;
import org.eclipse.jdt.annotation.NonNull;
interface Consumer<T> {
void accept(T t);
}
Expand All @@ -310,7 +301,7 @@ public void select(final double min, final double max) {
}
\t
private void doStuff(int a, int b, final double min, final double max, Consumer<Object> postAction) {
}
private void updateSelectionData(final @NonNull Object data) {
}
Expand Down

0 comments on commit afba14e

Please sign in to comment.