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 224969
Collapse All | Expand All

(-)src/org/eclipse/pde/api/tools/comparator/tests/ClassDeltaTests.java (-4 / +67 lines)
Lines 35-41 Link Here
35
	public static Test suite() {
35
	public static Test suite() {
36
		if (true) return new TestSuite(ClassDeltaTests.class);
36
		if (true) return new TestSuite(ClassDeltaTests.class);
37
		TestSuite suite = new TestSuite(ClassDeltaTests.class.getName());
37
		TestSuite suite = new TestSuite(ClassDeltaTests.class.getName());
38
		suite.addTest(new ClassDeltaTests("test114"));
38
		suite.addTest(new ClassDeltaTests("test49"));
39
		suite.addTest(new ClassDeltaTests("test50"));
40
		suite.addTest(new ClassDeltaTests("test51"));
39
		return suite;
41
		return suite;
40
	}
42
	}
41
43
Lines 1130-1138 Link Here
1130
		IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after);
1132
		IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after);
1131
		assertNotNull("No delta", delta);
1133
		assertNotNull("No delta", delta);
1132
		IDelta[] allLeavesDeltas = collectLeaves(delta);
1134
		IDelta[] allLeavesDeltas = collectLeaves(delta);
1133
		assertEquals("Wrong size", 1, allLeavesDeltas.length);
1135
		assertEquals("Wrong size", 2, allLeavesDeltas.length);
1134
		IDelta child = allLeavesDeltas[0];
1136
		IDelta child = allLeavesDeltas[0];
1135
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1137
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1138
		assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERINTERFACES_SET, child.getFlags());
1139
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1140
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
1141
		child = allLeavesDeltas[1];
1142
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1136
		assertEquals("Wrong flag", IDelta.SUPERCLASS, child.getFlags());
1143
		assertEquals("Wrong flag", IDelta.SUPERCLASS, child.getFlags());
1137
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1144
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1138
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
1145
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
Lines 1152-1158 Link Here
1152
		IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after);
1159
		IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after);
1153
		assertNotNull("No delta", delta);
1160
		assertNotNull("No delta", delta);
1154
		IDelta[] allLeavesDeltas = collectLeaves(delta);
1161
		IDelta[] allLeavesDeltas = collectLeaves(delta);
1155
		assertEquals("Wrong size", 3, allLeavesDeltas.length);
1162
		assertEquals("Wrong size", 6, allLeavesDeltas.length);
1156
		IDelta child = allLeavesDeltas[0];
1163
		IDelta child = allLeavesDeltas[0];
1157
		assertEquals("Wrong kind", IDelta.ADDED, child.getKind());
1164
		assertEquals("Wrong kind", IDelta.ADDED, child.getKind());
1158
		assertEquals("Wrong flag", IDelta.SUPERCLASS, child.getFlags());
1165
		assertEquals("Wrong flag", IDelta.SUPERCLASS, child.getFlags());
Lines 1168-1173 Link Here
1168
		assertEquals("Wrong flag", IDelta.EXPANDED_SUPERCLASS_SET, child.getFlags());
1175
		assertEquals("Wrong flag", IDelta.EXPANDED_SUPERCLASS_SET, child.getFlags());
1169
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1176
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1170
		assertTrue("Not compatible", DeltaProcessor.isCompatible(child));
1177
		assertTrue("Not compatible", DeltaProcessor.isCompatible(child));
1178
		child = allLeavesDeltas[3];
1179
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1180
		assertEquals("Wrong flag", IDelta.EXPANDED_SUPERINTERFACES_SET, child.getFlags());
1181
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1182
		assertTrue("Not compatible", DeltaProcessor.isCompatible(child));
1183
		child = allLeavesDeltas[4];
1184
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1185
		assertEquals("Wrong flag", IDelta.EXPANDED_SUPERINTERFACES_SET, child.getFlags());
1186
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1187
		assertTrue("Not compatible", DeltaProcessor.isCompatible(child));
1188
		child = allLeavesDeltas[5];
1189
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1190
		assertEquals("Wrong flag", IDelta.EXPANDED_SUPERINTERFACES_SET, child.getFlags());
1191
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1192
		assertTrue("Not compatible", DeltaProcessor.isCompatible(child));
1171
	}
1193
	}
1172
1194
1173
	/**
1195
	/**
Lines 1184-1190 Link Here
1184
		IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after);
1206
		IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after);
1185
		assertNotNull("No delta", delta);
1207
		assertNotNull("No delta", delta);
1186
		IDelta[] allLeavesDeltas = collectLeaves(delta);
1208
		IDelta[] allLeavesDeltas = collectLeaves(delta);
1187
		assertEquals("Wrong size", 3, allLeavesDeltas.length);
1209
		assertEquals("Wrong size", 6, allLeavesDeltas.length);
1188
		IDelta child = allLeavesDeltas[0];
1210
		IDelta child = allLeavesDeltas[0];
1189
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1211
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1190
		assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERCLASS_SET, child.getFlags());
1212
		assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERCLASS_SET, child.getFlags());
Lines 1197-1202 Link Here
1197
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
1219
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
1198
		child = allLeavesDeltas[2];
1220
		child = allLeavesDeltas[2];
1199
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1221
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1222
		assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERINTERFACES_SET, child.getFlags());
1223
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1224
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
1225
		child = allLeavesDeltas[3];
1226
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1227
		assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERINTERFACES_SET, child.getFlags());
1228
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1229
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
1230
		child = allLeavesDeltas[4];
1231
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1232
		assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERINTERFACES_SET, child.getFlags());
1233
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1234
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
1235
		child = allLeavesDeltas[5];
1236
		assertEquals("Wrong kind", IDelta.CHANGED, child.getKind());
1200
		assertEquals("Wrong flag", IDelta.SUPERCLASS, child.getFlags());
1237
		assertEquals("Wrong flag", IDelta.SUPERCLASS, child.getFlags());
1201
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1238
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
1202
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
1239
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
Lines 2691-2694 Link Here
2691
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
2728
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
2692
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
2729
		assertFalse("Is compatible", DeltaProcessor.isCompatible(child));
2693
	}
2730
	}
2731
	/**
2732
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=224969
2733
	 */
2734
	public void test115() {
2735
		deployBundles("test115");
2736
		IApiProfile before = getBeforeState();
2737
		IApiProfile after = getAfterState();
2738
		IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME);
2739
		assertNotNull("no api component", beforeApiComponent);
2740
		IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME);
2741
		assertNotNull("no api component", afterApiComponent);
2742
		IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after);
2743
		assertNotNull("No delta", delta);
2744
		IDelta[] allLeavesDeltas = collectLeaves(delta);
2745
		assertEquals("Wrong size", 2, allLeavesDeltas.length);
2746
		IDelta child = allLeavesDeltas[0];
2747
		assertEquals("Wrong kind", IDelta.ADDED, child.getKind());
2748
		assertEquals("Wrong flag", IDelta.SUPERCLASS, child.getFlags());
2749
		assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType());
2750
		assertTrue("Is compatible", DeltaProcessor.isCompatible(child));
2751
		child = allLeavesDeltas[1];
2752
		assertEquals("Wrong kind", IDelta.ADDED, child.getKind());
2753
		assertEquals("Wrong flag", IDelta.TYPE, child.getFlags());
2754
		assertEquals("Wrong element type", IDelta.API_COMPONENT_ELEMENT_TYPE, child.getElementType());
2755
		assertTrue("Is compatible", DeltaProcessor.isCompatible(child));
2756
	}
2694
}
2757
}
(-)tests-deltas/class/test115/after/I.java (+2 lines)
Added Link Here
1
public interface I {
2
}
(-)tests-deltas/class/test115/after/X.java (+2 lines)
Added Link Here
1
public class X extends B {
2
}
(-)tests-deltas/class/test115/after/B.java (+2 lines)
Added Link Here
1
public class B implements I {
2
}
(-)tests-deltas/class/test115/before/I.java (+2 lines)
Added Link Here
1
public interface I {
2
}
(-)tests-deltas/class/test115/before/X.java (+2 lines)
Added Link Here
1
public class X implements I {
2
}
(-)src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java (-13 / +34 lines)
Lines 440-467 Link Here
440
	private void collectAllInterfaces(TypeDescriptor typeDescriptor, IApiComponent apiComponent, IApiProfile profile, Set set) {
440
	private void collectAllInterfaces(TypeDescriptor typeDescriptor, IApiComponent apiComponent, IApiProfile profile, Set set) {
441
		try {
441
		try {
442
			Set interfaces = typeDescriptor.interfaces;
442
			Set interfaces = typeDescriptor.interfaces;
443
			if (interfaces == null) return;
443
			if (interfaces != null) {
444
			for (Iterator iterator = interfaces.iterator(); iterator.hasNext();) {
444
				for (Iterator iterator = interfaces.iterator(); iterator.hasNext();) {
445
				String interfaceName = (String) iterator.next();
445
					String interfaceName = (String) iterator.next();
446
				String packageName = Util.getPackageName(interfaceName);
446
					String packageName = Util.getPackageName(interfaceName);
447
					IApiComponent[] components = profile.resolvePackage(apiComponent, packageName);
448
					if (components == null) {
449
						// TODO should we report this failure ?
450
						if (DEBUG) {
451
							System.err.println("SUPERINTERFACES LOOKUP: Could not find package " + packageName + " in profile " + profile.getName() + " from component " + apiComponent.getId()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
452
						}
453
						continue;
454
					}
455
					IClassFile superinterface = Util.getClassFile(components, interfaceName);
456
					if (superinterface == null) {
457
						// TODO should we report this failure ?
458
						if (DEBUG) {
459
							System.err.println("SUPERINTERFACES LOOKUP: Could not find interface " + interfaceName + " in profile " + profile.getName() + " from component " + apiComponent.getId()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
460
						}
461
						continue;
462
					}
463
					TypeDescriptor typeDescriptor2 = new TypeDescriptor(superinterface.getContents());
464
					set.add(typeDescriptor2);
465
					collectAllInterfaces(typeDescriptor2, apiComponent, profile, set);
466
				}
467
			}
468
			String superclassName = typeDescriptor.superName;
469
			if (!Util.isJavaLangObject(superclassName)) {
470
				String packageName = Util.getPackageName(superclassName);
447
				IApiComponent[] components = profile.resolvePackage(apiComponent, packageName);
471
				IApiComponent[] components = profile.resolvePackage(apiComponent, packageName);
448
				if (components == null) {
472
				if (components == null) {
449
					// TODO should we report this failure ?
473
					// TODO should we report this failure ?
450
					if (DEBUG) {
474
					if (DEBUG) {
451
						System.err.println("SUPERINTERFACES LOOKUP: Could not find package " + packageName + " in profile " + profile.getName() + " from component " + apiComponent.getId()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
475
						System.err.println("SUPERINTERFACES LOOKUP: Could not find package " + packageName + " in profile " + profile.getName() + " from component " + apiComponent.getId()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
452
					}
476
					}
453
					continue;
477
					return;
454
				}
478
				}
455
				IClassFile superinterface = Util.getClassFile(components, interfaceName);
479
				IClassFile superclass = Util.getClassFile(components, superclassName);
456
				if (superinterface == null) {
480
				if (superclass == null) {
457
					// TODO should we report this failure ?
481
					// TODO should we report this failure ?
458
					if (DEBUG) {
482
					if (DEBUG) {
459
						System.err.println("SUPERINTERFACES LOOKUP: Could not find interface " + interfaceName + " in profile " + profile.getName() + " from component " + apiComponent.getId()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
483
						System.err.println("SUPERINTERFACES LOOKUP: Could not find class " + superclassName + " in profile " + profile.getName() + " from component " + apiComponent.getId()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
460
					}
484
					}
461
					continue;
485
					return;
462
				}
486
				}
463
				TypeDescriptor typeDescriptor2 = new TypeDescriptor(superinterface.getContents());
487
				TypeDescriptor typeDescriptor2 = new TypeDescriptor(superclass.getContents());
464
				set.add(typeDescriptor2);
465
				collectAllInterfaces(typeDescriptor2, apiComponent, profile, set);
488
				collectAllInterfaces(typeDescriptor2, apiComponent, profile, set);
466
			}
489
			}
467
		} catch (CoreException e) {
490
		} catch (CoreException e) {
Lines 1098-1105 Link Here
1098
	}
1121
	}
1099
1122
1100
	private Set getInterfacesSet(TypeDescriptor typeDescriptor, IApiComponent apiComponent, IApiProfile profile) {
1123
	private Set getInterfacesSet(TypeDescriptor typeDescriptor, IApiComponent apiComponent, IApiProfile profile) {
1101
		TypeDescriptor descriptor = typeDescriptor;
1102
		if (descriptor.interfaces == null) return null;
1103
		HashSet set = new HashSet();
1124
		HashSet set = new HashSet();
1104
		collectAllInterfaces(typeDescriptor, apiComponent, profile, set);
1125
		collectAllInterfaces(typeDescriptor, apiComponent, profile, set);
1105
		return set;
1126
		return set;

Return to bug 224969