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; |