View | Details | Raw Unified | Return to bug 247292 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-8 / +5 lines)
Lines 99-111 Link Here
99
		return this.enclosingInstance;
99
		return this.enclosingInstance;
100
	}
100
	}
101
101
102
	public void generateCode(
102
	public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
103
		BlockScope currentScope,
104
		CodeStream codeStream,
105
		boolean valueRequired) {
106
107
		int pc = codeStream.position;
103
		int pc = codeStream.position;
108
		ReferenceBinding allocatedType = this.codegenBinding.declaringClass;
104
		MethodBinding codegenBinding = this.binding.original();
105
		ReferenceBinding allocatedType = codegenBinding.declaringClass;
109
		codeStream.new_(allocatedType);
106
		codeStream.new_(allocatedType);
110
		boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0;
107
		boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0;
111
		if (valueRequired || isUnboxing) {
108
		if (valueRequired || isUnboxing) {
Lines 139-149 Link Here
139
136
140
		// invoke constructor
137
		// invoke constructor
141
		if (this.syntheticAccessor == null) {
138
		if (this.syntheticAccessor == null) {
142
			codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */);
139
			codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, null /* default declaringClass */);
143
		} else {
140
		} else {
144
			// synthetic accessor got some extra arguments appended to its signature, which need values
141
			// synthetic accessor got some extra arguments appended to its signature, which need values
145
			for (int i = 0,
142
			for (int i = 0,
146
				max = this.syntheticAccessor.parameters.length - this.codegenBinding.parameters.length;
143
				max = this.syntheticAccessor.parameters.length - codegenBinding.parameters.length;
147
				i < max;
144
				i < max;
148
				i++) {
145
				i++) {
149
				codeStream.aconst_null();
146
				codeStream.aconst_null();
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (-9 / +9 lines)
Lines 22-28 Link Here
22
	public TypeReference type;
22
	public TypeReference type;
23
	public Expression[] arguments;
23
	public Expression[] arguments;
24
	public MethodBinding binding;							// exact binding resulting from lookup
24
	public MethodBinding binding;							// exact binding resulting from lookup
25
	protected MethodBinding codegenBinding;	// actual binding used for code generation (if no synthetic accessor)
26
	MethodBinding syntheticAccessor;						// synthetic accessor for inner-emulation
25
	MethodBinding syntheticAccessor;						// synthetic accessor for inner-emulation
27
	public TypeReference[] typeArguments;
26
	public TypeReference[] typeArguments;
28
	public TypeBinding[] genericTypeArguments;
27
	public TypeBinding[] genericTypeArguments;
Lines 80-86 Link Here
80
79
81
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
80
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
82
	int pc = codeStream.position;
81
	int pc = codeStream.position;
83
	ReferenceBinding allocatedType = this.codegenBinding.declaringClass;
82
	 MethodBinding codegenBinding = this.binding.original();
83
	ReferenceBinding allocatedType = codegenBinding.declaringClass;
84
84
85
	codeStream.new_(allocatedType);
85
	codeStream.new_(allocatedType);
86
	boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0;
86
	boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0;
Lines 115-125 Link Here
115
	}
115
	}
116
	// invoke constructor
116
	// invoke constructor
117
	if (this.syntheticAccessor == null) {
117
	if (this.syntheticAccessor == null) {
118
		codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */);
118
		codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, null /* default declaringClass */);
119
	} else {
119
	} else {
120
		// synthetic accessor got some extra arguments appended to its signature, which need values
120
		// synthetic accessor got some extra arguments appended to its signature, which need values
121
		for (int i = 0,
121
		for (int i = 0,
122
			max = this.syntheticAccessor.parameters.length - this.codegenBinding.parameters.length;
122
			max = this.syntheticAccessor.parameters.length - codegenBinding.parameters.length;
123
			i < max;
123
			i < max;
124
			i++) {
124
			i++) {
125
			codeStream.aconst_null();
125
			codeStream.aconst_null();
Lines 187-204 Link Here
187
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
187
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
188
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return;
188
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return;
189
	// if constructor from parameterized type got found, use the original constructor at codegen time
189
	// if constructor from parameterized type got found, use the original constructor at codegen time
190
	this.codegenBinding = this.binding.original();
190
	MethodBinding codegenBinding = this.binding.original();
191
191
192
	ReferenceBinding declaringClass;
192
	ReferenceBinding declaringClass;
193
	if (this.codegenBinding.isPrivate() && currentScope.enclosingSourceType() != (declaringClass = this.codegenBinding.declaringClass)) {
193
	if (codegenBinding.isPrivate() && currentScope.enclosingSourceType() != (declaringClass = codegenBinding.declaringClass)) {
194
194
195
		// from 1.4 on, local type constructor can lose their private flag to ease emulation
195
		// from 1.4 on, local type constructor can lose their private flag to ease emulation
196
		if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 	&& currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
196
		if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 	&& currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
197
			// constructor will not be dumped as private, no emulation required thus
197
			// constructor will not be dumped as private, no emulation required thus
198
			this.codegenBinding.tagBits |= TagBits.ClearPrivateModifier;
198
			codegenBinding.tagBits |= TagBits.ClearPrivateModifier;
199
		} else {
199
		} else {
200
			this.syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(this.codegenBinding, isSuperAccess());
200
			this.syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenBinding, isSuperAccess());
201
			currentScope.problemReporter().needToEmulateMethodAccess(this.codegenBinding, this);
201
			currentScope.problemReporter().needToEmulateMethodAccess(codegenBinding, this);
202
		}
202
		}
203
	}
203
	}
204
}
204
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-20 / +21 lines)
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
	}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java (-9 / +9 lines)
Lines 38-44 Link Here
38
	public Expression[] arguments;
38
	public Expression[] arguments;
39
	public Expression qualification;
39
	public Expression qualification;
40
	public MethodBinding binding;							// exact binding resulting from lookup
40
	public MethodBinding binding;							// exact binding resulting from lookup
41
	protected MethodBinding codegenBinding;		// actual binding used for code generation (if no synthetic accessor)
42
	MethodBinding syntheticAccessor;						// synthetic accessor for inner-emulation
41
	MethodBinding syntheticAccessor;						// synthetic accessor for inner-emulation
43
	public int accessMode;
42
	public int accessMode;
44
	public TypeReference[] typeArguments;
43
	public TypeReference[] typeArguments;
Lines 115-121 Link Here
115
			int pc = codeStream.position;
114
			int pc = codeStream.position;
116
			codeStream.aload_0();
115
			codeStream.aload_0();
117
116
118
			ReferenceBinding targetType = this.codegenBinding.declaringClass;
117
			MethodBinding codegenBinding = this.binding.original();
118
			ReferenceBinding targetType = codegenBinding.declaringClass;
119
119
120
			// special name&ordinal argument generation for enum constructors
120
			// special name&ordinal argument generation for enum constructors
121
			if (targetType.erasure().id == TypeIds.T_JavaLangEnum || targetType.isEnum()) {
121
			if (targetType.erasure().id == TypeIds.T_JavaLangEnum || targetType.isEnum()) {
Lines 144-157 Link Here
144
			if (this.syntheticAccessor != null) {
144
			if (this.syntheticAccessor != null) {
145
				// synthetic accessor got some extra arguments appended to its signature, which need values
145
				// synthetic accessor got some extra arguments appended to its signature, which need values
146
				for (int i = 0,
146
				for (int i = 0,
147
					max = this.syntheticAccessor.parameters.length - this.codegenBinding.parameters.length;
147
					max = this.syntheticAccessor.parameters.length - codegenBinding.parameters.length;
148
					i < max;
148
					i < max;
149
					i++) {
149
					i++) {
150
					codeStream.aconst_null();
150
					codeStream.aconst_null();
151
				}
151
				}
152
				codeStream.invoke(Opcodes.OPC_invokespecial, this.syntheticAccessor, null /* default declaringClass */);
152
				codeStream.invoke(Opcodes.OPC_invokespecial, this.syntheticAccessor, null /* default declaringClass */);
153
			} else {
153
			} else {
154
				codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */);
154
				codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, null /* default declaringClass */);
155
			}
155
			}
156
			codeStream.recordPositionsFrom(pc, this.sourceStart);
156
			codeStream.recordPositionsFrom(pc, this.sourceStart);
157
		} finally {
157
		} finally {
Lines 206-223 Link Here
206
	public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
206
	public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
207
		if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0)	{
207
		if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0)	{
208
			// if constructor from parameterized type got found, use the original constructor at codegen time
208
			// if constructor from parameterized type got found, use the original constructor at codegen time
209
			this.codegenBinding = this.binding.original();
209
			MethodBinding codegenBinding = this.binding.original();
210
210
211
			// perform some emulation work in case there is some and we are inside a local type only
211
			// perform some emulation work in case there is some and we are inside a local type only
212
			if (this.binding.isPrivate() && this.accessMode != ExplicitConstructorCall.This) {
212
			if (this.binding.isPrivate() && this.accessMode != ExplicitConstructorCall.This) {
213
				ReferenceBinding declaringClass = this.codegenBinding.declaringClass;
213
				ReferenceBinding declaringClass = codegenBinding.declaringClass;
214
				// from 1.4 on, local type constructor can lose their private flag to ease emulation
214
				// from 1.4 on, local type constructor can lose their private flag to ease emulation
215
				if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 	&& currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
215
				if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 	&& currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
216
					// constructor will not be dumped as private, no emulation required thus
216
					// constructor will not be dumped as private, no emulation required thus
217
					this.codegenBinding.tagBits |= TagBits.ClearPrivateModifier;
217
					codegenBinding.tagBits |= TagBits.ClearPrivateModifier;
218
				} else {
218
				} else {
219
					this.syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(this.codegenBinding, isSuperAccess());
219
					this.syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenBinding, isSuperAccess());
220
					currentScope.problemReporter().needToEmulateMethodAccess(this.codegenBinding, this);
220
					currentScope.problemReporter().needToEmulateMethodAccess(codegenBinding, this);
221
				}
221
				}
222
			}
222
			}
223
		}
223
		}
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java (-25 / +21 lines)
Lines 48-63 Link Here
48
 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
48
 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
49
 * @param valueRequired boolean
49
 * @param valueRequired boolean
50
 */
50
 */
51
public void generateCode(
51
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
52
	BlockScope currentScope,
53
	CodeStream codeStream,
54
	boolean valueRequired) {
55
56
	int pc = codeStream.position;
52
	int pc = codeStream.position;
57
53
	MethodBinding codegenBinding = this.binding.original();
58
	if (this.codegenBinding.canBeSeenBy(this.actualReceiverType, this, currentScope)) {
54
	if (codegenBinding.canBeSeenBy(this.actualReceiverType, this, currentScope)) {
59
		// generate receiver/enclosing instance access
55
		// generate receiver/enclosing instance access
60
		boolean isStatic = this.codegenBinding.isStatic();
56
		boolean isStatic = codegenBinding.isStatic();
61
		// outer access ?
57
		// outer access ?
62
		if (!isStatic && ((this.bits & DepthMASK) != 0)) {
58
		if (!isStatic && ((this.bits & DepthMASK) != 0)) {
63
			// outer method can be reached through emulation
59
			// outer method can be reached through emulation
Lines 80-99 Link Here
80
		// actual message invocation
76
		// actual message invocation
81
		TypeBinding constantPoolDeclaringClass = getConstantPoolDeclaringClass(currentScope);
77
		TypeBinding constantPoolDeclaringClass = getConstantPoolDeclaringClass(currentScope);
82
		if (isStatic) {
78
		if (isStatic) {
83
			codeStream.invoke(Opcodes.OPC_invokestatic, this.codegenBinding, constantPoolDeclaringClass);
79
			codeStream.invoke(Opcodes.OPC_invokestatic, codegenBinding, constantPoolDeclaringClass);
84
		} else if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){
80
		} else if( (this.receiver.isSuper()) || codegenBinding.isPrivate()){
85
			codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, constantPoolDeclaringClass);
81
			codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, constantPoolDeclaringClass);
86
		} else {
82
		} else {
87
			if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type
83
			if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type
88
				codeStream.invoke(Opcodes.OPC_invokeinterface, this.codegenBinding, constantPoolDeclaringClass);
84
				codeStream.invoke(Opcodes.OPC_invokeinterface, codegenBinding, constantPoolDeclaringClass);
89
			} else {
85
			} else {
90
				codeStream.invoke(Opcodes.OPC_invokevirtual, this.codegenBinding, constantPoolDeclaringClass);
86
				codeStream.invoke(Opcodes.OPC_invokevirtual, codegenBinding, constantPoolDeclaringClass);
91
			}
87
			}
92
		}
88
		}
93
	} else {
89
	} else {
94
		codeStream.generateEmulationForMethod(currentScope, this.codegenBinding);
90
		codeStream.generateEmulationForMethod(currentScope, codegenBinding);
95
		// generate receiver/enclosing instance access
91
		// generate receiver/enclosing instance access
96
		boolean isStatic = this.codegenBinding.isStatic();
92
		boolean isStatic = codegenBinding.isStatic();
97
		// outer access ?
93
		// outer access ?
98
		if (!isStatic && ((this.bits & DepthMASK) != 0)) {
94
		if (!isStatic && ((this.bits & DepthMASK) != 0)) {
99
			// not supported yet
95
			// not supported yet
Lines 117-125 Link Here
117
			for (int i = 0; i < argsLength; i++) {
113
			for (int i = 0; i < argsLength; i++) {
118
				codeStream.generateInlinedValue(i);
114
				codeStream.generateInlinedValue(i);
119
				this.arguments[i].generateCode(currentScope, codeStream, true);
115
				this.arguments[i].generateCode(currentScope, codeStream, true);
120
				TypeBinding parameterBinding = this.codegenBinding.parameters[i];
116
				TypeBinding parameterBinding = codegenBinding.parameters[i];
121
				if (parameterBinding.isBaseType() && parameterBinding != TypeBinding.NULL) {
117
				if (parameterBinding.isBaseType() && parameterBinding != TypeBinding.NULL) {
122
					codeStream.generateBoxingConversion(this.codegenBinding.parameters[i].id);
118
					codeStream.generateBoxingConversion(codegenBinding.parameters[i].id);
123
				}
119
				}
124
				codeStream.aastore();
120
				codeStream.aastore();
125
				if (i < argsLength - 1) {
121
				if (i < argsLength - 1) {
Lines 133-140 Link Here
133
		codeStream.invokeJavaLangReflectMethodInvoke();
129
		codeStream.invokeJavaLangReflectMethodInvoke();
134
130
135
		// convert the return value to the appropriate type for primitive types
131
		// convert the return value to the appropriate type for primitive types
136
		if (this.codegenBinding.returnType.isBaseType()) {
132
		if (codegenBinding.returnType.isBaseType()) {
137
			int typeID = this.codegenBinding.returnType.id;
133
			int typeID = codegenBinding.returnType.id;
138
			if (typeID == T_void) {
134
			if (typeID == T_void) {
139
				// remove the null from the stack
135
				// remove the null from the stack
140
				codeStream.pop();
136
				codeStream.pop();
Lines 142-148 Link Here
142
			codeStream.checkcast(typeID);
138
			codeStream.checkcast(typeID);
143
			codeStream.getBaseTypeValue(typeID);
139
			codeStream.getBaseTypeValue(typeID);
144
		} else {
140
		} else {
145
			codeStream.checkcast(this.codegenBinding.returnType);
141
			codeStream.checkcast(codegenBinding.returnType);
146
		}
142
		}
147
	}
143
	}
148
	// required cast must occur even if no value is required
144
	// required cast must occur even if no value is required
Lines 154-160 Link Here
154
		boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0;
150
		boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0;
155
		// conversion only generated if unboxing
151
		// conversion only generated if unboxing
156
		if (isUnboxing) codeStream.generateImplicitConversion(this.implicitConversion);
152
		if (isUnboxing) codeStream.generateImplicitConversion(this.implicitConversion);
157
		switch (isUnboxing ? postConversionType(currentScope).id : this.codegenBinding.returnType.id) {
153
		switch (isUnboxing ? postConversionType(currentScope).id : codegenBinding.returnType.id) {
158
			case T_long :
154
			case T_long :
159
			case T_double :
155
			case T_double :
160
				codeStream.pop2();
156
				codeStream.pop2();
Lines 171-181 Link Here
171
167
172
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) {
168
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) {
173
		// if method from parameterized type got found, use the original method at codegen time
169
		// if method from parameterized type got found, use the original method at codegen time
174
		this.codegenBinding = this.binding.original();
170
		MethodBinding codegenBinding = this.binding.original();
175
		if (this.codegenBinding != this.binding) {
171
		if (codegenBinding != this.binding) {
176
		    // extra cast needed if method return type was type variable
172
		    // extra cast needed if method return type was type variable
177
		    if (this.codegenBinding.returnType.isTypeVariable()) {
173
		    if (codegenBinding.returnType.isTypeVariable()) {
178
		        TypeVariableBinding variableReturnType = (TypeVariableBinding) this.codegenBinding.returnType;
174
		        TypeVariableBinding variableReturnType = (TypeVariableBinding) codegenBinding.returnType;
179
		        if (variableReturnType.firstBound != this.binding.returnType) { // no need for extra cast if same as first bound anyway
175
		        if (variableReturnType.firstBound != this.binding.returnType) { // no need for extra cast if same as first bound anyway
180
				    this.valueCast = this.binding.returnType;
176
				    this.valueCast = this.binding.returnType;
181
		        }
177
		        }
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java (-16 / +9 lines)
Lines 36-50 Link Here
36
public CodeSnippetAllocationExpression(EvaluationContext evaluationContext) {
36
public CodeSnippetAllocationExpression(EvaluationContext evaluationContext) {
37
	this.evaluationContext = evaluationContext;
37
	this.evaluationContext = evaluationContext;
38
}
38
}
39
public void generateCode(
39
public void generateCode(BlockScope currentScope, CodeStream codeStream, 	boolean valueRequired) {
40
	BlockScope currentScope,
41
	CodeStream codeStream,
42
	boolean valueRequired) {
43
44
	int pc = codeStream.position;
40
	int pc = codeStream.position;
45
	ReferenceBinding allocatedType = this.codegenBinding.declaringClass;
41
	MethodBinding codegenBinding = this.binding.original();
42
	ReferenceBinding allocatedType = codegenBinding.declaringClass;
46
43
47
	if (this.codegenBinding.canBeSeenBy(allocatedType, this, currentScope)) {
44
	if (codegenBinding.canBeSeenBy(allocatedType, this, currentScope)) {
48
		codeStream.new_(allocatedType);
45
		codeStream.new_(allocatedType);
49
		if (valueRequired) {
46
		if (valueRequired) {
50
			codeStream.dup();
47
			codeStream.dup();
Lines 74-83 Link Here
74
				this);
71
				this);
75
		}
72
		}
76
		// invoke constructor
73
		// invoke constructor
77
		codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */);
74
		codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, null /* default declaringClass */);
78
	} else {
75
	} else {
79
		// private emulation using reflect
76
		// private emulation using reflect
80
		codeStream.generateEmulationForConstructor(currentScope, this.codegenBinding);
77
		codeStream.generateEmulationForConstructor(currentScope, codegenBinding);
81
		// generate arguments
78
		// generate arguments
82
		if (this.arguments != null) {
79
		if (this.arguments != null) {
83
			int argsLength = this.arguments.length;
80
			int argsLength = this.arguments.length;
Lines 87-95 Link Here
87
			for (int i = 0; i < argsLength; i++) {
84
			for (int i = 0; i < argsLength; i++) {
88
				codeStream.generateInlinedValue(i);
85
				codeStream.generateInlinedValue(i);
89
				this.arguments[i].generateCode(currentScope, codeStream, true);
86
				this.arguments[i].generateCode(currentScope, codeStream, true);
90
				TypeBinding parameterBinding = this.codegenBinding.parameters[i];
87
				TypeBinding parameterBinding = codegenBinding.parameters[i];
91
				if (parameterBinding.isBaseType() && parameterBinding != TypeBinding.NULL) {
88
				if (parameterBinding.isBaseType() && parameterBinding != TypeBinding.NULL) {
92
					codeStream.generateBoxingConversion(this.codegenBinding.parameters[i].id);
89
					codeStream.generateBoxingConversion(codegenBinding.parameters[i].id);
93
				}
90
				}
94
				codeStream.aastore();
91
				codeStream.aastore();
95
				if (i < argsLength - 1) {
92
				if (i < argsLength - 1) {
Lines 116-126 Link Here
116
	// not supported yet
113
	// not supported yet
117
}
114
}
118
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
115
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
119
		if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) {
116
	// do nothing
120
121
		// if constructor from parameterized type got found, use the original constructor at codegen time
122
		this.codegenBinding = this.binding.original();
123
		}
124
}
117
}
125
public TypeBinding resolveType(BlockScope scope) {
118
public TypeBinding resolveType(BlockScope scope) {
126
	// Propagate the type checking to the arguments, and check if the constructor is defined.
119
	// Propagate the type checking to the arguments, and check if the constructor is defined.

Return to bug 247292