View | Details | Raw Unified | Return to bug 161977
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (-36 / +15 lines)
Lines 1453-1497 Link Here
1453
}
1453
}
1454
// TODO (philippe) could be a performance issue since some senders are building the list just to count them
1454
// TODO (philippe) could be a performance issue since some senders are building the list just to count them
1455
public SyntheticMethodBinding[] syntheticMethods() {
1455
public SyntheticMethodBinding[] syntheticMethods() {
1456
1456
	if (this.synthetics == null 
1457
	if (this.synthetics == null || this.synthetics[SourceTypeBinding.METHOD_EMUL] == null || this.synthetics[SourceTypeBinding.METHOD_EMUL].size() == 0) return null;
1457
			|| this.synthetics[SourceTypeBinding.METHOD_EMUL] == null 
1458
1458
			|| this.synthetics[SourceTypeBinding.METHOD_EMUL].size() == 0) {
1459
		return null;
1460
	}
1459
	// difficult to compute size up front because of the embedded arrays so assume there is only 1
1461
	// difficult to compute size up front because of the embedded arrays so assume there is only 1
1460
	int index = 0;
1462
	int index = 0;
1461
	SyntheticMethodBinding[] bindings = new SyntheticMethodBinding[1];
1463
	SyntheticMethodBinding[] bindings = new SyntheticMethodBinding[1];
1462
	Iterator fieldsOrMethods = this.synthetics[SourceTypeBinding.METHOD_EMUL].keySet().iterator();
1464
	Iterator methodArrayIterator = this.synthetics[SourceTypeBinding.METHOD_EMUL].values().iterator();
1463
	while (fieldsOrMethods.hasNext()) {
1465
	while (methodArrayIterator.hasNext()) {
1464
1466
		SyntheticMethodBinding[] methodAccessors = (SyntheticMethodBinding[]) methodArrayIterator.next();
1465
		Object fieldOrMethod = fieldsOrMethods.next();
1467
		for (int i = 0, max = methodAccessors.length; i < max; i++) {
1466
1468
			if (methodAccessors[i] != null) {
1467
		if (fieldOrMethod instanceof MethodBinding) {
1469
				if (index+1 > bindings.length) {
1468
1470
					System.arraycopy(bindings, 0, (bindings = new SyntheticMethodBinding[index + 1]), 0, index);
1469
			SyntheticMethodBinding[] methodAccessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL].get(fieldOrMethod);
1471
				}
1470
			int numberOfAccessors = 0;
1472
				bindings[index++] = methodAccessors[i]; 
1471
			if (methodAccessors[0] != null) numberOfAccessors++;
1473
			}
1472
			if (methodAccessors[1] != null) numberOfAccessors++;
1473
			if (index + numberOfAccessors > bindings.length)
1474
				System.arraycopy(bindings, 0, (bindings = new SyntheticMethodBinding[index + numberOfAccessors]), 0, index);
1475
			if (methodAccessors[0] != null)
1476
				bindings[index++] = methodAccessors[0]; // super access
1477
			if (methodAccessors[1] != null)
1478
				bindings[index++] = methodAccessors[1]; // normal access or bridge
1479
1480
		} else {
1481
1482
			SyntheticMethodBinding[] fieldAccessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL].get(fieldOrMethod);
1483
			int numberOfAccessors = 0;
1484
			if (fieldAccessors[0] != null) numberOfAccessors++;
1485
			if (fieldAccessors[1] != null) numberOfAccessors++;
1486
			if (index + numberOfAccessors > bindings.length)
1487
				System.arraycopy(bindings, 0, (bindings = new SyntheticMethodBinding[index + numberOfAccessors]), 0, index);
1488
			if (fieldAccessors[0] != null)
1489
				bindings[index++] = fieldAccessors[0]; // read access
1490
			if (fieldAccessors[1] != null)
1491
				bindings[index++] = fieldAccessors[1]; // write access
1492
		}
1474
		}
1493
	}
1475
	}
1494
1495
	// sort them in according to their own indexes
1476
	// sort them in according to their own indexes
1496
	int length;
1477
	int length;
1497
	SyntheticMethodBinding[] sortedBindings = new SyntheticMethodBinding[length = bindings.length];
1478
	SyntheticMethodBinding[] sortedBindings = new SyntheticMethodBinding[length = bindings.length];
Lines 1505-1513 Link Here
1505
 * Answer the collection of synthetic fields to append into the classfile
1486
 * Answer the collection of synthetic fields to append into the classfile
1506
 */
1487
 */
1507
public FieldBinding[] syntheticFields() {
1488
public FieldBinding[] syntheticFields() {
1508
1509
	if (this.synthetics == null) return null;
1489
	if (this.synthetics == null) return null;
1510
1511
	int fieldSize = this.synthetics[SourceTypeBinding.FIELD_EMUL] == null ? 0 : this.synthetics[SourceTypeBinding.FIELD_EMUL].size();
1490
	int fieldSize = this.synthetics[SourceTypeBinding.FIELD_EMUL] == null ? 0 : this.synthetics[SourceTypeBinding.FIELD_EMUL].size();
1512
	int literalSize = this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL] == null ? 0 :this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL].size();
1491
	int literalSize = this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL] == null ? 0 :this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL].size();
1513
	int totalSize = fieldSize + literalSize;
1492
	int totalSize = fieldSize + literalSize;
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java (-3 / +2 lines)
Lines 275-282 Link Here
275
		this.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccSynthetic;
275
		this.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccSynthetic;
276
		this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
276
		this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
277
		SourceTypeBinding sourceType = (SourceTypeBinding) accessedConstructor.declaringClass;
277
		SourceTypeBinding sourceType = (SourceTypeBinding) accessedConstructor.declaringClass;
278
		SyntheticMethodBinding[] knownSyntheticMethods =
278
		SyntheticMethodBinding[] knownSyntheticMethods = sourceType.syntheticMethods();
279
			sourceType.syntheticMethods();
280
		this.index = knownSyntheticMethods == null ? 0 : knownSyntheticMethods.length;
279
		this.index = knownSyntheticMethods == null ? 0 : knownSyntheticMethods.length;
281
280
282
		this.selector = accessedConstructor.selector;
281
		this.selector = accessedConstructor.selector;
Lines 314-320 Link Here
314
						if (knownSyntheticMethods[i] == null)
313
						if (knownSyntheticMethods[i] == null)
315
							continue;
314
							continue;
316
						if (CharOperation.equals(this.selector, knownSyntheticMethods[i].selector)
315
						if (CharOperation.equals(this.selector, knownSyntheticMethods[i].selector)
317
							&& areParametersEqual(knownSyntheticMethods[i])) {
316
								&& areParametersEqual(knownSyntheticMethods[i])) {
318
							needRename = true;
317
							needRename = true;
319
							break check;
318
							break check;
320
						}
319
						}
(-)compiler/org/eclipse/jdt/internal/compiler/ClassFile.java (-3 / +1 lines)
Lines 734-742 Link Here
734
	public void addFieldInfos() {
734
	public void addFieldInfos() {
735
		SourceTypeBinding currentBinding = this.referenceBinding;
735
		SourceTypeBinding currentBinding = this.referenceBinding;
736
		FieldBinding[] syntheticFields = currentBinding.syntheticFields();
736
		FieldBinding[] syntheticFields = currentBinding.syntheticFields();
737
		int fieldCount =
737
		int fieldCount = 	currentBinding.fieldCount() + (syntheticFields == null ? 0 : syntheticFields.length);
738
			currentBinding.fieldCount()
739
				+ (syntheticFields == null ? 0 : syntheticFields.length);
740
738
741
		// write the number of fields
739
		// write the number of fields
742
		if (fieldCount > 0xFFFF) {
740
		if (fieldCount > 0xFFFF) {

Return to bug 161977