|
Lines 63-82
Link Here
|
| 63 |
|
63 |
|
| 64 |
computeId(); |
64 |
computeId(); |
| 65 |
} |
65 |
} |
| 66 |
private void addDefaultAbstractMethod(MethodBinding abstractMethod) { |
66 |
|
| 67 |
MethodBinding defaultAbstract = new MethodBinding( |
|
|
| 68 |
abstractMethod.modifiers | ExtraCompilerModifiers.AccDefaultAbstract, |
| 69 |
abstractMethod.selector, |
| 70 |
abstractMethod.returnType, |
| 71 |
abstractMethod.parameters, |
| 72 |
abstractMethod.thrownExceptions, |
| 73 |
this); |
| 74 |
|
| 75 |
MethodBinding[] temp = new MethodBinding[this.methods.length + 1]; |
| 76 |
System.arraycopy(this.methods, 0, temp, 0, this.methods.length); |
| 77 |
temp[this.methods.length] = defaultAbstract; |
| 78 |
this.methods = temp; |
| 79 |
} |
| 80 |
public void addDefaultAbstractMethods() { |
67 |
public void addDefaultAbstractMethods() { |
| 81 |
if ((this.tagBits & TagBits.KnowsDefaultAbstractMethods) != 0) return; |
68 |
if ((this.tagBits & TagBits.KnowsDefaultAbstractMethods) != 0) return; |
| 82 |
|
69 |
|
|
Lines 88-106
Link Here
|
| 88 |
ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][]; |
75 |
ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][]; |
| 89 |
int lastPosition = 0; |
76 |
int lastPosition = 0; |
| 90 |
interfacesToVisit[lastPosition] = superInterfaces(); |
77 |
interfacesToVisit[lastPosition] = superInterfaces(); |
| 91 |
boolean hasAddedMethods = false; |
78 |
MethodBinding[] defaultAbstracts = null; |
|
|
79 |
int defaultAbstractsCount = 0; |
| 92 |
for (int i = 0; i <= lastPosition; i++) { |
80 |
for (int i = 0; i <= lastPosition; i++) { |
| 93 |
ReferenceBinding[] interfaces = interfacesToVisit[i]; |
81 |
ReferenceBinding[] interfaces = interfacesToVisit[i]; |
| 94 |
for (int j = 0, length = interfaces.length; j < length; j++) { |
82 |
for (int j = 0, length = interfaces.length; j < length; j++) { |
| 95 |
ReferenceBinding superType = interfaces[j]; |
83 |
ReferenceBinding superType = interfaces[j]; |
| 96 |
if (superType.isValidBinding()) { |
84 |
if (superType.isValidBinding()) { |
| 97 |
MethodBinding[] superMethods = superType.methods(); |
85 |
MethodBinding[] superMethods = superType.methods(); |
| 98 |
for (int m = superMethods.length; --m >= 0;) { |
86 |
nextAbstractMethod: for (int m = superMethods.length; --m >= 0;) { |
| 99 |
MethodBinding method = superMethods[m]; |
87 |
MethodBinding method = superMethods[m]; |
| 100 |
if (!implementsMethod(method)) { |
88 |
// explicitly implemented ? |
| 101 |
addDefaultAbstractMethod(method); |
89 |
if (implementsMethod(method)) { |
| 102 |
hasAddedMethods = true; |
90 |
continue nextAbstractMethod; |
| 103 |
} |
91 |
} |
|
|
92 |
if (defaultAbstractsCount == 0) { |
| 93 |
defaultAbstracts = new MethodBinding[5]; |
| 94 |
} else { |
| 95 |
// already added as default abstract ? |
| 96 |
for(int k = 0; k < defaultAbstractsCount; k++) { |
| 97 |
MethodBinding alreadyAddedMethod = defaultAbstracts[k]; |
| 98 |
if (CharOperation.equals(alreadyAddedMethod.selector, method.selector) |
| 99 |
&& alreadyAddedMethod.areParametersEqual(method)) { |
| 100 |
continue nextAbstractMethod; |
| 101 |
} |
| 102 |
} |
| 103 |
} |
| 104 |
MethodBinding defaultAbstract = new MethodBinding( |
| 105 |
method.modifiers | ExtraCompilerModifiers.AccDefaultAbstract, |
| 106 |
method.selector, |
| 107 |
method.returnType, |
| 108 |
method.parameters, |
| 109 |
method.thrownExceptions, |
| 110 |
this); |
| 111 |
if (defaultAbstractsCount == defaultAbstracts.length) { |
| 112 |
System.arraycopy(defaultAbstracts, 0, defaultAbstracts = new MethodBinding[2*defaultAbstractsCount], 0, defaultAbstractsCount); |
| 113 |
} |
| 114 |
defaultAbstracts[defaultAbstractsCount++] = defaultAbstract; |
| 104 |
} |
115 |
} |
| 105 |
|
116 |
|
| 106 |
ReferenceBinding[] itsInterfaces = superType.superInterfaces(); |
117 |
ReferenceBinding[] itsInterfaces = superType.superInterfaces(); |
|
Lines 112-120
Link Here
|
| 112 |
} |
123 |
} |
| 113 |
} |
124 |
} |
| 114 |
} |
125 |
} |
| 115 |
if (hasAddedMethods) { |
126 |
if (defaultAbstractsCount > 0) { |
| 116 |
// re-sort methods |
|
|
| 117 |
int length = this.methods.length; |
127 |
int length = this.methods.length; |
|
|
128 |
System.arraycopy(this.methods, 0, this.methods = new MethodBinding[length+defaultAbstractsCount], 0, length); |
| 129 |
System.arraycopy(defaultAbstracts, 0, this.methods, length, defaultAbstractsCount); |
| 130 |
// re-sort methods |
| 131 |
length = length+defaultAbstractsCount; |
| 118 |
if (length > 1) { |
132 |
if (length > 1) { |
| 119 |
ReferenceBinding.sortMethods(this.methods, 0, length - 1); |
133 |
ReferenceBinding.sortMethods(this.methods, 0, length - 1); |
| 120 |
} |
134 |
} |