Bug 431823 - [1.8] Annotation validator reports @NoOverride not allowed
on default methods
Change-Id: I4d19b6516bf732968bf1cdc13a23f589372b05d5
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/AnnotationTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/AnnotationTest.java
index 4015621..9be90f3 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/AnnotationTest.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/AnnotationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
+ * Copyright (c) 2013, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -34,8 +34,8 @@
public abstract class AnnotationTest extends ApiBuilderTest {
// reuse the Javadoc tag project
- protected static IPath WORKSPACE_PATH = new Path("tagproject/src/a/b/c"); //$NON-NLS-1$
- protected static IPath WORKSPACE_PATH_DEFAULT = new Path("tagproject/src"); //$NON-NLS-1$
+ protected static IPath WORKSPACE_PATH = new Path("src/a/b/c"); //$NON-NLS-1$
+ protected static IPath WORKSPACE_PATH_DEFAULT = new Path("src"); //$NON-NLS-1$
/**
* Constructor
@@ -71,9 +71,12 @@
ValidAnnotationAnnotationsTests.class,
InvalidClassAnnotationsTests.class,
ValidClassAnnotationsTests.class,
+ InvalidInterfaceAnnotationTests.class,
+ ValidInterfaceAnnotationTests.class,
InvalidDuplicateAnnotationTests.class,
InvalidEnumAnnotationsTests.class,
- ValidEnumAnnotationsTests.class, FieldAnnotationTest.class };
+ ValidEnumAnnotationsTests.class, FieldAnnotationTest.class,
+ MethodAnnotationTest.class};
return classes;
}
@@ -212,9 +215,9 @@
*/
protected void deployAnnotationTest(String sourcename, boolean incremental, boolean usedefault) {
try {
- IPath path = WORKSPACE_PATH.append(sourcename);
+ IPath path = new Path(getTestingProjectName()).append(WORKSPACE_PATH).append(sourcename);
if (usedefault) {
- path = WORKSPACE_PATH_DEFAULT.append(sourcename);
+ path = new Path(getTestingProjectName()).append(WORKSPACE_PATH_DEFAULT).append(sourcename);
}
createWorkspaceFile(path, TestSuiteHelper.getPluginDirectoryPath().append(TEST_SOURCE_ROOT).append(getTestSourcePath()).append(sourcename));
if (incremental) {
@@ -240,9 +243,9 @@
*/
protected void deployAnnotationTestWithErrors(String sourcename, boolean incremental, boolean usedefault) {
try {
- IPath path = WORKSPACE_PATH.append(sourcename);
+ IPath path = new Path(getTestingProjectName()).append(WORKSPACE_PATH).append(sourcename);
if (usedefault) {
- path = WORKSPACE_PATH_DEFAULT.append(sourcename);
+ path = new Path(getTestingProjectName()).append(WORKSPACE_PATH_DEFAULT).append(sourcename);
}
createWorkspaceFile(path, TestSuiteHelper.getPluginDirectoryPath().append(TEST_SOURCE_ROOT).append(getTestSourcePath()).append(sourcename));
if (incremental) {
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/FieldAnnotationTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/FieldAnnotationTest.java
index 116f507..540a5a8 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/FieldAnnotationTest.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/FieldAnnotationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
+ * Copyright (c) 2013, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -48,23 +48,11 @@
return suite;
}
- /*
- * (non-Javadoc)
- * @see
- * org.eclipse.pde.api.tools.builder.tests.tags.TagTest#getDefaultProblemId
- * ()
- */
@Override
protected int getDefaultProblemId() {
return ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_USAGE, IElementDescriptor.FIELD, IApiProblem.UNSUPPORTED_ANNOTATION_USE, IApiProblem.NO_FLAGS);
}
- /*
- * (non-Javadoc)
- * @see
- * org.eclipse.pde.api.tools.builder.tests.ApiBuilderTests#getTestSourcePath
- * ()
- */
@Override
protected IPath getTestSourcePath() {
return super.getTestSourcePath().append("field"); //$NON-NLS-1$
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidClassAnnotationsTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidClassAnnotationsTests.java
index ebc5ec3..8ac5834 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidClassAnnotationsTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidClassAnnotationsTests.java
@@ -41,22 +41,11 @@
return buildTestSuite(InvalidClassAnnotationsTests.class);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.pde.api.tools.builder.tests.annotations.AnnotationTest#
- * getTestSourcePath()
- */
@Override
protected IPath getTestSourcePath() {
return super.getTestSourcePath().append("class"); //$NON-NLS-1$
}
- /*
- * (non-Javadoc)
- * @see
- * org.eclipse.pde.api.tools.builder.tests.ApiBuilderTest#getDefaultProblemId
- * ()
- */
@Override
protected int getDefaultProblemId() {
return ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_USAGE, IElementDescriptor.TYPE, IApiProblem.UNSUPPORTED_ANNOTATION_USE, IApiProblem.NO_FLAGS);
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidDefaultMethodAnnotationTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidDefaultMethodAnnotationTests.java
new file mode 100644
index 0000000..ef2861e
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidDefaultMethodAnnotationTests.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.api.tools.builder.tests.annotations;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.pde.api.tools.internal.builder.BuilderMessages;
+
+/**
+ * Tests invalid annotations on default interface methods
+ */
+public class InvalidDefaultMethodAnnotationTests extends MethodAnnotationTest {
+
+ /**
+ * @param name
+ */
+ public InvalidDefaultMethodAnnotationTests(String name) {
+ super(name);
+ }
+
+ @Override
+ protected String getTestCompliance() {
+ return JavaCore.VERSION_1_8;
+ }
+
+ @Override
+ protected IPath getTestSourcePath() {
+ return super.getTestSourcePath().append("interface"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected String getTestingProjectName() {
+ return "java8tags"; //$NON-NLS-1$
+ }
+
+ /**
+ * @return the test for this class
+ */
+ public static Test suite() {
+ return buildTestSuite(InvalidDefaultMethodAnnotationTests.class);
+ }
+
+ public void testInvalidJava8InterfaceMethodTag2I() {
+ x1(true);
+ }
+
+ public void testInvalidJava8InterfaceMethodTag2F() {
+ x1(false);
+ }
+
+ /**
+ * Tests the unsupported @NoOverride tag on non-default interface methods in
+ * Java 8 interfaces
+ */
+ private void x1(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemSet(2));
+ setExpectedMessageArgs(new String[][] {
+ {
+ "@NoOverride", BuilderMessages.TagValidator_nondefault_interface_method }, //$NON-NLS-1$
+ {
+ "@NoOverride", BuilderMessages.TagValidator_nondefault_interface_method } //$NON-NLS-1$
+ });
+ deployAnnotationTest("test1.java", inc, false); //$NON-NLS-1$
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidInterfaceAnnotationTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidInterfaceAnnotationTests.java
new file mode 100644
index 0000000..d96be9d
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidInterfaceAnnotationTests.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.api.tools.builder.tests.annotations;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.pde.api.tools.internal.builder.BuilderMessages;
+import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory;
+import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
+import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
+
+/**
+ *
+ */
+public class InvalidInterfaceAnnotationTests extends AnnotationTest {
+
+ /**
+ * @param name
+ */
+ public InvalidInterfaceAnnotationTests(String name) {
+ super(name);
+ }
+
+ /**
+ * @return the tests for this class
+ */
+ public static Test suite() {
+ return buildTestSuite(InvalidInterfaceAnnotationTests.class);
+ }
+
+ @Override
+ protected IPath getTestSourcePath() {
+ return super.getTestSourcePath().append("interface"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected int getDefaultProblemId() {
+ return ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_USAGE, IElementDescriptor.TYPE, IApiProblem.UNSUPPORTED_ANNOTATION_USE, IApiProblem.NO_FLAGS);
+ }
+
+ /**
+ * Tests @NoInstantiate on an interface
+ *
+ * @throws Exception
+ */
+ public void testNoInstantiateF() throws Exception {
+ x1(false);
+ }
+
+ /**
+ * Tests @NoInstantiate on an interface
+ *
+ * @throws Exception
+ */
+ public void testNoInstantiateI() throws Exception {
+ x1(true);
+ }
+
+ private void x1(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemIdSet(1));
+ setExpectedMessageArgs(new String[][] { {
+ "@NoInstantiate", BuilderMessages.TagValidator_an_interface } //$NON-NLS-1$
+ });
+ deployAnnotationTest("test1.java", inc, false); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests @NoOverride on an interface
+ *
+ * @throws Exception
+ */
+ public void testNoOverrideF() throws Exception {
+ x2(false);
+ }
+
+ /**
+ * Tests @NoOvveride on an interface
+ *
+ * @throws Exception
+ */
+ public void testNoOverrideI() throws Exception {
+ x2(true);
+ }
+
+ private void x2(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemIdSet(1));
+ setExpectedMessageArgs(new String[][] { {
+ "@NoOverride", BuilderMessages.TagValidator_an_interface } //$NON-NLS-1$
+ });
+ deployAnnotationTestWithErrors("test2.java", inc, false); //$NON-NLS-1$
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidInterfaceMethodAnnotationTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidInterfaceMethodAnnotationTests.java
new file mode 100644
index 0000000..3a9ae5c
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/InvalidInterfaceMethodAnnotationTests.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.api.tools.builder.tests.annotations;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.pde.api.tools.internal.builder.BuilderMessages;
+
+/**
+ * Tests invalid annotations on interface methods
+ *
+ * @since 1.0.600
+ */
+public class InvalidInterfaceMethodAnnotationTests extends MethodAnnotationTest {
+
+ /**
+ * @param name
+ */
+ public InvalidInterfaceMethodAnnotationTests(String name) {
+ super(name);
+ }
+
+ @Override
+ protected IPath getTestSourcePath() {
+ return super.getTestSourcePath().append("interface"); //$NON-NLS-1$
+ }
+
+ /**
+ * @return the test for this class
+ */
+ public static Test suite() {
+ return buildTestSuite(InvalidInterfaceMethodAnnotationTests.class);
+ }
+
+ public void testNoInstantiateF() throws Exception {
+ x1(false);
+ }
+
+ public void testNoInstantiateI() throws Exception {
+ x1(true);
+ }
+
+ void x1(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemIdSet(1));
+ setExpectedMessageArgs(new String[][] { {
+ "@NoInstantiate", BuilderMessages.TagValidator_an_interface_method }, //$NON-NLS-1$
+ });
+ deployAnnotationTestWithErrors("test2.java", inc, false); //$NON-NLS-1$
+ }
+
+ public void testNoImplementF() throws Exception {
+ x2(false);
+ }
+
+ public void testNoImplementI() throws Exception {
+ x2(true);
+ }
+
+ void x2(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemIdSet(1));
+ setExpectedMessageArgs(new String[][] { {
+ "@NoImplement", BuilderMessages.TagValidator_an_interface_method }, //$NON-NLS-1$
+ });
+ deployAnnotationTestWithErrors("test3.java", inc, false); //$NON-NLS-1$
+ }
+
+ public void testNoExtendF() throws Exception {
+ x3(false);
+ }
+
+ public void testNoExtendI() throws Exception {
+ x3(true);
+ }
+
+ void x3(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemIdSet(1));
+ setExpectedMessageArgs(new String[][] { {
+ "@NoExtend", BuilderMessages.TagValidator_an_interface_method }, //$NON-NLS-1$
+ });
+ deployAnnotationTestWithErrors("test4.java", inc, false); //$NON-NLS-1$
+ }
+
+ public void testNoOverrideF() throws Exception {
+ x4(false);
+ }
+
+ public void testNoOverrideI() throws Exception {
+ x4(true);
+ }
+
+ void x4(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemIdSet(1));
+ setExpectedMessageArgs(new String[][] { {
+ "@NoOverride", BuilderMessages.TagValidator_nondefault_interface_method }, //$NON-NLS-1$
+ });
+ deployAnnotationTest("test5.java", inc, false); //$NON-NLS-1$
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/MethodAnnotationTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/MethodAnnotationTest.java
new file mode 100644
index 0000000..7f638c3
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/MethodAnnotationTest.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.api.tools.builder.tests.annotations;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.tests.junit.extension.TestCase;
+import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory;
+import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
+import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
+
+/**
+ * Abstract class for method annotation tests
+ *
+ * @since 1.0.600
+ */
+public abstract class MethodAnnotationTest extends AnnotationTest {
+
+ /**
+ * @param name
+ */
+ public MethodAnnotationTest(String name) {
+ super(name);
+ }
+
+ /**
+ * @return the tests for this class
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite(MethodAnnotationTest.class.getName());
+ collectTests(suite);
+ return suite;
+ }
+
+ @Override
+ protected int getDefaultProblemId() {
+ return ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_USAGE, IElementDescriptor.METHOD, IApiProblem.UNSUPPORTED_ANNOTATION_USE, IApiProblem.NO_FLAGS);
+ }
+
+ @Override
+ protected IPath getTestSourcePath() {
+ return super.getTestSourcePath().append("method"); //$NON-NLS-1$
+ }
+
+ /**
+ * @return all of the child test classes of this class
+ */
+ private static Class<?>[] getAllTestClasses() {
+ Class<?>[] classes = new Class[] {
+ ValidDefaultMethodAnnotationTests.class,
+ InvalidDefaultMethodAnnotationTests.class,
+ InvalidInterfaceMethodAnnotationTests.class,
+ ValidInterfaceMethodAnnotationTests.class };
+ return classes;
+ }
+
+ /**
+ * Collects tests from the getAllTestClasses() method into the given suite
+ *
+ * @param suite
+ */
+ private static void collectTests(TestSuite suite) {
+ // Hack to load all classes before computing their suite of test cases
+ // this allow to reset test cases subsets while running all Builder
+ // tests...
+ Class<?>[] classes = getAllTestClasses();
+
+ // Reset forgotten subsets of tests
+ TestCase.TESTS_PREFIX = null;
+ TestCase.TESTS_NAMES = null;
+ TestCase.TESTS_NUMBERS = null;
+ TestCase.TESTS_RANGE = null;
+ TestCase.RUN_ONLY_ID = null;
+
+ /* tests */
+ for (int i = 0, length = classes.length; i < length; i++) {
+ Class<?> clazz = classes[i];
+ Method suiteMethod;
+ try {
+ suiteMethod = clazz.getDeclaredMethod("suite", new Class[0]); //$NON-NLS-1$
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ continue;
+ }
+ Object test;
+ try {
+ test = suiteMethod.invoke(null, new Object[0]);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ continue;
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ continue;
+ }
+ suite.addTest((Test) test);
+ }
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/ValidDefaultMethodAnnotationTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/ValidDefaultMethodAnnotationTests.java
new file mode 100644
index 0000000..7b30ae2
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/ValidDefaultMethodAnnotationTests.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.api.tools.builder.tests.annotations;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.JavaCore;
+
+/**
+ * Tests valid annotations on interface default methods
+ *
+ * @since 1.0.600
+ */
+public class ValidDefaultMethodAnnotationTests extends MethodAnnotationTest {
+
+ /**
+ * @param name
+ */
+ public ValidDefaultMethodAnnotationTests(String name) {
+ super(name);
+ }
+
+ @Override
+ protected String getTestCompliance() {
+ return JavaCore.VERSION_1_8;
+ }
+
+ @Override
+ protected IPath getTestSourcePath() {
+ return super.getTestSourcePath().append("interface").append("valid"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ protected String getTestingProjectName() {
+ return "java8tags"; //$NON-NLS-1$
+ }
+
+ /**
+ * @return the test for this class
+ */
+ public static Test suite() {
+ return buildTestSuite(ValidDefaultMethodAnnotationTests.class);
+ }
+
+ public void testNoOverrideAnnotOnDefaultI() {
+ x1(true);
+ }
+
+ public void testNoOverrideAnnotOnDefaultF() {
+ x1(false);
+ }
+
+ /**
+ * Tests the @NoOverride tag on a default method
+ */
+ private void x1(boolean inc) {
+ deployAnnotationTest("test1.java", inc, false); //$NON-NLS-1$
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/ValidInterfaceAnnotationTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/ValidInterfaceAnnotationTests.java
new file mode 100644
index 0000000..8db9eb1
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/ValidInterfaceAnnotationTests.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.api.tools.builder.tests.annotations;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Tests valid annotations on interfaces
+ *
+ * @since 1.0.600
+ */
+public class ValidInterfaceAnnotationTests extends InvalidInterfaceAnnotationTests {
+
+ /**
+ * @param name
+ */
+ public ValidInterfaceAnnotationTests(String name) {
+ super(name);
+ }
+
+ /**
+ * @return the tests for this class
+ */
+ public static Test suite() {
+ return buildTestSuite(ValidInterfaceAnnotationTests.class);
+ }
+
+ @Override
+ protected IPath getTestSourcePath() {
+ return super.getTestSourcePath().append("valid"); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests @NoImplement annotation on interfaces
+ *
+ * @throws Exception
+ */
+ public void testNoImplementF() throws Exception {
+ x1(false);
+ }
+
+ /**
+ * Tests @NoImplement annotation on interfaces
+ *
+ * @throws Exception
+ */
+ public void testNoImplementI() throws Exception {
+ x1(true);
+ }
+
+ private void x1(boolean inc) {
+ deployAnnotationTest("test1.java", inc, false); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests @NoExtend annotation on interfaces
+ *
+ * @throws Exception
+ */
+ public void testNoExtendF() throws Exception {
+ x2(false);
+ }
+
+ /**
+ * Tests @NoExtend annotation on interfaces
+ *
+ * @throws Exception
+ */
+ public void testNoExtendI() throws Exception {
+ x2(true);
+ }
+
+ private void x2(boolean inc) {
+ deployAnnotationTest("test2.java", inc, false); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests @NoReference annotation on interfaces
+ *
+ * @throws Exception
+ */
+ public void testNoReferenceF() throws Exception {
+ x3(false);
+ }
+
+ /**
+ * Tests @NoReference annotation on interfaces
+ *
+ * @throws Exception
+ */
+ public void testNoReferenceI() throws Exception {
+ x3(true);
+ }
+
+ private void x3(boolean inc) {
+ deployAnnotationTest("test3.java", inc, false); //$NON-NLS-1$
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/ValidInterfaceMethodAnnotationTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/ValidInterfaceMethodAnnotationTests.java
new file mode 100644
index 0000000..c2030b3
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/ValidInterfaceMethodAnnotationTests.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.api.tools.builder.tests.annotations;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Tests valid annotations on interface methods
+ *
+ * @since 1.0.600
+ */
+public class ValidInterfaceMethodAnnotationTests extends InvalidInterfaceMethodAnnotationTests {
+
+ public ValidInterfaceMethodAnnotationTests(String name) {
+ super(name);
+ }
+
+ @Override
+ protected IPath getTestSourcePath() {
+ return super.getTestSourcePath().append("valid"); //$NON-NLS-1$
+ }
+
+ /**
+ * @return the test for this class
+ */
+ public static Test suite() {
+ return buildTestSuite(ValidInterfaceMethodAnnotationTests.class);
+ }
+
+ /**
+ * Tests the valid @NoReferrence annotation on interface methods
+ *
+ * @throws Exception
+ */
+ public void testNoReferenceF() throws Exception {
+ x1(false);
+ }
+
+ /**
+ * Tests the valid @NoReferrence annotation on interface methods
+ *
+ * @throws Exception
+ */
+ public void testNoReferenceI() throws Exception {
+ x1(true);
+ }
+
+ @Override
+ void x1(boolean inc) {
+ deployAnnotationTest("test2.java", inc, false); //$NON-NLS-1$
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/test1.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/test1.java
new file mode 100644
index 0000000..54bb7bf
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/test1.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoInstantiate;
+
+@NoInstantiate
+public interface test1 {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/test2.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/test2.java
new file mode 100644
index 0000000..4f97e94
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/test2.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoOverride;
+
+@NoOverride
+public interface test2 {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/valid/test1.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/valid/test1.java
new file mode 100644
index 0000000..c7c2092
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/valid/test1.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoImplement;
+
+@NoImplement
+public interface test1 {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/valid/test2.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/valid/test2.java
new file mode 100644
index 0000000..107cb70
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/valid/test2.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoExtend;
+
+@NoExtend
+public interface test2 {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/valid/test3.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/valid/test3.java
new file mode 100644
index 0000000..3b569df
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/interface/valid/test3.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoReference;
+
+@NoReference
+public interface test3 {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test1.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test1.java
new file mode 100644
index 0000000..1f9abdd
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test1.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoOverride;
+
+/**
+ * Tests invalid @NoOverride annotation on nested inner interfaces
+ */
+public interface test1 {
+
+ @NoOverride
+ int m1();
+
+ interface inner {
+ @NoOverride
+ int m1();
+ }
+
+}
+
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test2.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test2.java
new file mode 100644
index 0000000..4e25338
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test2.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoInstantiate;
+
+/**
+ * Tests invalid @NoInstantiate annotation on an interface method
+ */
+public interface test2 {
+ @NoInstantiate
+ void m1();
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test3.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test3.java
new file mode 100644
index 0000000..0742001
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test3.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoImplement;
+
+
+public interface test3 {
+
+ @NoImplement
+ void m1();
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test4.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test4.java
new file mode 100644
index 0000000..bea2b24
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test4.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoExtend;
+
+/**
+ *
+ */
+public interface test4 {
+ @NoExtend
+ void m1();
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test5.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test5.java
new file mode 100644
index 0000000..bc65488
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/test5.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoOverride;
+
+public interface test5 {
+
+ @NoOverride
+ void m1();
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/valid/test1.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/valid/test1.java
new file mode 100644
index 0000000..d35da4f
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/valid/test1.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoOverride;
+import org.eclipse.pde.api.tools.annotations.NoReference;
+
+/**
+ *
+ */
+public interface test1 {
+ @NoOverride
+ @NoReference
+ default int m1() {
+ return 1;
+ }
+
+ interface inner {
+ @NoOverride
+ @NoReference
+ default int m1() {
+ return 1;
+ }
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/valid/test2.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/valid/test2.java
new file mode 100644
index 0000000..a76738f
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/annotations/method/interface/valid/test2.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) Apr 2, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+import org.eclipse.pde.api.tools.annotations.NoReference;
+
+public interface test2 {
+ @NoReference
+ void m1();
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tagprojects/java8tags/META-INF/MANIFEST.MF b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tagprojects/java8tags/META-INF/MANIFEST.MF
index 473db98..e0ca566 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tagprojects/java8tags/META-INF/MANIFEST.MF
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tagprojects/java8tags/META-INF/MANIFEST.MF
@@ -3,6 +3,7 @@
Bundle-Name: java8tags
Bundle-SymbolicName: java8tags
Bundle-Version: 1.0.0.qualifier
-Require-Bundle: org.eclipse.core.runtime
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.pde.api.tools.annotations;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: a.b.c
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java
index ebfcf77..a0428fa 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java
@@ -234,12 +234,12 @@
annots.add(ANNOTATION_NOOVERRIDE);
annots.add(ANNOTATION_NOREFERENCE);
fAnnotationCache.put(new Key(IApiJavadocTag.TYPE_CLASS, IApiJavadocTag.MEMBER_METHOD), annots);
+ fAnnotationCache.put(new Key(IApiJavadocTag.TYPE_CLASS, IApiJavadocTag.MEMBER_CONSTRUCTOR), annots);
+ fAnnotationCache.put(new Key(IApiJavadocTag.TYPE_INTERFACE, IApiJavadocTag.MEMBER_METHOD), annots);
annots = new HashSet<String>();
annots.add(ANNOTATION_NOREFERENCE);
fAnnotationCache.put(new Key(IApiJavadocTag.TYPE_CLASS, IApiJavadocTag.MEMBER_FIELD), annots);
- fAnnotationCache.put(new Key(IApiJavadocTag.TYPE_CLASS, IApiJavadocTag.MEMBER_CONSTRUCTOR), annots);
fAnnotationCache.put(new Key(IApiJavadocTag.TYPE_INTERFACE, IApiJavadocTag.MEMBER_FIELD), annots);
- fAnnotationCache.put(new Key(IApiJavadocTag.TYPE_INTERFACE, IApiJavadocTag.MEMBER_METHOD), annots);
fAnnotationCache.put(new Key(IApiJavadocTag.TYPE_ANNOTATION, IApiJavadocTag.MEMBER_NONE), annots);
fAnnotationCache.put(new Key(IApiJavadocTag.TYPE_ENUM, IApiJavadocTag.MEMBER_NONE), annots);
fAnnotationCache.put(new Key(IApiJavadocTag.TYPE_ENUM, IApiJavadocTag.MEMBER_FIELD), annots);
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java
index c3fb67c..df3bce8 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java
@@ -694,7 +694,7 @@
createAnnotationProblem(item.typename, node, IElementDescriptor.METHOD, IApiProblem.UNSUPPORTED_ANNOTATION_USE, IApiMarkerConstants.UNSUPPORTED_ANNOTATION_MARKER_ID, BuilderMessages.TagValidator_an_interface_method);
} else if (!item.visible) {
createAnnotationProblem(item.typename, node, IElementDescriptor.METHOD, IApiProblem.UNSUPPORTED_ANNOTATION_USE, IApiMarkerConstants.UNSUPPORTED_ANNOTATION_MARKER_ID, BuilderMessages.TagValidator_not_visible_interface_method);
- } else if (!Flags.isDefaultMethod(flags) && JavadocTagManager.TAG_NOOVERRIDE.equals(name)) {
+ } else if (!Flags.isDefaultMethod(flags) && JavadocTagManager.ANNOTATION_NOOVERRIDE.equals(name)) {
createAnnotationProblem(item.typename, node, IElementDescriptor.METHOD, IApiProblem.UNSUPPORTED_ANNOTATION_USE, IApiMarkerConstants.UNSUPPORTED_ANNOTATION_MARKER_ID, BuilderMessages.TagValidator_nondefault_interface_method);
}
break;