Lines 44-50
Link Here
|
44 |
public char[] selector; |
44 |
public char[] selector; |
45 |
public Expression[] arguments; |
45 |
public Expression[] arguments; |
46 |
public MethodBinding binding; // exact binding resulting from lookup |
46 |
public MethodBinding binding; // exact binding resulting from lookup |
47 |
public MethodBinding codegenBinding; // actual binding used for code generation (if no synthetic accessor) |
|
|
48 |
public MethodBinding syntheticAccessor; // synthetic accessor for inner-emulation |
47 |
public MethodBinding syntheticAccessor; // synthetic accessor for inner-emulation |
49 |
public TypeBinding expectedType; // for generic method invocation (return type inference) |
48 |
public TypeBinding expectedType; // for generic method invocation (return type inference) |
50 |
|
49 |
|
Lines 128-134
Link Here
|
128 |
int pc = codeStream.position; |
127 |
int pc = codeStream.position; |
129 |
|
128 |
|
130 |
// generate receiver/enclosing instance access |
129 |
// generate receiver/enclosing instance access |
131 |
boolean isStatic = this.codegenBinding.isStatic(); |
130 |
MethodBinding codegenBinding = this.binding.original(); |
|
|
131 |
boolean isStatic = codegenBinding.isStatic(); |
132 |
if (isStatic) { |
132 |
if (isStatic) { |
133 |
this.receiver.generateCode(currentScope, codeStream, false); |
133 |
this.receiver.generateCode(currentScope, codeStream, false); |
134 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
134 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
Lines 151-164
Link Here
|
151 |
if (this.syntheticAccessor == null){ |
151 |
if (this.syntheticAccessor == null){ |
152 |
TypeBinding constantPoolDeclaringClass = getConstantPoolDeclaringClass(currentScope); |
152 |
TypeBinding constantPoolDeclaringClass = getConstantPoolDeclaringClass(currentScope); |
153 |
if (isStatic){ |
153 |
if (isStatic){ |
154 |
codeStream.invoke(Opcodes.OPC_invokestatic, this.codegenBinding, constantPoolDeclaringClass); |
154 |
codeStream.invoke(Opcodes.OPC_invokestatic, codegenBinding, constantPoolDeclaringClass); |
155 |
} else if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){ |
155 |
} else if( (this.receiver.isSuper()) || codegenBinding.isPrivate()){ |
156 |
codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, constantPoolDeclaringClass); |
156 |
codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, constantPoolDeclaringClass); |
157 |
} else { |
157 |
} else { |
158 |
if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type |
158 |
if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type |
159 |
codeStream.invoke(Opcodes.OPC_invokeinterface, this.codegenBinding, constantPoolDeclaringClass); |
159 |
codeStream.invoke(Opcodes.OPC_invokeinterface, codegenBinding, constantPoolDeclaringClass); |
160 |
} else { |
160 |
} else { |
161 |
codeStream.invoke(Opcodes.OPC_invokevirtual, this.codegenBinding, constantPoolDeclaringClass); |
161 |
codeStream.invoke(Opcodes.OPC_invokevirtual, codegenBinding, constantPoolDeclaringClass); |
162 |
} |
162 |
} |
163 |
} |
163 |
} |
164 |
} else { |
164 |
} else { |
Lines 173-179
Link Here
|
173 |
boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0; |
173 |
boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0; |
174 |
// conversion only generated if unboxing |
174 |
// conversion only generated if unboxing |
175 |
if (isUnboxing) codeStream.generateImplicitConversion(this.implicitConversion); |
175 |
if (isUnboxing) codeStream.generateImplicitConversion(this.implicitConversion); |
176 |
switch (isUnboxing ? postConversionType(currentScope).id : this.codegenBinding.returnType.id) { |
176 |
switch (isUnboxing ? postConversionType(currentScope).id : codegenBinding.returnType.id) { |
177 |
case T_long : |
177 |
case T_long : |
178 |
case T_double : |
178 |
case T_double : |
179 |
codeStream.pop2(); |
179 |
codeStream.pop2(); |
Lines 195-204
Link Here
|
195 |
|
195 |
|
196 |
protected TypeBinding getConstantPoolDeclaringClass(BlockScope currentScope) { |
196 |
protected TypeBinding getConstantPoolDeclaringClass(BlockScope currentScope) { |
197 |
// constantpool declaringClass |
197 |
// constantpool declaringClass |
198 |
TypeBinding constantPoolDeclaringClass = this.codegenBinding.declaringClass; |
198 |
MethodBinding codegenBinding = this.binding.original(); |
|
|
199 |
TypeBinding constantPoolDeclaringClass = codegenBinding.declaringClass; |
199 |
// Post 1.4.0 target, array clone() invocations are qualified with array type |
200 |
// Post 1.4.0 target, array clone() invocations are qualified with array type |
200 |
// This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding) |
201 |
// This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding) |
201 |
if (this.codegenBinding == currentScope.environment().arrayClone) { |
202 |
if (codegenBinding == currentScope.environment().arrayClone) { |
202 |
CompilerOptions options = currentScope.compilerOptions(); |
203 |
CompilerOptions options = currentScope.compilerOptions(); |
203 |
if (options.sourceLevel > ClassFileConstants.JDK1_4 ) { |
204 |
if (options.sourceLevel > ClassFileConstants.JDK1_4 ) { |
204 |
constantPoolDeclaringClass = this.actualReceiverType.erasure(); |
205 |
constantPoolDeclaringClass = this.actualReceiverType.erasure(); |
Lines 211-217
Link Here
|
211 |
if (constantPoolDeclaringClass != this.actualReceiverType && this.receiverGenericCast == null && !this.actualReceiverType.isArrayType()) { |
212 |
if (constantPoolDeclaringClass != this.actualReceiverType && this.receiverGenericCast == null && !this.actualReceiverType.isArrayType()) { |
212 |
CompilerOptions options = currentScope.compilerOptions(); |
213 |
CompilerOptions options = currentScope.compilerOptions(); |
213 |
if ((options.targetJDK >= ClassFileConstants.JDK1_2 |
214 |
if ((options.targetJDK >= ClassFileConstants.JDK1_2 |
214 |
&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(this.receiver.isImplicitThis() && this.codegenBinding.isStatic())) |
215 |
&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(this.receiver.isImplicitThis() && codegenBinding.isStatic())) |
215 |
&& this.binding.declaringClass.id != TypeIds.T_JavaLangObject) // no change for Object methods |
216 |
&& this.binding.declaringClass.id != TypeIds.T_JavaLangObject) // no change for Object methods |
216 |
|| !this.binding.declaringClass.canBeSeenBy(currentScope)) { |
217 |
|| !this.binding.declaringClass.canBeSeenBy(currentScope)) { |
217 |
constantPoolDeclaringClass = this.actualReceiverType.erasure(); |
218 |
constantPoolDeclaringClass = this.actualReceiverType.erasure(); |
Lines 232-245
Link Here
|
232 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return; |
233 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return; |
233 |
|
234 |
|
234 |
// if method from parameterized type got found, use the original method at codegen time |
235 |
// if method from parameterized type got found, use the original method at codegen time |
235 |
this.codegenBinding = this.binding.original(); |
236 |
MethodBinding codegenBinding = this.binding.original(); |
236 |
if (this.binding.isPrivate()){ |
237 |
if (this.binding.isPrivate()){ |
237 |
|
238 |
|
238 |
// depth is set for both implicit and explicit access (see MethodBinding#canBeSeenBy) |
239 |
// depth is set for both implicit and explicit access (see MethodBinding#canBeSeenBy) |
239 |
if (currentScope.enclosingSourceType() != this.codegenBinding.declaringClass){ |
240 |
if (currentScope.enclosingSourceType() != codegenBinding.declaringClass){ |
240 |
|
241 |
|
241 |
this.syntheticAccessor = ((SourceTypeBinding)this.codegenBinding.declaringClass).addSyntheticMethod(this.codegenBinding, isSuperAccess()); |
242 |
this.syntheticAccessor = ((SourceTypeBinding)codegenBinding.declaringClass).addSyntheticMethod(codegenBinding, isSuperAccess()); |
242 |
currentScope.problemReporter().needToEmulateMethodAccess(this.codegenBinding, this); |
243 |
currentScope.problemReporter().needToEmulateMethodAccess(codegenBinding, this); |
243 |
return; |
244 |
return; |
244 |
} |
245 |
} |
245 |
|
246 |
|
Lines 247-266
Link Here
|
247 |
|
248 |
|
248 |
// qualified super need emulation always |
249 |
// qualified super need emulation always |
249 |
SourceTypeBinding destinationType = (SourceTypeBinding)(((QualifiedSuperReference)this.receiver).currentCompatibleType); |
250 |
SourceTypeBinding destinationType = (SourceTypeBinding)(((QualifiedSuperReference)this.receiver).currentCompatibleType); |
250 |
this.syntheticAccessor = destinationType.addSyntheticMethod(this.codegenBinding, isSuperAccess()); |
251 |
this.syntheticAccessor = destinationType.addSyntheticMethod(codegenBinding, isSuperAccess()); |
251 |
currentScope.problemReporter().needToEmulateMethodAccess(this.codegenBinding, this); |
252 |
currentScope.problemReporter().needToEmulateMethodAccess(codegenBinding, this); |
252 |
return; |
253 |
return; |
253 |
|
254 |
|
254 |
} else if (this.binding.isProtected()){ |
255 |
} else if (this.binding.isProtected()){ |
255 |
|
256 |
|
256 |
SourceTypeBinding enclosingSourceType; |
257 |
SourceTypeBinding enclosingSourceType; |
257 |
if (((this.bits & ASTNode.DepthMASK) != 0) |
258 |
if (((this.bits & ASTNode.DepthMASK) != 0) |
258 |
&& this.codegenBinding.declaringClass.getPackage() |
259 |
&& codegenBinding.declaringClass.getPackage() |
259 |
!= (enclosingSourceType = currentScope.enclosingSourceType()).getPackage()){ |
260 |
!= (enclosingSourceType = currentScope.enclosingSourceType()).getPackage()){ |
260 |
|
261 |
|
261 |
SourceTypeBinding currentCompatibleType = (SourceTypeBinding)enclosingSourceType.enclosingTypeAt((this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT); |
262 |
SourceTypeBinding currentCompatibleType = (SourceTypeBinding)enclosingSourceType.enclosingTypeAt((this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT); |
262 |
this.syntheticAccessor = currentCompatibleType.addSyntheticMethod(this.codegenBinding, isSuperAccess()); |
263 |
this.syntheticAccessor = currentCompatibleType.addSyntheticMethod(codegenBinding, isSuperAccess()); |
263 |
currentScope.problemReporter().needToEmulateMethodAccess(this.codegenBinding, this); |
264 |
currentScope.problemReporter().needToEmulateMethodAccess(codegenBinding, this); |
264 |
return; |
265 |
return; |
265 |
} |
266 |
} |
266 |
} |
267 |
} |