Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Chandra2016-12-13 15:00:53 +0000
committerVikas Chandra2016-12-13 15:00:53 +0000
commit06356d4863cb71d796fdb8e989d93fc46085d14d (patch)
tree6f13872e236ae3b169819cc95327c3d165126413
parent2e660c305d1677979d4d6667e287ddbdf444c8b6 (diff)
downloadeclipse.pde.ui-06356d4863cb71d796fdb8e989d93fc46085d14d.tar.gz
eclipse.pde.ui-06356d4863cb71d796fdb8e989d93fc46085d14d.tar.xz
eclipse.pde.ui-06356d4863cb71d796fdb8e989d93fc46085d14d.zip
Bug 507701 - @noreference should not exclude all overriding methods from
API change analysis Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/MissingSinceTagTests.java19
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/baseline/bundle.a/src/a/since/AddInheritedBase.java24
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/baseline/bundle.a/src/a/since/AddInheritedMethod2.java18
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/compat/since/AddInheritedBase.java24
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/compat/since/AddInheritedMethod2.java20
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java27
6 files changed, 132 insertions, 0 deletions
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/MissingSinceTagTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/MissingSinceTagTests.java
index cbc2c4effe..4efdbdd036 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/MissingSinceTagTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/MissingSinceTagTests.java
@@ -191,6 +191,25 @@ public class MissingSinceTagTests extends SinceTagTest {
}
/**
+ * Tests that @noreference should not exclude all overriding methods from
+ * API change analysis - See bug 507701
+ */
+ private void xAddInheritedMethod2(boolean incremental) throws Exception {
+ IPath filePath = WORKSPACE_CLASSES_PACKAGE_A.append("AddInheritedMethod2.java"); //$NON-NLS-1$
+ // expect a since tag
+ configureExpectedProblems(IDelta.METHOD_ELEMENT_TYPE, "newMethod()"); //$NON-NLS-1$
+ performCompatibilityTest(filePath, incremental);
+ }
+
+ public void testAddInheritedMethodI2() throws Exception {
+ xAddInheritedMethod2(true);
+ }
+
+ public void testAddInheritedMethodF2() throws Exception {
+ xAddInheritedMethod2(false);
+ }
+
+ /**
* Tests adding a non-visible method
*/
private void xAddNonVisibleMethod(boolean incremental) throws Exception {
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/baseline/bundle.a/src/a/since/AddInheritedBase.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/baseline/bundle.a/src/a/since/AddInheritedBase.java
new file mode 100644
index 0000000000..7600390bf6
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/baseline/bundle.a/src/a/since/AddInheritedBase.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.since;
+
+/**
+ *
+ */
+public class AddInheritedBase {
+ /**
+ *
+ * @noreference
+ */
+ public void newMethod() {
+ }
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/baseline/bundle.a/src/a/since/AddInheritedMethod2.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/baseline/bundle.a/src/a/since/AddInheritedMethod2.java
new file mode 100644
index 0000000000..0d06c69f18
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/baseline/bundle.a/src/a/since/AddInheritedMethod2.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.since;
+
+/**
+ *
+ */
+public class AddInheritedMethod2 extends AddInheritedBase{
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/compat/since/AddInheritedBase.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/compat/since/AddInheritedBase.java
new file mode 100644
index 0000000000..7600390bf6
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/compat/since/AddInheritedBase.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.since;
+
+/**
+ *
+ */
+public class AddInheritedBase {
+ /**
+ *
+ * @noreference
+ */
+ public void newMethod() {
+ }
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/compat/since/AddInheritedMethod2.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/compat/since/AddInheritedMethod2.java
new file mode 100644
index 0000000000..ba75c90261
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/compat/since/AddInheritedMethod2.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.since;
+
+/**
+ *
+ */
+public class AddInheritedMethod2 extends AddInheritedBase{
+ public void newMethod() {
+ }
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java
index 7257030730..4790310a7f 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java
@@ -2104,6 +2104,18 @@ public class ClassFileComparator {
} else {
int access3 = method3.getModifiers();
if (Flags.isPublic(access3) || Flags.isProtected(access3)) {
+ IApiAnnotations apiAnnotations = null;
+ if (apiDescription != null) {
+ apiAnnotations = apiDescription.resolveAnnotations(method3.getHandle());
+ }
+ if (apiAnnotations != null) {
+ int restrictions = apiAnnotations.getRestrictions();
+ // if overriding no reference method, break the loop and report method addition
+ if (RestrictionModifiers.isReferenceRestriction(restrictions)) {
+ found = false;
+ break loop;
+ }
+ }
// method has been move up in the
// hierarchy - report the delta and
// abort loop
@@ -2153,6 +2165,21 @@ public class ClassFileComparator {
} else {
int access3 = method3.getModifiers();
if (Flags.isPublic(access3) || Flags.isProtected(access3)) {
+ IApiAnnotations apiAnnotations = null;
+ if (apiDescription != null) {
+ apiAnnotations = apiDescription.resolveAnnotations(method3.getHandle());
+ }
+ if (apiAnnotations != null) {
+ int restrictions = apiAnnotations.getRestrictions();
+ // if overriding no reference
+ // method, break the loop and
+ // report method addition
+ if (RestrictionModifiers.isReferenceRestriction(restrictions)) {
+ found = false;
+ break loop;
+ }
+
+ }
// method has been pushed down in
// the hierarchy - report the delta
// and abort loop

Back to the top