Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 247703 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java (-5 / +43 lines)
Lines 253-263 Link Here
253
		if (visibilityModifiers == VisibilityModifiers.API) {
253
		if (visibilityModifiers == VisibilityModifiers.API) {
254
			int currentTypeVisibility = 0;
254
			int currentTypeVisibility = 0;
255
			String superTypeName = this.descriptor1.superName;
255
			String superTypeName = this.descriptor1.superName;
256
			String superTypeName2 = this.descriptor2.superName;
257
			if (!superTypeName.equals(superTypeName2)) {
258
				// we don't need to check the superclass if it has changed
259
				return;
260
			}
261
			LookupResult pair = getType(superTypeName, this.component, this.apiProfile);
256
			LookupResult pair = getType(superTypeName, this.component, this.apiProfile);
262
			if (pair == null) return;
257
			if (pair == null) return;
263
			IClassFile superclassType1 = pair.classFile;
258
			IClassFile superclassType1 = pair.classFile;
Lines 267-272 Link Here
267
			if (superclassAnnotations != null) {
262
			if (superclassAnnotations != null) {
268
				currentTypeVisibility = superclassAnnotations.getVisibility();
263
				currentTypeVisibility = superclassAnnotations.getVisibility();
269
				if (!VisibilityModifiers.isAPI(currentTypeVisibility)) {
264
				if (!VisibilityModifiers.isAPI(currentTypeVisibility)) {
265
					String superTypeName2 = this.descriptor2.superName;
266
					if (!superTypeName.equals(superTypeName2)) {
267
						// we don't need to check the superclass if it has changed
268
						// all visible members (methods, fields and types) should be reported as removed
269
						for (Iterator iterator = superTypeDescriptor.methods.values().iterator(); iterator.hasNext(); ) {
270
							MethodDescriptor methodDescriptor = (MethodDescriptor) iterator.next();
271
							int access = methodDescriptor.access;
272
							if (methodDescriptor.isClinit()
273
									|| methodDescriptor.isConstructor()
274
									|| Util.isDefault(access)
275
									|| Util.isPrivate(access)
276
									|| (Util.isProtected(access)
277
											&& RestrictionModifiers.isExtendRestriction(currentDescriptorRestrictions))) continue;
278
							String methodDisplayName = getMethodDisplayName(methodDescriptor, this.descriptor1);
279
							this.addDelta(
280
									this.descriptor1.getElementType(),
281
									IDelta.REMOVED,
282
									IDelta.METHOD,
283
									this.initialDescriptorRestrictions,
284
									this.descriptor1.access,
285
									this.classFile,
286
									this.descriptor1.name,
287
									new String[] {Util.getDescriptorName(this.descriptor1), methodDisplayName});
288
						}
289
						for (Iterator iterator = superTypeDescriptor.fields.values().iterator(); iterator.hasNext(); ) {
290
							FieldDescriptor fieldDescriptor = (FieldDescriptor) iterator.next();
291
							int access = fieldDescriptor.access;
292
							if (Util.isDefault(access)
293
									|| Util.isPrivate(access)
294
									|| (Util.isProtected(access)
295
											&& RestrictionModifiers.isExtendRestriction(currentDescriptorRestrictions))) continue;
296
							this.addDelta(
297
									this.descriptor1.getElementType(),
298
									IDelta.REMOVED,
299
									IDelta.FIELD,
300
									this.initialDescriptorRestrictions,
301
									this.descriptor1.access,
302
									this.classFile,
303
									this.descriptor1.name,
304
									new String[] {Util.getDescriptorName(this.descriptor1), fieldDescriptor.name});
305
						}
306
						return;
307
					}
270
					// superclass is not an API type so we need to check it for visible members
308
					// superclass is not an API type so we need to check it for visible members
271
					// if this is an API, it will be checked when the supertype is checked
309
					// if this is an API, it will be checked when the supertype is checked
272
					final boolean ignoreProtected = RestrictionModifiers.isExtendRestriction(this.currentDescriptorRestrictions) || Util.isFinal(this.descriptor1.access);
310
					final boolean ignoreProtected = RestrictionModifiers.isExtendRestriction(this.currentDescriptorRestrictions) || Util.isFinal(this.descriptor1.access);
(-)src/org/eclipse/pde/api/tools/builder/tests/compatibility/ClassCompatibilityHierarchyTests.java (-9 / +16 lines)
Lines 110-116 Link Here
110
		setExpectedMessageArgs(args);
110
		setExpectedMessageArgs(args);
111
		performCompatibilityTest(filePath, incremental);
111
		performCompatibilityTest(filePath, incremental);
112
	}
112
	}
113
114
	public void testRemoveIntSuperClassWithMethodI() throws Exception {
115
		xRemoveIntSuperClassWithMethod(true);
116
	}
113
	
117
	
118
	public void testRemoveIntSuperClassWithMethodF() throws Exception {
119
		xRemoveIntSuperClassWithMethod(false);
120
	}
121
114
	public void testReduceHierarchyCtoAI() throws Exception {
122
	public void testReduceHierarchyCtoAI() throws Exception {
115
		xReduceHierarchyCtoA(true);
123
		xReduceHierarchyCtoA(true);
116
	}	
124
	}	
Lines 265-271 Link Here
265
		// no problems expected
273
		// no problems expected
266
		performCompatibilityTest(filePath, incremental);
274
		performCompatibilityTest(filePath, incremental);
267
	}
275
	}
268
	
276
269
	public void testAddInterfaceAI() throws Exception {
277
	public void testAddInterfaceAI() throws Exception {
270
		xAddInterfaceA(true);
278
		xAddInterfaceA(true);
271
	}	
279
	}	
Lines 318-334 Link Here
318
	 */
326
	 */
319
	private void xRemoveIntSuperClassWithMethod(boolean incremental) throws Exception {
327
	private void xRemoveIntSuperClassWithMethod(boolean incremental) throws Exception {
320
		IPath filePath = WORKSPACE_CLASSES_PACKAGE_A.append("RemoveIntSuperClassWithMethod.java");
328
		IPath filePath = WORKSPACE_CLASSES_PACKAGE_A.append("RemoveIntSuperClassWithMethod.java");
321
		// TODO: expect a removed method problem
329
		int[] ids = new int[] {
330
				getRemovedProblemId(IDelta.METHOD)
331
			};
332
			setExpectedProblemIds(ids);
333
			String[][] args = new String[1][];
334
			args[0] = new String[]{PACKAGE_PREFIX + "RemoveIntSuperClassWithMethod", "method()"};
335
			setExpectedMessageArgs(args);
322
		performCompatibilityTest(filePath, incremental);
336
		performCompatibilityTest(filePath, incremental);
323
	}
337
	}
324
	
338
	
325
	public void testRemoveIntSuperClassWithMethodI() throws Exception {
326
		xRemoveIntSuperClassWithMethod(true);
327
	}
328
	
329
	public void testRemoveIntSuperClassWithMethodF() throws Exception {
330
		xRemoveIntSuperClassWithMethod(false);
331
	}		
332
	
339
	
333
	/* (non-Javadoc)
340
	/* (non-Javadoc)
334
	 * @see org.eclipse.pde.api.tools.builder.tests.ApiBuilderTest#getDefaultProblemId()
341
	 * @see org.eclipse.pde.api.tools.builder.tests.ApiBuilderTest#getDefaultProblemId()
(-)src/org/eclipse/pde/api/tools/comparator/tests/ClassDeltaTests.java (-3 / +25 lines)
Lines 34-42 Link Here
34
public class ClassDeltaTests extends DeltaTestSetup {
34
public class ClassDeltaTests extends DeltaTestSetup {
35
	
35
	
36
	public static Test suite() {
36
	public static Test suite() {
37
		if (true) return new TestSuite(ClassDeltaTests.class);
37
		if (false) return new TestSuite(ClassDeltaTests.class);
38
		TestSuite suite = new TestSuite(ClassDeltaTests.class.getName());
38
		TestSuite suite = new TestSuite(ClassDeltaTests.class.getName());
39
		suite.addTest(new ClassDeltaTests("test138"));
39
		suite.addTest(new ClassDeltaTests("test139"));
40
		return suite;
40
		return suite;
41
	}
41
	}
42
42
Lines 3229-3232 Link Here
3229
		assertEquals("Wrong flag", IDelta.METHOD, child.getFlags());
3229
		assertEquals("Wrong flag", IDelta.METHOD, child.getFlags());
3230
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
3230
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
3231
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
3231
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
3232
	}}
3232
	}
3233
	/**
3234
	 * Remove internal superclass that contains public method 
3235
	 */
3236
	public void test139() {
3237
		deployBundles("test139");
3238
		IApiProfile before = getBeforeState();
3239
		IApiProfile after = getAfterState();
3240
		IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME);
3241
		assertNotNull("no api component", beforeApiComponent);
3242
		IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME);
3243
		assertNotNull("no api component", afterApiComponent);
3244
		IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after, VisibilityModifiers.API);
3245
		assertNotNull("No delta", delta);
3246
		IDelta[] allLeavesDeltas = collectLeaves(delta);
3247
		assertEquals("Wrong size", 1, allLeavesDeltas.length);
3248
		IDelta child = allLeavesDeltas[0];
3249
		assertEquals("Wrong kind", IDelta.REMOVED, child.getKind());
3250
		assertEquals("Wrong flag", IDelta.METHOD, child.getFlags());
3251
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
3252
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
3253
	}
3254
}
(-)tests-deltas/class/test139/before/p/X.java (+16 lines)
Added Link Here
1
package p;
2
3
public class X extends internal.p.Y {}
Added Link Here
1
package p;
2
3
public class X {}
Added Link Here
1
Manifest-Version: 1.0
2
Ant-Version: Apache Ant 1.7.0
3
Created-By: 1.6.0_05-ea-b04 (Sun Microsystems Inc.)
4
Bundle-ManifestVersion: 2
5
Bundle-Name: deltatest Plug-in
6
Bundle-SymbolicName: deltatest
7
Bundle-Version: 2.0.0
8
Bundle-RequiredExecutionEnvironment: J2SE-1.4
9
Export-Package: p,
10
 internal.p;x-internal:=true
(-)tests-deltas/class/test139/resources/before/.api_description (+14 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<component name="deltatest">
3
<plugin id="deltatest" />
4
</component>
Added Link Here
1
Manifest-Version: 1.0
2
Ant-Version: Apache Ant 1.7.0
3
Created-By: 1.6.0_05-ea-b04 (Sun Microsystems Inc.)
4
Bundle-ManifestVersion: 2
5
Bundle-Name: deltatest Plug-in
6
Bundle-SymbolicName: deltatest
7
Bundle-Version: 1.0.0
8
Bundle-RequiredExecutionEnvironment: J2SE-1.4
9
Export-Package: p,
10
 internal.p;x-internal:=true
(-)tests-deltas/class/test139/resources/after/.api_description (+12 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<component name="deltatest">
3
<plugin id="deltatest" />
4
</component>
Added Link Here
1
package internal.p;
2
3
public class Y {}
Added Link Here
1
package internal.p;
2
3
public class Y {
4
	public void bar() {}
5
}

Return to bug 247703