Bug 479384 - Types marked with @noimplement and @noextend are not
considered by API leak analysis



Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/ClassExtendsLeak.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/ClassExtendsLeak.java
index e783512..f79c41b 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/ClassExtendsLeak.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/ClassExtendsLeak.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2013 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 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
@@ -10,14 +10,14 @@
  *******************************************************************************/
 package org.eclipse.pde.api.tools.builder.tests.leak;
 
-import junit.framework.Test;
-
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.jdt.core.JavaCore;
 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;
 
+import junit.framework.Test;
+
 /**
  * Tests that leaked members via extends for classes is properly detected
  *
@@ -596,4 +596,46 @@
 		String typename = "test32"; //$NON-NLS-1$
 		deployLeakTest(typename + ".java", inc); //$NON-NLS-1$
 	}
+
+	/**
+	 * Tests that an API class that extends a  noextend class is a leak
+	 */
+	public void testClassExtendsNoExtendClass33F() {
+		x34(false);
+	}
+
+
+	public void testClassExtendsNoExtendClass13I() {
+		x34(true);
+	}
+
+	private void x34(boolean inc) {
+		int pid = ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_USAGE, IElementDescriptor.TYPE,
+				IApiProblem.API_LEAK, IApiProblem.LEAK_BY_EXTENDING_NO_EXTEND_TYPE);
+		setExpectedProblemIds(new int[] { pid });
+		String typename = "test34"; //$NON-NLS-1$
+		setExpectedMessageArgs(new String[][] { { "classNoExtend", typename } }); //$NON-NLS-1$
+		deployLeakTest(typename + ".java", inc); //$NON-NLS-1$
+	}
+
+	/**
+	 * Test that an API class that extends a  noextend class is not a  leak
+	 * if it is noextend
+	 */
+	public void testNoExtendClassExtendsNoExtendClass14F() {
+		x35(false);
+	}
+
+
+	public void testNoExtendClassExtendsNoExtendClass14I() {
+		x35(true);
+	}
+
+	private void x35(boolean inc) {
+		expectingNoProblems();
+		String typename = "test35"; //$NON-NLS-1$
+		setExpectedMessageArgs(new String[][] { { "class1", typename } }); //$NON-NLS-1$
+		deployLeakTest(typename + ".java", inc); //$NON-NLS-1$
+	}
+
 }
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/ClassImplementsLeak.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/ClassImplementsLeak.java
index 75f8e72..c2060e7 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/ClassImplementsLeak.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/ClassImplementsLeak.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 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
@@ -10,13 +10,13 @@
  *******************************************************************************/
 package org.eclipse.pde.api.tools.builder.tests.leak;
 
-import junit.framework.Test;
-
 import org.eclipse.core.runtime.IPath;
 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;
 
+import junit.framework.Test;
+
 /**
  * Tests that an API type that implements an internal type
  * is properly detected
@@ -324,4 +324,25 @@
 		setExpectedMessageArgs(new String[][] {{"Iouter", typename}}); //$NON-NLS-1$
 		deployLeakTest(typename+".java", inc); //$NON-NLS-1$
 	}
+
+	/**
+	 * Tests that an API class that implements noimplement interface is a leak
+	 */
+	public void testClassImplementsNoImplementInterface12F() {
+		x12(false);
+	}
+
+
+	public void testClassImplementsNoImplementInterface12I() {
+		x12(true);
+	}
+
+	private void x12(boolean inc) {
+		setExpectedProblemIds(new int[] { getDefaultProblemId() });
+		String typename = "test33"; //$NON-NLS-1$
+		setExpectedMessageArgs(new String[][] { { "interfaceNoImplement", typename } }); //$NON-NLS-1$
+		deployLeakTest(typename + ".java", inc); //$NON-NLS-1$
+	}
+
+
 }
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/InterfaceExtendsLeak.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/InterfaceExtendsLeak.java
index 184eb31..f742995 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/InterfaceExtendsLeak.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/InterfaceExtendsLeak.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 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
@@ -10,13 +10,13 @@
  *******************************************************************************/
 package org.eclipse.pde.api.tools.builder.tests.leak;
 
-import junit.framework.Test;
-
 import org.eclipse.core.runtime.IPath;
 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;
 
+import junit.framework.Test;
+
 /**
  * Tests that an API interface leaking an internal type via extends is
  * flagged properly
@@ -300,4 +300,81 @@
 		setExpectedMessageArgs(new String[][] {{"Iouter", typename}}); //$NON-NLS-1$
 		deployLeakTest(typename+".java", inc); //$NON-NLS-1$
 	}
+
+	/**
+	 * Tests extending a noimplement interface is a leak of a non-API type.
+	 */
+	public void testInterfaceExtendsNoImplementInterface11F() {
+		x11(false);
+	}
+
+	public void testInterfaceExtendsNoImplementInterface11I() {
+		x11(true);
+	}
+
+	private void x11(boolean inc) {
+		setExpectedProblemIds(new int[] { getDefaultProblemId() });
+		String typename = "Etest11"; //$NON-NLS-1$
+		setExpectedMessageArgs(new String[][] { { "interfaceNoImplement", typename } }); //$NON-NLS-1$
+		deployLeakTest(typename + ".java", inc); //$NON-NLS-1$
+	}
+
+	/**
+	 * Tests extending a noimplement interface is a leak of a non-API type
+	 * unless it itself is noimplement
+	 */
+	public void testInterfaceExtendsNoImplementInterface12F() {
+		x12(false);
+	}
+
+
+	public void testInterfaceExtendsNoImplementInterface12I() {
+		x12(true);
+	}
+
+	private void x12(boolean inc) {
+		expectingNoProblems();
+		String typename = "Etest12"; //$NON-NLS-1$
+		deployLeakTest(typename + ".java", inc); //$NON-NLS-1$
+	}
+
+	// *******
+	/**
+	 * Tests extending a noextend interface is am indirect leak.
+	 */
+	public void testInterfaceExtendsNoExtendInterface13F() {
+		x13(false);
+	}
+
+	public void testInterfaceExtendsNoExtendInterface13I() {
+		x13(true);
+	}
+
+	private void x13(boolean inc) {
+		int pid = ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_USAGE, IElementDescriptor.TYPE,
+				IApiProblem.API_LEAK, IApiProblem.LEAK_BY_EXTENDING_NO_EXTEND_TYPE);
+		setExpectedProblemIds(new int[] { pid });
+		String typename = "Etest13"; //$NON-NLS-1$
+		setExpectedMessageArgs(new String[][] { { "interfaceNoExtend", typename } }); //$NON-NLS-1$
+		deployLeakTest(typename + ".java", inc);//$NON-NLS-1$
+	}
+
+	/**
+	 * Tests extending a noextend interface is a leak of a non-API type
+	 * unless it itself is noextend
+	 */
+	public void testInterfaceExtendsNoExtendInterface14F() {
+		x14(false);
+	}
+
+
+	public void testInterfaceExtendsNoExtendInterface14I() {
+		x14(true);
+	}
+
+	private void x14(boolean inc) {
+		expectingNoProblems();
+		String typename = "Etest14"; //$NON-NLS-1$
+		deployLeakTest(typename + ".java", inc);//$NON-NLS-1$
+	}
 }
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/LeakTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/LeakTest.java
index 92f0e45..3827f05 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/LeakTest.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/leak/LeakTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2013 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 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
@@ -13,9 +13,6 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
@@ -25,6 +22,9 @@
 import org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment;
 import org.eclipse.pde.api.tools.model.tests.TestSuiteHelper;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 /**
  * Tests the builder to make sure it correctly reports non-API type leaks
  *
@@ -148,11 +148,21 @@
 	}
 
 	/**
+	 * Verifies that the project has no problems.
+	 */
+	@Override
+	protected void expectingNoProblems() {
+		IProject project = getEnv().getWorkspace().getRoot().getProject(getTestingProjectName());
+		expectingNoProblemsFor(project.getFullPath());
+	}
+
+	/**
 	 * Deploys a leak test
 	 *
-	 * @param sourcename the name of the source files to create in the testing
-	 *            project.
-	 * @param incremental if an incremental build should be performed
+	 * @param sourcename
+	 *            the name of the source files to create in the testing project.
+	 * @param incremental
+	 *            if an incremental build should be performed
 	 */
 	protected void deployLeakTest(String sourcename, boolean incremantal) {
 		try {
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UnusedApiProblemFilterTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UnusedApiProblemFilterTests.java
index 3f8aa11..323ca62 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UnusedApiProblemFilterTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UnusedApiProblemFilterTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2013 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 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
@@ -10,13 +10,12 @@
  *******************************************************************************/
 package org.eclipse.pde.api.tools.builder.tests.usage;
 
-import junit.framework.Test;
-
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResourceChangeEvent;
 import org.eclipse.core.resources.IResourceDelta;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.pde.api.tools.builder.tests.ApiProblem;
 import org.eclipse.pde.api.tools.internal.model.ApiModelFactory;
 import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory;
 import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
@@ -28,6 +27,8 @@
 import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
 import org.eclipse.pde.api.tools.util.tests.ResourceEventWaiter;
 
+import junit.framework.Test;
+
 /**
  * Tests that unused
  * {@link org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter}
@@ -187,10 +188,12 @@
 			fullBuild();
 		}
 		expectingNoJDTProblems();
-		if (getExpectedProblemIds().length > 0) {
-			assertProblems(getEnv().getProblems());
+		IProject projectCurrent = getEnv().getWorkspace().getRoot().getProject(getTestingProjectName());
+		ApiProblem[] apiProblems = allSortedApiProblems(new IPath[] { projectCurrent.getFullPath() });
+		if (apiProblems != null && apiProblems.length > 0) {
+			assertProblems(apiProblems);
 		} else {
-			expectingNoProblems();
+			expectingNoProblemsFor(projectCurrent.getFullPath());
 		}
 	}
 
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/class/test33.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/class/test33.java
new file mode 100644
index 0000000..95c77a1
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/class/test33.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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 x.y.z;
+
+import x.y.z.interfaceNoImplement;
+
+/**
+*
+*/
+public class test33 implements interfaceNoImplement {
+	
+	public void exposeMethod() {}
+
+}
+
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/class/test34.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/class/test34.java
new file mode 100644
index 0000000..6377a4a
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/class/test34.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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 x.y.z;
+
+import x.y.z.classNoExtend;
+
+/**
+*
+*/
+public class test34 extends classNoExtend {
+	
+
+}
+
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/class/test35.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/class/test35.java
new file mode 100644
index 0000000..2639863
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/class/test35.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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 x.y.z;
+
+import x.y.z.classNoExtend;
+
+/**
+ * @noextend
+ */
+public class test35 extends classNoExtend {
+	
+
+}
+
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest11.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest11.java
new file mode 100644
index 0000000..24a0452
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest11.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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 x.y.z;
+import x.y.z.interfaceNoImplement;
+
+public interface Etest11 extends interfaceNoImplement {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest12.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest12.java
new file mode 100644
index 0000000..b1a17e2
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest12.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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 x.y.z;
+import x.y.z.interfaceNoImplement;
+
+/**
+ * @noimplement
+ */
+public interface Etest12 extends interfaceNoImplement {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest13.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest13.java
new file mode 100644
index 0000000..b073fa2
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest13.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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 x.y.z;
+import x.y.z.interfaceNoExtend;
+
+
+public interface Etest13 extends interfaceNoExtend {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest14.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest14.java
new file mode 100644
index 0000000..8313478
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leak/interface/Etest14.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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 x.y.z;
+import x.y.z.interfaceNoExtend;
+
+/**
+ * @noextend
+ */
+public interface Etest14 extends interfaceNoExtend {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/leakprojects/leakproject/src/x/y/z/classNoExtend.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leakprojects/leakproject/src/x/y/z/classNoExtend.java
new file mode 100644
index 0000000..751ae16
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leakprojects/leakproject/src/x/y/z/classNoExtend.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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 x.y.z;
+
+/**
+ * @noextend
+ */
+public class classNoExtend {
+	
+	public void exposeMethod() {
+		
+	}
+}
\ No newline at end of file
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/leakprojects/leakproject/src/x/y/z/interfaceNoExtend.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leakprojects/leakproject/src/x/y/z/interfaceNoExtend.java
new file mode 100644
index 0000000..f826be0
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leakprojects/leakproject/src/x/y/z/interfaceNoExtend.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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 x.y.z;
+
+/**
+ * @noextend
+ */
+public interface interfaceNoExtend {
+	
+	public void exposeMethod();
+}
\ No newline at end of file
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/leakprojects/leakproject/src/x/y/z/interfaceNoImplement.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leakprojects/leakproject/src/x/y/z/interfaceNoImplement.java
new file mode 100644
index 0000000..0b97f33
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/leakprojects/leakproject/src/x/y/z/interfaceNoImplement.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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 x.y.z;
+
+/**
+ * @noimplement
+ */
+public interface interfaceNoImplement {
+	
+	public void exposeMethod();
+}
\ No newline at end of file
diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/preferences/preferencemessages.properties b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/preferences/preferencemessages.properties
index a14bb5b..4d7e816 100644
--- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/preferences/preferencemessages.properties
+++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/preferences/preferencemessages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2008, 2016 IBM Corporation and others.
+# Copyright (c) 2008, 2017 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
@@ -139,7 +139,7 @@
 
 ApiErrorsWarningsConfigurationBlock_error=Error
 ApiErrorsWarningsConfigurationBlock_error_button=&Error
-ApiErrorsWarningsConfigurationBlock_extend_non_api_class=Extends a non-API class:
+ApiErrorsWarningsConfigurationBlock_extend_non_api_class=Extends a non-API class or interface:
 ApiErrorsWarningsConfigurationBlock_field_decl_non_api=Field with a non-API type:
 ApiErrorsWarningsConfigurationBlock_general=&General
 ApiErrorsWarningsConfigurationBlock_warning=Warning
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractLeakProblemDetector.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractLeakProblemDetector.java
index e923d61..7f60d95 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractLeakProblemDetector.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractLeakProblemDetector.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2015 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 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
@@ -14,6 +14,7 @@
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jdt.core.Flags;
+import org.eclipse.pde.api.tools.internal.provisional.RestrictionModifiers;
 import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
 import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
 import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
@@ -48,6 +49,17 @@
 		}
 		// could be a reference to a package visible type
 		IApiMember member = reference.getMember();
+		
+		// if reference has noimplement restriction, it could leak non-API types
+		if (RestrictionModifiers.isImplementRestriction(member.getModifiers())) {
+			return true;
+		}
+		// if reference has noextend restriction, it could be indirectly be
+		// extended bypassing the noextend
+		if (RestrictionModifiers.isImplementRestriction(member.getModifiers())) {
+			return true;
+		}
+
 		IApiType type = null;
 		if (member.getType() == IApiElement.TYPE) {
 			type = (IApiType) member;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/LeakExtendsProblemDetector.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/LeakExtendsProblemDetector.java
index 4448e2f..e16b60e 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/LeakExtendsProblemDetector.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/LeakExtendsProblemDetector.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2013 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 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
@@ -26,6 +26,7 @@
 import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
 import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
 import org.eclipse.pde.api.tools.internal.provisional.model.IApiField;
+import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
 import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod;
 import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
 import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
@@ -38,6 +39,8 @@
  */
 public class LeakExtendsProblemDetector extends AbstractTypeLeakDetector {
 
+	int problemFlags = IApiProblem.LEAK_EXTENDS;
+
 	/**
 	 * @param nonApiPackageNames
 	 */
@@ -57,12 +60,43 @@
 
 	@Override
 	protected int getProblemFlags(IReference reference) {
-		return IApiProblem.LEAK_EXTENDS;
+		return problemFlags;
 	}
 
 	@Override
 	public boolean isProblem(IReference reference) {
-		if (super.isProblem(reference)) {
+		boolean isProb = super.isProblem(reference);
+		problemFlags = IApiProblem.LEAK_EXTENDS;
+		//check if the no extend type is left to be extended
+		// or if noimplement interface is extended but not marked noimplement
+		if (isProb == false) {
+			IApiMember member = reference.getResolvedReference();
+			IApiMember sourceMember = reference.getMember();
+			try {
+				IApiAnnotations annotations = member.getApiComponent().getApiDescription().resolveAnnotations(member.getHandle());
+				if (annotations != null) {
+					if (RestrictionModifiers.isExtendRestriction(annotations.getRestrictions())) {
+						IApiAnnotations annotationsSource = member.getApiComponent().getApiDescription().resolveAnnotations(sourceMember.getHandle());
+						if (annotationsSource != null && !RestrictionModifiers.isExtendRestriction(annotationsSource.getRestrictions())) {
+							problemFlags = IApiProblem.LEAK_BY_EXTENDING_NO_EXTEND_TYPE;
+							return true;
+						}
+					}
+					if (RestrictionModifiers.isImplementRestriction(annotations.getRestrictions())) {
+						IApiAnnotations annotationsSource = member.getApiComponent().getApiDescription().resolveAnnotations(sourceMember.getHandle());
+						if (annotationsSource != null && !RestrictionModifiers.isImplementRestriction(annotationsSource.getRestrictions())) {
+							// problemFlags =
+							// IApiProblem.LEAK_BY_EXTENDING_NO_EXTEND_TYPE;
+							return true;
+						}
+					}
+				}
+			}
+			catch (CoreException e) {
+				ApiPlugin.log(e);
+			}
+		}
+		if (isProb) {
 			// check the use restrictions on the API type (can be extended or
 			// not)
 			IApiType type = (IApiType) reference.getMember();
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/LeakImplementsProblemDetector.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/LeakImplementsProblemDetector.java
index d4d1460..b95a97a 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/LeakImplementsProblemDetector.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/LeakImplementsProblemDetector.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2013 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 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
@@ -12,7 +12,12 @@
 
 import java.util.Set;
 
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
+import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
+import org.eclipse.pde.api.tools.internal.provisional.RestrictionModifiers;
 import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
+import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
 import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
 import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemTypes;
 
@@ -45,4 +50,29 @@
 		return IApiProblem.LEAK_IMPLEMENTS;
 	}
 
+	@Override
+	public boolean isProblem(IReference reference) {
+		boolean isProb = super.isProblem(reference);
+		// check if no implement interface is implemented and thereby leaking api
+		// types from noimplement interface
+		if (isProb == false) {
+			IApiMember member = reference.getResolvedReference();
+			IApiMember sourceMember = reference.getMember();
+			try {
+				IApiAnnotations annotations = member.getApiComponent().getApiDescription().resolveAnnotations(member.getHandle());
+				if (annotations != null) {
+					if (RestrictionModifiers.isImplementRestriction(annotations.getRestrictions())) {
+						IApiAnnotations annotationsSource = member.getApiComponent().getApiDescription().resolveAnnotations(sourceMember.getHandle());
+						if (annotationsSource != null && !RestrictionModifiers.isImplementRestriction(annotationsSource.getRestrictions())) {
+							isProb= true;
+						}
+					}
+				}
+			}
+			catch (CoreException e) {
+				ApiPlugin.log(e);
+			}
+		}
+		return isProb;
+	}
 }
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java
index 5202f89..cc941ef 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2016 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 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
@@ -676,6 +676,8 @@
 						switch (flags) {
 							case IApiProblem.LEAK_EXTENDS:
 								return 13;
+							case IApiProblem.LEAK_BY_EXTENDING_NO_EXTEND_TYPE:
+								return 48;
 							case IApiProblem.LEAK_IMPLEMENTS:
 								return 14;
 							case IApiProblem.LEAK_FIELD:
@@ -1052,6 +1054,7 @@
 					case IApiProblem.API_LEAK: {
 						switch (problem.getFlags()) {
 							case IApiProblem.LEAK_EXTENDS:
+							case IApiProblem.LEAK_BY_EXTENDING_NO_EXTEND_TYPE:
 								return IApiProblemTypes.LEAK_EXTEND;
 							case IApiProblem.LEAK_FIELD:
 								return IApiProblemTypes.LEAK_FIELD_DECL;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/problemmessages.properties b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/problemmessages.properties
index 8394d3d..973e8f4 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/problemmessages.properties
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/problemmessages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2008, 2016 IBM Corporation and others.
+# Copyright (c) 2008, 2017 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
@@ -8,7 +8,7 @@
 # Contributors:
 #     IBM Corporation - initial API and implementation
 ###############################################################################
-# available message ids  48, 49, 50, 51, 53, 57, 58, 59, 60, 62, 63, 65, 68, 70, 71, 75, 80,
+# available message ids   49, 50, 51, 53, 57, 58, 59, 60, 62, 63, 65, 68, 70, 71, 75, 80,
 # 82, 83, 88, 90, 93
 
 #API baseline 
@@ -41,6 +41,7 @@
 11 = {1}.{2} illegally overrides {0}.{2}
 12 = {1} illegally references field {0}.{2}
 13 = {1} extends non-API type {0}
+48= {1} leaks types by allowing it to extend {0}
 14 = {1} implements non-API interface {0}
 15 = {1}.{2} declared as non-API type {0}
 16 = {1}.{2} has non-API return type {0}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/problems/IApiProblem.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/problems/IApiProblem.java
index c484b58..f6eb216 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/problems/IApiProblem.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/problems/IApiProblem.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2016 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 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
@@ -455,6 +455,16 @@
 	public static final int ANNOTATION = 14;
 
 	/**
+	 * Constant representing the value of an API leak {@link IApiProblem} by
+	 * extending a no extend type <br>
+	 * Value is: <code>15</code>
+	 *
+	 * @see #getFlags()
+	 * @see #CATEGORY_USAGE
+	 */
+	public static final int LEAK_BY_EXTENDING_NO_EXTEND_TYPE = 15;
+
+	/**
 	 * Constant representing the value of a default API profile
 	 * {@link IApiProblem} kind. <br>
 	 * Value is: <code>1</code>