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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-1 / +2 lines)
Lines 156-161 Link Here
156
	// for references on lhs of assignment
156
	// for references on lhs of assignment
157
	public static final int IsStrictlyAssigned = Bit14; // set only for true assignments, as opposed to compound ones
157
	public static final int IsStrictlyAssigned = Bit14; // set only for true assignments, as opposed to compound ones
158
	public static final int IsCompoundAssigned = Bit17; // set only for compound assignments, as opposed to other ones
158
	public static final int IsCompoundAssigned = Bit17; // set only for compound assignments, as opposed to other ones
159
	public static final int IsInsideCondition = Bit21; // for name/field reference inside a condition 
159
160
160
	// for explicit constructor call
161
	// for explicit constructor call
161
	public static final int DiscardEnclosingInstance = Bit14; // used for codegen
162
	public static final int DiscardEnclosingInstance = Bit14; // used for codegen
Lines 364-370 Link Here
364
				&& field.isOrEnclosedByPrivateType() 
365
				&& field.isOrEnclosedByPrivateType() 
365
				&& !scope.isDefinedInField(field)) 				// ignore cases where field is used from inside itself 
366
				&& !scope.isDefinedInField(field)) 				// ignore cases where field is used from inside itself 
366
		{		
367
		{		
367
			if (((filteredBits & IsCompoundAssigned) != 0))
368
			if (((filteredBits & (IsCompoundAssigned|IsInsideCondition)) != 0))
368
				// used, but usage may not be relevant
369
				// used, but usage may not be relevant
369
				field.original().compoundUseFlag++;
370
				field.original().compoundUseFlag++;
370
			else
371
			else
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java (+3 lines)
Lines 197-202 Link Here
197
						abort = true;
197
						abort = true;
198
					}
198
					}
199
				} else if (e.compilationResult == CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE) {
199
				} else if (e.compilationResult == CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE) {
200
					if (e.getScope() != this.scope) {
201
						throw e;
202
					}
200
					classFile.contentsOffset = problemResetPC;
203
					classFile.contentsOffset = problemResetPC;
201
					classFile.methodCount--;
204
					classFile.methodCount--;
202
					classFile.codeStream.resetForCodeGenUnusedLocals();
205
					classFile.codeStream.resetForCodeGenUnusedLocals();
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (-1 / +3 lines)
Lines 75-81 Link Here
75
			for (int i = 0, count = syntheticArguments.length; i < count; i++){
75
			for (int i = 0, count = syntheticArguments.length; i < count; i++){
76
				SyntheticArgumentBinding syntheticArgument = syntheticArguments[i];
76
				SyntheticArgumentBinding syntheticArgument = syntheticArguments[i];
77
				LocalVariableBinding targetLocal;
77
				LocalVariableBinding targetLocal;
78
				if ((targetLocal = syntheticArgument.actualOuterLocalVariable) == null) continue;
78
				if ((targetLocal = syntheticArgument.actualOuterLocalVariable) == null) {
79
					continue;
80
				}
79
				if (targetLocal.declaration != null && !flowInfo.isDefinitelyAssigned(targetLocal)){
81
				if (targetLocal.declaration != null && !flowInfo.isDefinitelyAssigned(targetLocal)){
80
					currentScope.problemReporter().uninitializedLocalVariable(targetLocal, this);
82
					currentScope.problemReporter().uninitializedLocalVariable(targetLocal, this);
81
				}
83
				}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java (-3 / +3 lines)
Lines 149-157 Link Here
149
	 * @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile
149
	 * @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile
150
	 */
150
	 */
151
	private void generateCode(
151
	private void generateCode(
152
		ClassScope classScope,
152
			ClassScope classScope,
153
		ClassFile classFile,
153
			ClassFile classFile,
154
		int clinitOffset) {
154
			int clinitOffset) {
155
155
156
		ConstantPool constantPool = classFile.constantPool;
156
		ConstantPool constantPool = classFile.constantPool;
157
		int constantPoolOffset = constantPool.currentOffset;
157
		int constantPoolOffset = constantPool.currentOffset;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java (-3 / +8 lines)
Lines 229-234 Link Here
229
					abort = true;
229
					abort = true;
230
				}
230
				}
231
			} else if (e.compilationResult == CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE) {
231
			} else if (e.compilationResult == CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE) {
232
				if (e.getScope() != this.scope) {
233
					throw e;
234
				}
232
				classFile.contentsOffset = problemResetPC;
235
				classFile.contentsOffset = problemResetPC;
233
				classFile.methodCount--;
236
				classFile.methodCount--;
234
				classFile.codeStream.resetForCodeGenUnusedLocals();
237
				classFile.codeStream.resetForCodeGenUnusedLocals();
Lines 266-272 Link Here
266
	syntheticArgs = nestedType.syntheticOuterLocalVariables();
269
	syntheticArgs = nestedType.syntheticOuterLocalVariables();
267
	for (int i = 0, max = syntheticArgs == null ? 0 : syntheticArgs.length; i < max; i++) {
270
	for (int i = 0, max = syntheticArgs == null ? 0 : syntheticArgs.length; i < max; i++) {
268
		SyntheticArgumentBinding syntheticArg;
271
		SyntheticArgumentBinding syntheticArg;
269
		if ((syntheticArg = syntheticArgs[i]).matchingField != null) {
272
		if ((syntheticArg = syntheticArgs[i]).matchingField != null
273
				&& syntheticArg.actualOuterLocalVariable.resolvedPosition != -1) {
270
			codeStream.aload_0();
274
			codeStream.aload_0();
271
			codeStream.load(syntheticArg);
275
			codeStream.load(syntheticArg);
272
			codeStream.fieldAccess(Opcodes.OPC_putfield, syntheticArg.matchingField, null /* default declaringClass */);
276
			codeStream.fieldAccess(Opcodes.OPC_putfield, syntheticArg.matchingField, null /* default declaringClass */);
Lines 294-303 Link Here
294
298
295
		if (declaringClass.isNestedType()){
299
		if (declaringClass.isNestedType()){
296
			this.scope.extraSyntheticArguments = declaringClass.syntheticOuterLocalVariables();
300
			this.scope.extraSyntheticArguments = declaringClass.syntheticOuterLocalVariables();
301
			int enclosingInstancesSlotSize = declaringClass.getEnclosingInstancesSlotSize();
297
			this.scope.computeLocalVariablePositions(// consider synthetic arguments if any
302
			this.scope.computeLocalVariablePositions(// consider synthetic arguments if any
298
					declaringClass.getEnclosingInstancesSlotSize() + 1 + enumOffset,
303
					enclosingInstancesSlotSize + 1 + enumOffset,
299
				codeStream);
304
				codeStream);
300
			argSlotSize += declaringClass.getEnclosingInstancesSlotSize();
305
			argSlotSize += enclosingInstancesSlotSize;
301
			argSlotSize += declaringClass.getOuterLocalVariablesSlotSize();
306
			argSlotSize += declaringClass.getOuterLocalVariablesSlotSize();
302
		} else {
307
		} else {
303
			this.scope.computeLocalVariablePositions(1 + enumOffset,  codeStream);
308
			this.scope.computeLocalVariablePositions(1 + enumOffset,  codeStream);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java (+4 lines)
Lines 192-197 Link Here
192
		codeStream.recordPositionsFrom(pc, this.sourceStart);
192
		codeStream.recordPositionsFrom(pc, this.sourceStart);
193
		return;
193
		return;
194
	}
194
	}
195
	reportOnlyUselesslyReadPrivateField(currentScope, this.binding, valueRequired);
195
	FieldBinding codegenBinding = this.binding.original();
196
	FieldBinding codegenBinding = this.binding.original();
196
	boolean isStatic = codegenBinding.isStatic();
197
	boolean isStatic = codegenBinding.isStatic();
197
	boolean isThisReceiver = this.receiver instanceof ThisReference;
198
	boolean isThisReceiver = this.receiver instanceof ThisReference;
Lines 523-528 Link Here
523
	// constants are propaged when the field is final
524
	// constants are propaged when the field is final
524
	// and initialized with a (compile time) constant
525
	// and initialized with a (compile time) constant
525
526
527
	if (scope.isInsideCondition)
528
		this.bits |= ASTNode.IsInsideCondition;
529
526
	//always ignore receiver cast, since may affect constant pool reference
530
	//always ignore receiver cast, since may affect constant pool reference
527
	boolean receiverCast = false;
531
	boolean receiverCast = false;
528
	if (this.receiver instanceof CastExpression) {
532
	if (this.receiver instanceof CastExpression) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java (-1 / +7 lines)
Lines 377-383 Link Here
377
			for (int i = 0, length = this.initializations.length; i < length; i++)
377
			for (int i = 0, length = this.initializations.length; i < length; i++)
378
				this.initializations[i].resolve(this.scope);
378
				this.initializations[i].resolve(this.scope);
379
		if (this.condition != null) {
379
		if (this.condition != null) {
380
			TypeBinding type = this.condition.resolveTypeExpecting(this.scope, TypeBinding.BOOLEAN);
380
			TypeBinding type = null;
381
			try {
382
				upperScope.isInsideCondition = true;
383
				type = this.condition.resolveTypeExpecting(this.scope, TypeBinding.BOOLEAN);
384
			} finally  {
385
				upperScope.isInsideCondition = false;
386
			}
381
			this.condition.computeConversion(this.scope, type, type);
387
			this.condition.computeConversion(this.scope, type, type);
382
		}
388
		}
383
		if (this.increments != null)
389
		if (this.increments != null)
(-)compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java (-1 / +7 lines)
Lines 260-266 Link Here
260
}
260
}
261
261
262
public void resolve(BlockScope scope) {
262
public void resolve(BlockScope scope) {
263
	TypeBinding type = this.condition.resolveTypeExpecting(scope, TypeBinding.BOOLEAN);
263
	TypeBinding type = null;
264
	try {
265
		scope.isInsideCondition = true;
266
		type = this.condition.resolveTypeExpecting(scope, TypeBinding.BOOLEAN);
267
	} finally {
268
		scope.isInsideCondition = false;
269
	}
264
	this.condition.computeConversion(scope, type, type);
270
	this.condition.computeConversion(scope, type, type);
265
	if (this.thenStatement != null)
271
	if (this.thenStatement != null)
266
		this.thenStatement.resolve(scope);
272
		this.thenStatement.resolve(scope);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-2 / +14 lines)
Lines 32-37 Link Here
32
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
32
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
33
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
33
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
34
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
34
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
35
import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
35
36
36
/**
37
/**
37
 * Variation on allocation, where can optionally be specified any of:
38
 * Variation on allocation, where can optionally be specified any of:
Lines 126-131 Link Here
126
			codeStream.ldc(String.valueOf(this.enumConstant.name));
127
			codeStream.ldc(String.valueOf(this.enumConstant.name));
127
			codeStream.generateInlinedValue(this.enumConstant.binding.id);
128
			codeStream.generateInlinedValue(this.enumConstant.binding.id);
128
		}
129
		}
130
		// invoke constructor
131
		int constantPoolOffset = codeStream.constantPool.currentOffset;
132
		int constantPoolIndex = codeStream.constantPool.currentIndex;
129
		// handling innerclass instance allocation - enclosing instance arguments
133
		// handling innerclass instance allocation - enclosing instance arguments
130
		if (allocatedType.isNestedType()) {
134
		if (allocatedType.isNestedType()) {
131
			codeStream.generateSyntheticEnclosingInstanceValues(
135
			codeStream.generateSyntheticEnclosingInstanceValues(
Lines 144-150 Link Here
144
				this);
148
				this);
145
		}
149
		}
146
150
147
		// invoke constructor
148
		if (this.syntheticAccessor == null) {
151
		if (this.syntheticAccessor == null) {
149
			codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, null /* default declaringClass */);
152
			codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, null /* default declaringClass */);
150
		} else {
153
		} else {
Lines 174-180 Link Here
174
		codeStream.recordPositionsFrom(pc, this.sourceStart);
177
		codeStream.recordPositionsFrom(pc, this.sourceStart);
175
178
176
		if (this.anonymousType != null) {
179
		if (this.anonymousType != null) {
177
			this.anonymousType.generateCode(currentScope, codeStream);
180
			try {
181
				this.anonymousType.generateCode(currentScope, codeStream);
182
			} catch(AbortMethod e) {
183
				if (e.compilationResult == CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE) {
184
					this.binding.resetSignature();
185
					codeStream.constantPool.currentIndex = constantPoolIndex;
186
					codeStream.constantPool.currentOffset = constantPoolOffset;
187
				}
188
				throw e;
189
			}
178
		}
190
		}
179
	}
191
	}
180
192
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java (-5 / +6 lines)
Lines 306-311 Link Here
306
	} else {
306
	} else {
307
		FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
307
		FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
308
		if (lastFieldBinding != null) {
308
		if (lastFieldBinding != null) {
309
			reportOnlyUselesslyReadPrivateField(currentScope, lastFieldBinding, valueRequired);
309
			boolean isStatic = lastFieldBinding.isStatic();
310
			boolean isStatic = lastFieldBinding.isStatic();
310
			Constant fieldConstant = lastFieldBinding.constant();
311
			Constant fieldConstant = lastFieldBinding.constant();
311
			if (fieldConstant != Constant.NotAConstant) {
312
			if (fieldConstant != Constant.NotAConstant) {
Lines 788-798 Link Here
788
				// local was tagged as uninitialized
789
				// local was tagged as uninitialized
789
				return;
790
				return;
790
			}
791
			}
791
			switch(localVariableBinding.useFlag) {
792
			currentScope.emulateOuterAccess(localVariableBinding);
792
				case LocalVariableBinding.FAKE_USED :
793
				case LocalVariableBinding.USED :
794
					currentScope.emulateOuterAccess(localVariableBinding);
795
			}
796
		}
793
		}
797
	}
794
	}
798
}
795
}
Lines 919-924 Link Here
919
	// field and/or local are done before type lookups
916
	// field and/or local are done before type lookups
920
	// the only available value for the restrictiveFlag BEFORE
917
	// the only available value for the restrictiveFlag BEFORE
921
	// the TC is Flag_Type Flag_LocalField and Flag_TypeLocalField
918
	// the TC is Flag_Type Flag_LocalField and Flag_TypeLocalField
919
920
	if (scope.isInsideCondition)
921
		this.bits |= ASTNode.IsInsideCondition;
922
922
	this.actualReceiverType = scope.enclosingReceiverType();
923
	this.actualReceiverType = scope.enclosingReceiverType();
923
	this.constant = Constant.NotAConstant;
924
	this.constant = Constant.NotAConstant;
924
	if ((this.binding = scope.getBinding(this.tokens, this.bits & ASTNode.RestrictiveFlagMASK, this, true /*resolve*/)).isValidBinding()) {
925
	if ((this.binding = scope.getBinding(this.tokens, this.bits & ASTNode.RestrictiveFlagMASK, this, true /*resolve*/)).isValidBinding()) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java (-9 / +18 lines)
Lines 171-177 Link Here
171
				currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
171
				currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
172
			}
172
			}
173
			if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) {
173
			if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) {
174
				localBinding.useFlag = LocalVariableBinding.USED;
174
				// check possibility for optimization (https://bugs.eclipse.org/328830):
175
				if ((this.implicitConversion & TypeIds.UNBOXING) == 0		// only optimize if no unboxing is involved 
176
						&& (this.bits & ASTNode.IsInsideCondition) != 0) 	// only optimize within a condition that may be unnecessary
177
				{
178
					// use values < 0 to count the number of uses which might fall subject to optimization:
179
					if (localBinding.useFlag <= LocalVariableBinding.UNUSED)
180
						localBinding.useFlag--;
181
				} else {
182
					localBinding.useFlag = LocalVariableBinding.USED;
183
				}
175
			} else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
184
			} else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
176
				localBinding.useFlag = LocalVariableBinding.FAKE_USED;
185
				localBinding.useFlag = LocalVariableBinding.FAKE_USED;
177
			}
186
			}
Lines 370-375 Link Here
370
		switch (this.bits & ASTNode.RestrictiveFlagMASK) {
379
		switch (this.bits & ASTNode.RestrictiveFlagMASK) {
371
			case Binding.FIELD : // reading a field
380
			case Binding.FIELD : // reading a field
372
				FieldBinding codegenField = ((FieldBinding) this.binding).original();
381
				FieldBinding codegenField = ((FieldBinding) this.binding).original();
382
				reportOnlyUselesslyReadPrivateField(currentScope, codegenField, valueRequired);
373
				Constant fieldConstant = codegenField.constant();
383
				Constant fieldConstant = codegenField.constant();
374
				if (fieldConstant != Constant.NotAConstant) {
384
				if (fieldConstant != Constant.NotAConstant) {
375
					// directly use inlined value for constant fields
385
					// directly use inlined value for constant fields
Lines 423-433 Link Here
423
				break;
433
				break;
424
			case Binding.LOCAL : // reading a local
434
			case Binding.LOCAL : // reading a local
425
				LocalVariableBinding localBinding = (LocalVariableBinding) this.binding;
435
				LocalVariableBinding localBinding = (LocalVariableBinding) this.binding;
436
				Reference.reportOnlyUselesslyReadLocal(currentScope, localBinding, valueRequired);
426
				if (localBinding.resolvedPosition == -1) {
437
				if (localBinding.resolvedPosition == -1) {
427
					if (valueRequired) {
438
					if (valueRequired) {
428
						// restart code gen
439
						// restart code gen
429
						localBinding.useFlag = LocalVariableBinding.USED;
440
						localBinding.useFlag = LocalVariableBinding.USED;
430
						throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null);
441
						throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null, localBinding.declaringScope.methodScope());
431
					}
442
					}
432
					codeStream.recordPositionsFrom(pc, this.sourceStart);
443
					codeStream.recordPositionsFrom(pc, this.sourceStart);
433
					return;
444
					return;
Lines 554-560 Link Here
554
							 * - the constant can have potential side-effect
565
							 * - the constant can have potential side-effect
555
							 */
566
							 */
556
							localBinding.useFlag = LocalVariableBinding.USED;
567
							localBinding.useFlag = LocalVariableBinding.USED;
557
							throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null);
568
							throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null, localBinding.declaringScope.methodScope());
558
						} else if (assignConstant == Constant.NotAConstant) {
569
						} else if (assignConstant == Constant.NotAConstant) {
559
							// we only need to generate the value of the expression's constant if it is not a constant expression
570
							// we only need to generate the value of the expression's constant if it is not a constant expression
560
							expression.generateCode(currentScope, codeStream, false);
571
							expression.generateCode(currentScope, codeStream, false);
Lines 733-739 Link Here
733
				if (valueRequired) {
744
				if (valueRequired) {
734
					// restart code gen
745
					// restart code gen
735
					localBinding.useFlag = LocalVariableBinding.USED;
746
					localBinding.useFlag = LocalVariableBinding.USED;
736
					throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null);
747
					throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null, localBinding.declaringScope.methodScope());
737
				}
748
				}
738
				return;
749
				return;
739
			}
750
			}
Lines 807-817 Link Here
807
				// local was tagged as uninitialized
818
				// local was tagged as uninitialized
808
				return;
819
				return;
809
			}
820
			}
810
			switch(localVariableBinding.useFlag) {
821
			currentScope.emulateOuterAccess(localVariableBinding);
811
				case LocalVariableBinding.FAKE_USED :
812
				case LocalVariableBinding.USED :
813
					currentScope.emulateOuterAccess(localVariableBinding);
814
			}
815
		}
822
		}
816
	}
823
	}
817
}
824
}
Lines 914-919 Link Here
914
}
921
}
915
922
916
public TypeBinding resolveType(BlockScope scope) {
923
public TypeBinding resolveType(BlockScope scope) {
924
	if (scope.isInsideCondition)
925
		this.bits |= ASTNode.IsInsideCondition;
917
	// for code gen, harm the restrictiveFlag
926
	// for code gen, harm the restrictiveFlag
918
927
919
	if (this.actualReceiverType != null) {
928
	if (this.actualReceiverType != null) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java (-2 / +10 lines)
Lines 162-168 Link Here
162
					codeStream.pop();
162
					codeStream.pop();
163
				}
163
				}
164
			} else {
164
			} else {
165
				valueRequired = this.expression.constant == Constant.NotAConstant || hasCases;
165
				valueRequired = hasCases || 
166
								((this.expression.constant == Constant.NotAConstant) 
167
									&& (this.expression.implicitConversion & TypeIds.UNBOXING) != 0);
166
				// generate expression
168
				// generate expression
167
				this.expression.generateCode(currentScope, codeStream, valueRequired);
169
				this.expression.generateCode(currentScope, codeStream, valueRequired);
168
			}
170
			}
Lines 267-273 Link Here
267
	public void resolve(BlockScope upperScope) {
269
	public void resolve(BlockScope upperScope) {
268
		try {
270
		try {
269
			boolean isEnumSwitch = false;
271
			boolean isEnumSwitch = false;
270
			TypeBinding expressionType = this.expression.resolveType(upperScope);
272
			TypeBinding expressionType = null;
273
			try {
274
				upperScope.isInsideCondition = true;
275
				expressionType = this.expression.resolveType(upperScope);
276
			} finally  {
277
				upperScope.isInsideCondition = false;
278
			}
271
			if (expressionType != null) {
279
			if (expressionType != null) {
272
				this.expression.computeConversion(upperScope, expressionType, expressionType);
280
				this.expression.computeConversion(upperScope, expressionType, expressionType);
273
				checkType: {
281
				checkType: {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java (-1 / +4 lines)
Lines 498-505 Link Here
498
public void generateCode(ClassFile enclosingClassFile) {
498
public void generateCode(ClassFile enclosingClassFile) {
499
	if ((this.bits & ASTNode.HasBeenGenerated) != 0)
499
	if ((this.bits & ASTNode.HasBeenGenerated) != 0)
500
		return;
500
		return;
501
	this.bits |= ASTNode.HasBeenGenerated;
502
	if (this.ignoreFurtherInvestigation) {
501
	if (this.ignoreFurtherInvestigation) {
502
		this.bits |= ASTNode.HasBeenGenerated;
503
		if (this.binding == null)
503
		if (this.binding == null)
504
			return;
504
			return;
505
		ClassFile.createProblemType(
505
		ClassFile.createProblemType(
Lines 554-559 Link Here
554
		this.scope.referenceCompilationUnit().compilationResult.record(
554
		this.scope.referenceCompilationUnit().compilationResult.record(
555
			this.binding.constantPoolName(),
555
			this.binding.constantPoolName(),
556
			classFile);
556
			classFile);
557
		this.bits |= ASTNode.HasBeenGenerated;
558
	} catch(AbortMethod e) {
559
		throw e;
557
	} catch (AbortType e) {
560
	} catch (AbortType e) {
558
		if (this.binding == null)
561
		if (this.binding == null)
559
			return;
562
			return;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java (-2 / +7 lines)
Lines 254-261 Link Here
254
	}
254
	}
255
255
256
	public void resolve(BlockScope scope) {
256
	public void resolve(BlockScope scope) {
257
257
		TypeBinding type = null;
258
		TypeBinding type = this.condition.resolveTypeExpecting(scope, TypeBinding.BOOLEAN);
258
		try {
259
			scope.isInsideCondition = true;
260
			type = this.condition.resolveTypeExpecting(scope, TypeBinding.BOOLEAN);
261
		} finally  {
262
			scope.isInsideCondition = false;
263
		}
259
		this.condition.computeConversion(scope, type, type);
264
		this.condition.computeConversion(scope, type, type);
260
		if (this.action != null)
265
		if (this.action != null)
261
			this.action.resolve(scope);
266
			this.action.resolve(scope);
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-5 / +21 lines)
Lines 2263-2269 Link Here
2263
		aload_0();
2263
		aload_0();
2264
		fieldAccess(Opcodes.OPC_getfield, fieldBinding, null /* default declaringClass */);
2264
		fieldAccess(Opcodes.OPC_getfield, fieldBinding, null /* default declaringClass */);
2265
	} else {
2265
	} else {
2266
		load((LocalVariableBinding) mappingSequence[0]);
2266
		LocalVariableBinding localBinding = (LocalVariableBinding) mappingSequence[0];
2267
		if (localBinding.resolvedPosition != -1) {
2268
			load(localBinding);
2269
		}
2267
	}
2270
	}
2268
	for (int i = 1, length = mappingSequence.length; i < length; i++) {
2271
	for (int i = 1, length = mappingSequence.length; i < length; i++) {
2269
		if (mappingSequence[i] instanceof FieldBinding) {
2272
		if (mappingSequence[i] instanceof FieldBinding) {
Lines 2388-2394 Link Here
2388
		SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
2391
		SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
2389
		for (int i = 0; i < (syntheticArguments == null ? 0 : syntheticArguments.length); i++) {
2392
		for (int i = 0; i < (syntheticArguments == null ? 0 : syntheticArguments.length); i++) {
2390
			TypeBinding type;
2393
			TypeBinding type;
2391
			load(type = syntheticArguments[i].type, resolvedPosition);
2394
			SyntheticArgumentBinding syntheticArgumentBinding = syntheticArguments[i];
2395
			LocalVariableBinding actualOuterLocalVariable = syntheticArgumentBinding.actualOuterLocalVariable;
2396
			if (actualOuterLocalVariable != null && actualOuterLocalVariable.resolvedPosition == -1) {
2397
				continue;
2398
			}
2399
			load(type = syntheticArgumentBinding.type, resolvedPosition);
2392
			switch(type.id) {
2400
			switch(type.id) {
2393
				case TypeIds.T_long :
2401
				case TypeIds.T_long :
2394
				case TypeIds.T_double :
2402
				case TypeIds.T_double :
Lines 2709-2714 Link Here
2709
	if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) {
2717
	if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) {
2710
		for (int i = 0, max = syntheticArguments.length; i < max; i++) {
2718
		for (int i = 0, max = syntheticArguments.length; i < max; i++) {
2711
			LocalVariableBinding targetVariable = syntheticArguments[i].actualOuterLocalVariable;
2719
			LocalVariableBinding targetVariable = syntheticArguments[i].actualOuterLocalVariable;
2720
			if (targetVariable == null || targetVariable.resolvedPosition == -1) {
2721
				continue;
2722
			}
2712
			VariableBinding[] emulationPath = currentScope.getEmulationPath(targetVariable);
2723
			VariableBinding[] emulationPath = currentScope.getEmulationPath(targetVariable);
2713
			generateOuterAccess(emulationPath, invocationSite, targetVariable, currentScope);
2724
			generateOuterAccess(emulationPath, invocationSite, targetVariable, currentScope);
2714
		}
2725
		}
Lines 3860-3866 Link Here
3860
					SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
3871
					SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
3861
					if (syntheticArguments != null) {
3872
					if (syntheticArguments != null) {
3862
						for (int i = 0, max = syntheticArguments.length; i < max; i++) {
3873
						for (int i = 0, max = syntheticArguments.length; i < max; i++) {
3863
							switch (syntheticArguments[i].id)  {
3874
							SyntheticArgumentBinding syntheticArgumentBinding = syntheticArguments[i];
3875
							LocalVariableBinding actualOuterLocalVariable = syntheticArgumentBinding.actualOuterLocalVariable;
3876
							if (actualOuterLocalVariable == null || actualOuterLocalVariable.resolvedPosition == -1) {
3877
								continue;
3878
							}
3879
							switch (syntheticArgumentBinding.id) {
3864
								case TypeIds.T_double :
3880
								case TypeIds.T_double :
3865
								case TypeIds.T_long :
3881
								case TypeIds.T_long :
3866
									receiverAndArgsSize += 2;
3882
									receiverAndArgsSize += 2;
Lines 3868-3874 Link Here
3868
								default: 
3884
								default: 
3869
									receiverAndArgsSize++;
3885
									receiverAndArgsSize++;
3870
									break;
3886
									break;
3871
							}    						
3887
							}
3872
						}
3888
						}
3873
					}
3889
					}
3874
				}
3890
				}
Lines 3876-3882 Link Here
3876
					// adding String (name) and int (ordinal)
3892
					// adding String (name) and int (ordinal)
3877
					receiverAndArgsSize += 2;
3893
					receiverAndArgsSize += 2;
3878
				}
3894
				}
3879
			}    		
3895
			}
3880
			break;
3896
			break;
3881
		default :
3897
		default :
3882
			return; // should not occur
3898
			return; // should not occur
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java (-2 / +8 lines)
Lines 35-40 Link Here
35
	// record the current case statement being processed (for entire switch case block).
35
	// record the current case statement being processed (for entire switch case block).
36
	public CaseStatement enclosingCase; // from 1.4 on, local types should not be accessed across switch case blocks (52221)
36
	public CaseStatement enclosingCase; // from 1.4 on, local types should not be accessed across switch case blocks (52221)
37
37
38
	public boolean isInsideCondition = false;
39
38
	public final static VariableBinding[] EmulationPathToImplicitThis = {};
40
	public final static VariableBinding[] EmulationPathToImplicitThis = {};
39
	public final static VariableBinding[] NoEnclosingInstanceInConstructorCall = {};
41
	public final static VariableBinding[] NoEnclosingInstanceInConstructorCall = {};
40
42
Lines 894-903 Link Here
894
	if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) {
896
	if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) {
895
		for (int i = 0, max = syntheticArguments.length; i < max; i++) {
897
		for (int i = 0, max = syntheticArguments.length; i < max; i++) {
896
			SyntheticArgumentBinding syntheticArg = syntheticArguments[i];
898
			SyntheticArgumentBinding syntheticArg = syntheticArguments[i];
899
			LocalVariableBinding outerLocalVariable = syntheticArg.actualOuterLocalVariable;
897
			// need to filter out the one that could match a supplied enclosing instance
900
			// need to filter out the one that could match a supplied enclosing instance
898
			if (!(isEnclosingInstanceSupplied
901
			if (!(isEnclosingInstanceSupplied
899
				&& (syntheticArg.type == targetType.enclosingType()))) {
902
					&& (syntheticArg.type == targetType.enclosingType()))) {
900
				emulateOuterAccess(syntheticArg.actualOuterLocalVariable);
903
				if (outerLocalVariable == null || outerLocalVariable.resolvedPosition == -1) {
904
					continue;
905
				}
906
				emulateOuterAccess(outerLocalVariable);
901
			}
907
			}
902
		}
908
		}
903
	}
909
	}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java (-2 / +15 lines)
Lines 887-893 Link Here
887
		SyntheticArgumentBinding[] syntheticOuterArguments = this.declaringClass.syntheticOuterLocalVariables();
887
		SyntheticArgumentBinding[] syntheticOuterArguments = this.declaringClass.syntheticOuterLocalVariables();
888
		int count = syntheticOuterArguments == null ? 0 : syntheticOuterArguments.length;
888
		int count = syntheticOuterArguments == null ? 0 : syntheticOuterArguments.length;
889
		for (int i = 0; i < count; i++) {
889
		for (int i = 0; i < count; i++) {
890
			buffer.append(syntheticOuterArguments[i].type.signature());
890
			SyntheticArgumentBinding syntheticArgumentBinding = syntheticOuterArguments[i];
891
			LocalVariableBinding actualOuterLocalVariable = syntheticArgumentBinding.actualOuterLocalVariable;
892
			if (actualOuterLocalVariable == null || actualOuterLocalVariable.resolvedPosition == -1) {
893
				continue;
894
			}
895
			buffer.append(syntheticArgumentBinding.type.signature());
891
		}
896
		}
892
		// move the extra padding arguments of the synthetic constructor invocation to the end
897
		// move the extra padding arguments of the synthetic constructor invocation to the end
893
		for (int i = targetParameters.length, extraLength = this.parameters.length; i < extraLength; i++) {
898
		for (int i = targetParameters.length, extraLength = this.parameters.length; i < extraLength; i++) {
Lines 1005-1011 Link Here
1005
		SyntheticArgumentBinding[] syntheticOuterArguments = this.declaringClass.syntheticOuterLocalVariables();
1010
		SyntheticArgumentBinding[] syntheticOuterArguments = this.declaringClass.syntheticOuterLocalVariables();
1006
		int count = syntheticOuterArguments == null ? 0 : syntheticOuterArguments.length;
1011
		int count = syntheticOuterArguments == null ? 0 : syntheticOuterArguments.length;
1007
		for (int i = 0; i < count; i++) {
1012
		for (int i = 0; i < count; i++) {
1008
			buffer.append(syntheticOuterArguments[i].type.signature());
1013
			SyntheticArgumentBinding syntheticArgumentBinding = syntheticOuterArguments[i];
1014
			LocalVariableBinding actualOuterLocalVariable = syntheticArgumentBinding.actualOuterLocalVariable;
1015
			if (actualOuterLocalVariable == null || actualOuterLocalVariable.resolvedPosition == -1) {
1016
				continue;
1017
			}
1018
			buffer.append(syntheticArgumentBinding.type.signature());
1009
		}
1019
		}
1010
		// move the extra padding arguments of the synthetic constructor invocation to the end
1020
		// move the extra padding arguments of the synthetic constructor invocation to the end
1011
		for (int i = targetParameters.length, extraLength = this.parameters.length; i < extraLength; i++) {
1021
		for (int i = targetParameters.length, extraLength = this.parameters.length; i < extraLength; i++) {
Lines 1118-1121 Link Here
1118
public TypeVariableBinding[] typeVariables() {
1128
public TypeVariableBinding[] typeVariables() {
1119
	return this.typeVariables;
1129
	return this.typeVariables;
1120
}
1130
}
1131
public void resetSignature() {
1132
	this.signature = null;
1133
}
1121
}
1134
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 127-134 Link Here
127
	if (this.outerLocalVariablesSlotSize < 0) {
127
	if (this.outerLocalVariablesSlotSize < 0) {
128
		this.outerLocalVariablesSlotSize = 0;
128
		this.outerLocalVariablesSlotSize = 0;
129
		int outerLocalsCount = this.outerLocalVariables == null ? 0 : this.outerLocalVariables.length;
129
		int outerLocalsCount = this.outerLocalVariables == null ? 0 : this.outerLocalVariables.length;
130
			for (int i = 0; i < outerLocalsCount; i++){
130
		for (int i = 0; i < outerLocalsCount; i++) {
131
			SyntheticArgumentBinding argument = this.outerLocalVariables[i];
131
			SyntheticArgumentBinding argument = this.outerLocalVariables[i];
132
			LocalVariableBinding outerLocalVariable = argument.actualOuterLocalVariable;
133
			if (outerLocalVariable == null || outerLocalVariable.resolvedPosition == -1) {
134
				continue;
135
			}
132
			switch (argument.type.id) {
136
			switch (argument.type.id) {
133
				case TypeIds.T_long :
137
				case TypeIds.T_long :
134
				case TypeIds.T_double :
138
				case TypeIds.T_double :
(-)compiler/org/eclipse/jdt/internal/compiler/problem/AbortMethod.java (-1 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-17 Link Here
12
12
13
import org.eclipse.jdt.core.compiler.CategorizedProblem;
13
import org.eclipse.jdt.core.compiler.CategorizedProblem;
14
import org.eclipse.jdt.internal.compiler.CompilationResult;
14
import org.eclipse.jdt.internal.compiler.CompilationResult;
15
import org.eclipse.jdt.internal.compiler.lookup.Scope;
15
16
16
/*
17
/*
17
 * Special unchecked exception type used
18
 * Special unchecked exception type used
Lines 22-29 Link Here
22
public class AbortMethod extends AbortType {
23
public class AbortMethod extends AbortType {
23
24
24
	private static final long serialVersionUID = -1480267398969840003L; // backward compatible
25
	private static final long serialVersionUID = -1480267398969840003L; // backward compatible
26
	private Scope scope;
25
27
26
public AbortMethod(CompilationResult compilationResult, CategorizedProblem problem) {
28
public AbortMethod(CompilationResult compilationResult, CategorizedProblem problem) {
27
	super(compilationResult, problem);
29
	super(compilationResult, problem);
28
}
30
}
31
public AbortMethod(CompilationResult compilationResult, CategorizedProblem problem, Scope scope) {
32
	super(compilationResult, problem);
33
	this.scope = scope;
34
}
35
public Scope getScope() {
36
	return this.scope;
37
}
29
}
38
}
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java (-2 / +2 lines)
Lines 275-281 Link Here
275
					if (valueRequired) {
275
					if (valueRequired) {
276
						// restart code gen
276
						// restart code gen
277
						localBinding.useFlag = LocalVariableBinding.USED;
277
						localBinding.useFlag = LocalVariableBinding.USED;
278
						throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null);
278
						throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null, localBinding.declaringScope.methodScope());
279
					}
279
					}
280
					codeStream.recordPositionsFrom(pc, this.sourceStart);
280
					codeStream.recordPositionsFrom(pc, this.sourceStart);
281
					return;
281
					return;
Lines 370-376 Link Here
370
							 * - the constant can have potential side-effect
370
							 * - the constant can have potential side-effect
371
							 */
371
							 */
372
							localBinding.useFlag = LocalVariableBinding.USED;
372
							localBinding.useFlag = LocalVariableBinding.USED;
373
							throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null);
373
							throw new AbortMethod(CodeStream.RESTART_CODE_GEN_FOR_UNUSED_LOCALS_MODE, null, localBinding.declaringScope.methodScope());
374
						} else if (assignConstant == Constant.NotAConstant) {
374
						} else if (assignConstant == Constant.NotAConstant) {
375
							// we only need to generate the value of the expression's constant if it is not a constant expression
375
							// we only need to generate the value of the expression's constant if it is not a constant expression
376
							expression.generateCode(currentScope, codeStream, false);
376
							expression.generateCode(currentScope, codeStream, false);
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetTypeDeclaration.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 30-38 Link Here
30
 */
30
 */
31
public void generateCode(ClassFile enclosingClassFile) {
31
public void generateCode(ClassFile enclosingClassFile) {
32
	if ((this.bits & ASTNode.HasBeenGenerated) != 0) return;
32
	if ((this.bits & ASTNode.HasBeenGenerated) != 0) return;
33
	this.bits |= ASTNode.HasBeenGenerated;
34
33
35
	if (this.ignoreFurtherInvestigation) {
34
	if (this.ignoreFurtherInvestigation) {
35
		this.bits |= ASTNode.HasBeenGenerated;
36
		if (this.binding == null)
36
		if (this.binding == null)
37
			return;
37
			return;
38
		CodeSnippetClassFile.createProblemType(this, this.scope.referenceCompilationUnit().compilationResult);
38
		CodeSnippetClassFile.createProblemType(this, this.scope.referenceCompilationUnit().compilationResult);
Lines 81-86 Link Here
81
		// finalize the compiled type result
81
		// finalize the compiled type result
82
		classFile.addAttributes();
82
		classFile.addAttributes();
83
		this.scope.referenceCompilationUnit().compilationResult.record(this.binding.constantPoolName(), classFile);
83
		this.scope.referenceCompilationUnit().compilationResult.record(this.binding.constantPoolName(), classFile);
84
		this.bits |= ASTNode.HasBeenGenerated;
84
	} catch (AbortType e) {
85
	} catch (AbortType e) {
85
		if (this.binding == null)
86
		if (this.binding == null)
86
			return;
87
			return;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-8 / +19 lines)
Lines 5950-5962 Link Here
5950
  + " -warn:+null"
5950
  + " -warn:+null"
5951
  + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
5951
  + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
5952
  "",
5952
  "",
5953
  "----------\n" +
5953
  "----------\n" + 
5954
  "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
5954
  "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
5955
  "	if (o == null) {}\n" +
5955
  "	Object o = null;\n" + 
5956
  "	    ^\n" +
5956
  "	       ^\n" + 
5957
  "Redundant null check: The variable o can only be null at this location\n" +
5957
  "The value of the local variable o is not used\n" + 
5958
  "----------\n" +
5958
  "----------\n" + 
5959
  "1 problem (1 warning)",
5959
  "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + 
5960
  "	if (o == null) {}\n" + 
5961
  "	    ^\n" + 
5962
  "Redundant null check: The variable o can only be null at this location\n" + 
5963
  "----------\n" + 
5964
  "2 problems (2 warnings)",
5960
  true);
5965
  true);
5961
}
5966
}
5962
// null ref option
5967
// null ref option
Lines 5979-5985 Link Here
5979
+ " -warn:+nullDereference"
5984
+ " -warn:+nullDereference"
5980
+ " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
5985
+ " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
5981
"",
5986
"",
5982
"",
5987
"----------\n" + 
5988
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
5989
"	Object o = null;\n" + 
5990
"	       ^\n" + 
5991
"The value of the local variable o is not used\n" + 
5992
"----------\n" + 
5993
"1 problem (1 warning)",
5983
true);
5994
true);
5984
}
5995
}
5985
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=190493
5996
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=190493
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java (-8 / +1021 lines)
Lines 28-45 Link Here
28
public class ProgrammingProblemsTest extends AbstractRegressionTest {
28
public class ProgrammingProblemsTest extends AbstractRegressionTest {
29
29
30
public ProgrammingProblemsTest(String name) {
30
public ProgrammingProblemsTest(String name) {
31
    super(name);
31
	super(name);
32
}
32
}
33
33
34
	// Static initializer to specify tests subset using TESTS_* static variables
34
	// Static initializer to specify tests subset using TESTS_* static variables
35
  	// All specified tests which does not belong to the class are skipped...
35
	// All specified tests which does not belong to the class are skipped...
36
  	// Only the highest compliance level is run; add the VM argument
36
	// Only the highest compliance level is run; add the VM argument
37
  	// -Dcompliance=1.4 (for example) to lower it if needed
37
	// -Dcompliance=1.4 (for example) to lower it if needed
38
  	static {
38
	static {
39
//    	TESTS_NAMES = new String[] { "test0055" };
39
//    	TESTS_NAMES = new String[] { "test0055" };
40
//		TESTS_NUMBERS = new int[] { 56 };
40
//		TESTS_NUMBERS = new int[] { 73 };
41
//  	TESTS_RANGE = new int[] { 1, -1 };
41
//  	TESTS_RANGE = new int[] { 66, -1 };
42
  	}
42
	}
43
43
44
public static Test suite() {
44
public static Test suite() {
45
    return buildAllCompliancesTestSuite(testClass());
45
    return buildAllCompliancesTestSuite(testClass());
Lines 2279-2282 Link Here
2279
		customOptions,
2279
		customOptions,
2280
		null);
2280
		null);
2281
}
2281
}
2282
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2283
// SingleNameReference, local, postIncr, emptyThen
2284
public void test0058()  throws Exception {
2285
	Map customOptions = getCompilerOptions();
2286
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.ERROR);	
2287
	this.runNegativeTest(
2288
		new String[] {
2289
			"X.java",
2290
			"public class X {\n" +
2291
			"	public void method() {\n" +
2292
			"		int a=10;\n" +
2293
			" 		if(a++ > 10) {\n" + // not counted as relevant use since bug 185682
2294
			"		}\n" +   
2295
			"    }\n" +
2296
			"}\n"
2297
		},
2298
		"----------\n" + 
2299
		"1. ERROR in X.java (at line 3)\n" + 
2300
		"	int a=10;\n" + 
2301
		"	    ^\n" + 
2302
		"The value of the local variable a is not used\n" + 
2303
		"----------\n",
2304
		null/*classLibraries*/,
2305
		true/*shouldFlushOutputDirectory*/,
2306
		customOptions);
2307
}
2308
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2309
// SingleNameReference, field, postIncr, emptyThenWithElse
2310
public void test0059()  throws Exception {
2311
	Map customOptions = getCompilerOptions();
2312
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);	
2313
	customOptions.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);	
2314
	this.runNegativeTest(
2315
		new String[] {
2316
			"X.java",
2317
			"public class X {\n" +
2318
			"	private int a=10;\n" +
2319
			"	public void method() {\n" +
2320
			" 		if(a++ > 10 && false) {\n" + // not counted as relevant use since bug 185682
2321
			"		} else {\n" +   
2322
			"			System.out.println(\"OK\");\n" +   
2323
			"		}\n" +   
2324
			"   }\n" +
2325
			"}\n"
2326
		},
2327
		"----------\n" + 
2328
		"1. ERROR in X.java (at line 2)\n" + 
2329
		"	private int a=10;\n" + 
2330
		"	            ^\n" + 
2331
		"The value of the field X.a is not used\n" + 
2332
		"----------\n",
2333
		null/*classLibraries*/,
2334
		true/*shouldFlushOutputDirectory*/,
2335
		customOptions);
2336
}
2337
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2338
// FieldReference, field, postIncr, optimizableCondition
2339
public void test0060()  throws Exception {
2340
	Map customOptions = getCompilerOptions();
2341
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);	
2342
	customOptions.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);	
2343
	this.runNegativeTest(
2344
		new String[] {
2345
			"X.java",
2346
			"public class X {\n" +
2347
			"	private int a=10;\n" +
2348
			"	public void method() {\n" +
2349
			" 		if(this.a++ > 10 || true) {\n" + // not counted as relevant use since bug 185682
2350
			"			System.out.println(\"OK\");\n" +
2351
			"		}\n" +   
2352
			"   }\n" +
2353
			"}\n"
2354
		},
2355
		"----------\n" + 
2356
		"1. ERROR in X.java (at line 2)\n" + 
2357
		"	private int a=10;\n" + 
2358
		"	            ^\n" + 
2359
		"The value of the field X.a is not used\n" + 
2360
		"----------\n",
2361
		null/*classLibraries*/,
2362
		true/*shouldFlushOutputDirectory*/,
2363
		customOptions);
2364
}
2365
2366
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2367
// SingleNameReference, local, simpleRead, emptyThen
2368
public void test0061()  throws Exception {
2369
	Map customOptions = getCompilerOptions();
2370
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.ERROR);	
2371
	this.runNegativeTest(
2372
		new String[] {
2373
			"X.java",
2374
			"public class X {\n" +
2375
			"	public void method() {\n" +
2376
			"		int a=10;\n" +
2377
			" 		if(a > 10) {\n" +
2378
			"		}\n" +   
2379
			"    }\n" +
2380
			"}\n"
2381
		},
2382
		"----------\n" + 
2383
		"1. ERROR in X.java (at line 3)\n" + 
2384
		"	int a=10;\n" + 
2385
		"	    ^\n" + 
2386
		"The value of the local variable a is not used\n" + 
2387
		"----------\n",
2388
		null/*classLibraries*/,
2389
		true/*shouldFlushOutputDirectory*/,
2390
		customOptions);
2391
}
2392
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2393
// SingleNameReference, field, simpleRead, emptyThenWithElse
2394
public void test0062()  throws Exception {
2395
	Map customOptions = getCompilerOptions();
2396
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);	
2397
	customOptions.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);	
2398
	this.runNegativeTest(
2399
		new String[] {
2400
			"X.java",
2401
			"public class X {\n" +
2402
			"	private int a=10;\n" +
2403
			"	public void method() {\n" +
2404
			" 		if(a > 10 && false) {\n" +
2405
			"		} else {\n" +   
2406
			"			System.out.println(\"OK\");\n" +   
2407
			"		}\n" +   
2408
			"   }\n" +
2409
			"}\n"
2410
		},
2411
		"----------\n" + 
2412
		"1. ERROR in X.java (at line 2)\n" + 
2413
		"	private int a=10;\n" + 
2414
		"	            ^\n" + 
2415
		"The value of the field X.a is not used\n" + 
2416
		"----------\n",
2417
		null/*classLibraries*/,
2418
		true/*shouldFlushOutputDirectory*/,
2419
		customOptions);
2420
}
2421
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2422
// FieldReference+QualifiedNameReference, field, simpleRead, optimizableCondition
2423
public void test0063()  throws Exception {
2424
	Map customOptions = getCompilerOptions();
2425
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);	
2426
	customOptions.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);	
2427
	this.runNegativeTest(
2428
		new String[] {
2429
			"X.java",
2430
			"public class X {\n" +
2431
			"	private int a=10;\n" +
2432
			"	public void method(X other) {\n" +
2433
			" 		if(this.a < 3 || true) {\n" +
2434
			"			System.out.println(\"OK\");\n" +
2435
			"		}\n" +   
2436
			" 		if(other.a > 10 || true) {\n" +
2437
			"			System.out.println(\"OK\");\n" +
2438
			"		}\n" +   
2439
			"   }\n" +
2440
			"}\n"
2441
		},
2442
		"----------\n" + 
2443
		"1. ERROR in X.java (at line 2)\n" + 
2444
		"	private int a=10;\n" + 
2445
		"	            ^\n" + 
2446
		"The value of the field X.a is not used\n" + 
2447
		"----------\n",
2448
		null/*classLibraries*/,
2449
		true/*shouldFlushOutputDirectory*/,
2450
		customOptions);
2451
}
2452
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2453
// FieldReference+QualifiedNameReference, field, postIncr, optimizableCondition, exprOfForWhileSwitch
2454
public void test0064()  throws Exception {
2455
	Map customOptions = getCompilerOptions();
2456
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);	
2457
	customOptions.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);	
2458
	this.runNegativeTest(
2459
		new String[] {
2460
			"X.java",
2461
			"public class X {\n" +
2462
			" 	private int a=10;\n" +
2463
			"	public void method(X other) {\n" +
2464
			" 		for(;other.a++ > 10 && false;) {\n" +
2465
			" 		}\n" +
2466
			" 		while (this.a++>10 && false) {\n" +
2467
			" 		}\n" +
2468
			" 		switch(a++) {\n" +
2469
			" 		}\n" +   
2470
			"   }\n" +
2471
			"}\n"
2472
		},
2473
		"----------\n" + 
2474
		"1. ERROR in X.java (at line 2)\n" + 
2475
		"	private int a=10;\n" + 
2476
		"	            ^\n" + 
2477
		"The value of the field X.a is not used\n" + 
2478
		"----------\n",
2479
		null/*classLibraries*/,
2480
		true/*shouldFlushOutputDirectory*/,
2481
		customOptions);
2482
}
2483
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2484
// SingleNameReference, argument, simpleRead, optimizableCondition, exprOfForWhileSwitch
2485
public void test0065()  throws Exception {
2486
	Map customOptions = getCompilerOptions();
2487
	customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.ERROR);	
2488
	customOptions.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);	
2489
	this.runNegativeTest(
2490
		new String[] {
2491
			"X.java",
2492
			"public class X {\n" +
2493
			"	public void method(int a) {\n" +
2494
			" 		for(;a > 10 && false;) {\n" +
2495
			" 		}\n" +
2496
			" 		while (a>10 && false) {\n" +
2497
			" 		}\n" +
2498
			" 		switch(a) {\n" +
2499
			" 		}\n" +   
2500
			"   }\n" +
2501
			"}\n"
2502
		},
2503
		"----------\n" + 
2504
		"1. ERROR in X.java (at line 2)\n" + 
2505
		"	public void method(int a) {\n" + 
2506
		"	                       ^\n" + 
2507
		"The value of the parameter a is not used\n" + 
2508
		"----------\n",
2509
		null/*classLibraries*/,
2510
		true/*shouldFlushOutputDirectory*/,
2511
		customOptions);
2512
}
2513
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2514
// SimpleNameReference, localOfEnclosing, simpleRead, valueNeeded signaled by AbortMethod
2515
public void test0066() throws Exception {
2516
	Map customOptions = getCompilerOptions();
2517
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.ERROR);
2518
	this.runConformTest(
2519
		new String[] {
2520
			"X.java",
2521
			"public class X {\n" + 
2522
			"    int bar() { return 23; }\n" +
2523
			"    void foo() {\n" + 
2524
			"        final int i=bar();\n" +
2525
			"        new Runnable() {\n" +
2526
			"            public void run() {\n" +
2527
			"                if (i>3) { System.out.print(4); }\n" + 	// value is used
2528
			"            }\n" + 
2529
			"        }.run();\n" + 
2530
			"    }\n" + 
2531
			"	public static void main(String[] args) {\n" +
2532
			"		new  X().foo();\n" +
2533
			"	}\n" +
2534
			"}"
2535
		},
2536
		"4",
2537
		null/*classLibraries*/,
2538
		true/*shouldFlushOutputDirectory*/,
2539
		null,
2540
		customOptions,
2541
		null);
2542
	String expectedOutput =
2543
			"  // Method descriptor #6 ()V\n" + 
2544
			"  // Stack: 4, Locals: 2\n" + 
2545
			"  void foo();\n" + 
2546
			"     0  aload_0 [this]\n" + 
2547
			"     1  invokevirtual X.bar() : int [17]\n" + 
2548
			"     4  istore_1 [i]\n" + 
2549
			"     5  new X$1 [19]\n" + 
2550
			"     8  dup\n" + 
2551
			"     9  aload_0 [this]\n" + 
2552
			"    10  iload_1 [i]\n" + 
2553
			"    11  invokespecial X$1(X, int) [21]\n" + 
2554
			"    14  invokevirtual X$1.run() : void [24]\n" + 
2555
			"    17  return\n" + 
2556
			"      Line numbers:\n" + 
2557
			"        [pc: 0, line: 4]\n" + 
2558
			"        [pc: 5, line: 5]\n" + 
2559
			"        [pc: 14, line: 9]\n" + 
2560
			"        [pc: 17, line: 10]\n" + 
2561
			"      Local variable table:\n" + 
2562
			"        [pc: 0, pc: 18] local: this index: 0 type: X\n" + 
2563
			"        [pc: 5, pc: 18] local: i index: 1 type: int\n";
2564
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
2565
	if (this.complianceLevel < ClassFileConstants.JDK1_4) {
2566
		expectedOutput =
2567
			"  // Method descriptor #13 (LX;I)V\n" + 
2568
			"  // Stack: 2, Locals: 3\n" + 
2569
			"  X$1(X arg0, int arg1);\n" + 
2570
			"     0  aload_0 [this]\n" + 
2571
			"     1  invokespecial java.lang.Object() [15]\n" + 
2572
			"     4  aload_0 [this]\n" + 
2573
			"     5  aload_1 [arg0]\n" + 
2574
			"     6  putfield X$1.this$0 : X [18]\n" + 
2575
			"     9  aload_0 [this]\n" + 
2576
			"    10  iload_2 [arg1]\n" + 
2577
			"    11  putfield X$1.val$i : int [20]\n" + 
2578
			"    14  return\n" + 
2579
			"      Line numbers:\n" + 
2580
			"        [pc: 0, line: 5]\n" + 
2581
			"        [pc: 4, line: 1]\n" + 
2582
			"      Local variable table:\n" + 
2583
			"        [pc: 0, pc: 15] local: this index: 0 type: new X(){}\n";
2584
	} else if (this.complianceLevel < ClassFileConstants.JDK1_5) {
2585
		expectedOutput =
2586
			"  // Method descriptor #13 (LX;I)V\n" + 
2587
			"  // Stack: 2, Locals: 3\n" + 
2588
			"  X$1(X arg0, int arg1);\n" + 
2589
			"     0  aload_0 [this]\n" + 
2590
			"     1  aload_1 [arg0]\n" + 
2591
			"     2  putfield X$1.this$0 : X [15]\n" + 
2592
			"     5  aload_0 [this]\n" + 
2593
			"     6  iload_2 [arg1]\n" + 
2594
			"     7  putfield X$1.val$i : int [17]\n" + 
2595
			"    10  aload_0 [this]\n" + 
2596
			"    11  invokespecial java.lang.Object() [19]\n" + 
2597
			"    14  return\n" + 
2598
			"      Line numbers:\n" + 
2599
			"        [pc: 0, line: 1]\n" + 
2600
			"        [pc: 10, line: 5]\n" + 
2601
			"      Local variable table:\n" + 
2602
			"        [pc: 0, pc: 15] local: this index: 0 type: new X(){}\n";
2603
	} else {
2604
		expectedOutput =
2605
			"  // Method descriptor #12 (LX;I)V\n" + 
2606
			"  // Stack: 2, Locals: 3\n" + 
2607
			"  X$1(X arg0, int arg1);\n" + 
2608
			"     0  aload_0 [this]\n" + 
2609
			"     1  aload_1 [arg0]\n" + 
2610
			"     2  putfield X$1.this$0 : X [14]\n" + 
2611
			"     5  aload_0 [this]\n" + 
2612
			"     6  iload_2 [arg1]\n" + 
2613
			"     7  putfield X$1.val$i : int [16]\n" + 
2614
			"    10  aload_0 [this]\n" + 
2615
			"    11  invokespecial java.lang.Object() [18]\n" + 
2616
			"    14  return\n" + 
2617
			"      Line numbers:\n" + 
2618
			"        [pc: 0, line: 1]\n" + 
2619
			"        [pc: 10, line: 5]\n" + 
2620
			"      Local variable table:\n" + 
2621
			"        [pc: 0, pc: 15] local: this index: 0 type: new X(){}\n";
2622
	}
2623
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X$1.class", "X$1", expectedOutput);
2624
}
2625
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2626
// SimpleNameReference, localOfEnclosing, simpleRead, emptyThen
2627
public void test0067() throws Exception {
2628
	Map customOptions = getCompilerOptions();
2629
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
2630
	this.runNegativeTest(
2631
		new String[] {
2632
			"X.java",
2633
			"class X {\n" + 
2634
			"    int bar() { return 23; }\n" +
2635
			"    void foo() {\n" + 
2636
			"        final int i=bar();\n" +
2637
			"        new Runnable() {\n" +
2638
			"            public void run() {\n" +
2639
			"                if (i>3) { }\n" + 	// value is optimized out
2640
			"            }\n" + 
2641
			"        }.run();\n" + 
2642
			"    }\n" + 
2643
			"}"
2644
		},
2645
		"----------\n" + 
2646
		"1. WARNING in X.java (at line 4)\n" + 
2647
		"	final int i=bar();\n" + 
2648
		"	          ^\n" + 
2649
		"The value of the local variable i is not used\n" + 
2650
		"----------\n",
2651
		null/*classLibraries*/,
2652
		true/*shouldFlushOutputDirectory*/,
2653
		customOptions);
2654
	String expectedOutput =
2655
			"  // Method descriptor #6 ()V\n" + 
2656
			"  // Stack: 3, Locals: 1\n" + 
2657
			"  void foo();\n" + 
2658
			"     0  aload_0 [this]\n" + 
2659
			"     1  invokevirtual X.bar() : int [17]\n" + 
2660
			"     4  pop\n" + 
2661
			"     5  new X$1 [19]\n" + 
2662
			"     8  dup\n" + 
2663
			"     9  aload_0 [this]\n" + 
2664
			"    10  invokespecial X$1(X) [21]\n" + 
2665
			"    13  invokevirtual X$1.run() : void [24]\n" + 
2666
			"    16  return\n" + 
2667
			"      Line numbers:\n" + 
2668
			"        [pc: 0, line: 4]\n" + 
2669
			"        [pc: 5, line: 5]\n" + 
2670
			"        [pc: 13, line: 9]\n" + 
2671
			"        [pc: 16, line: 10]\n" + 
2672
			"      Local variable table:\n" + 
2673
			"        [pc: 0, pc: 17] local: this index: 0 type: X\n";
2674
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
2675
}
2676
// https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2677
// SingleNameReference, local, assignmentAsExpression, emptyThen
2678
public void test0068()  throws Exception {
2679
	Map customOptions = getCompilerOptions();
2680
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);	
2681
	this.runNegativeTest(
2682
			new String[] {
2683
				"X.java",
2684
				"public class X {\n" +
2685
				"	public void method() {\n" +
2686
				"		int a=10;\n" +
2687
				"		int b;\n" +
2688
				" 		if((b=a) > 10) {\n" +
2689
				"		}\n" +   
2690
				"    }\n" +
2691
				"}\n"
2692
			},
2693
			"----------\n" + 
2694
			"1. WARNING in X.java (at line 4)\n" + 
2695
			"	int b;\n" + 
2696
			"	    ^\n" + 
2697
			"The value of the local variable b is not used\n" + 
2698
			"----------\n" + 
2699
			"2. WARNING in X.java (at line 4)\n" + // FIXME(SH): duplicate report due to restart (AbortMethod) 
2700
			"	int b;\n" + 
2701
			"	    ^\n" + 
2702
			"The value of the local variable b is not used\n" + 
2703
			"----------\n",
2704
			null/*classLibraries*/,
2705
			true/*shouldFlushOutputDirectory*/,
2706
			customOptions);
2707
	String expectedOutput =
2708
			"  // Method descriptor #6 ()V\n" + 
2709
			"  // Stack: 1, Locals: 2\n" + 
2710
			"  public void method();\n" + 
2711
			"    0  bipush 10\n" + 
2712
			"    2  istore_1 [a]\n" + 
2713
			"    3  iload_1 [a]\n" + 
2714
			"    4  pop\n" + 
2715
			"    5  return\n" + 
2716
			"      Line numbers:\n" + 
2717
			"        [pc: 0, line: 3]\n" + 
2718
			"        [pc: 3, line: 5]\n" + 
2719
			"        [pc: 5, line: 7]\n" + 
2720
			"      Local variable table:\n" + 
2721
			"        [pc: 0, pc: 6] local: this index: 0 type: X\n" + 
2722
			"        [pc: 3, pc: 6] local: a index: 1 type: int\n"; // b has been optimized out
2723
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
2724
}
2725
//https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2726
//SimpleNameReference, localOfEnclosing, simpleRead, valueNeeded signaled by AbortMethod
2727
public void test0069() throws Exception {
2728
	Map customOptions = getCompilerOptions();
2729
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
2730
	this.runConformTest(
2731
			new String[] {
2732
					"X.java",
2733
					"public class X {\n" + 
2734
					"    int bar() { return 23; }\n" +
2735
					"    void foo() {\n" + 
2736
					"        final int i=bar();\n" +
2737
					"        new Runnable() {\n" +
2738
					"            public void run() {\n" +
2739
					"                if (i>3) {}\n" + 	// value is not used
2740
					"                System.out.print(4);\n" +
2741
					"            }\n" + 
2742
					"        }.run();\n" + 
2743
					"    }\n" + 
2744
					"	public static void main(String[] args) {\n" +
2745
					"		new  X().foo();\n" +
2746
					"	}\n" +
2747
					"}"
2748
			},
2749
			"4",
2750
			null/*classLibraries*/,
2751
			true/*shouldFlushOutputDirectory*/,
2752
			null,
2753
			customOptions,
2754
			null);
2755
	String expectedOutput =
2756
			"  // Method descriptor #6 ()V\n" + 
2757
			"  // Stack: 3, Locals: 1\n" + 
2758
			"  void foo();\n" + 
2759
			"     0  aload_0 [this]\n" + 
2760
			"     1  invokevirtual X.bar() : int [17]\n" + 
2761
			"     4  pop\n" + 
2762
			"     5  new X$1 [19]\n" + 
2763
			"     8  dup\n" + 
2764
			"     9  aload_0 [this]\n" + 
2765
			"    10  invokespecial X$1(X) [21]\n" + 
2766
			"    13  invokevirtual X$1.run() : void [24]\n" + 
2767
			"    16  return\n" + 
2768
			"      Line numbers:\n" + 
2769
			"        [pc: 0, line: 4]\n" + 
2770
			"        [pc: 5, line: 5]\n" + 
2771
			"        [pc: 13, line: 10]\n" + 
2772
			"        [pc: 16, line: 11]\n" + 
2773
			"      Local variable table:\n" + 
2774
			"        [pc: 0, pc: 17] local: this index: 0 type: X\n";
2775
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
2776
	if (this.complianceLevel < ClassFileConstants.JDK1_4) {
2777
		expectedOutput =
2778
			"  // Method descriptor #13 (LX;)V\n" + 
2779
			"  // Stack: 2, Locals: 2\n" + 
2780
			"  X$1(X arg0);\n" + 
2781
			"     0  aload_0 [this]\n" + 
2782
			"     1  invokespecial java.lang.Object() [15]\n" + 
2783
			"     4  aload_0 [this]\n" + 
2784
			"     5  aload_1 [arg0]\n" + 
2785
			"     6  putfield X$1.this$0 : X [18]\n" + 
2786
			"     9  return\n" + 
2787
			"      Line numbers:\n" + 
2788
			"        [pc: 0, line: 5]\n" + 
2789
			"        [pc: 4, line: 1]\n" + 
2790
			"      Local variable table:\n" + 
2791
			"        [pc: 0, pc: 10] local: this index: 0 type: new X(){}\n";
2792
	} else if (this.complianceLevel < ClassFileConstants.JDK1_5) {
2793
		expectedOutput =
2794
			"  // Method descriptor #13 (LX;)V\n" + 
2795
			"  // Stack: 2, Locals: 2\n" + 
2796
			"  X$1(X arg0);\n" + 
2797
			"     0  aload_0 [this]\n" + 
2798
			"     1  aload_1 [arg0]\n" + 
2799
			"     2  putfield X$1.this$0 : X [15]\n" + 
2800
			"     5  aload_0 [this]\n" + 
2801
			"     6  invokespecial java.lang.Object() [17]\n" + 
2802
			"     9  return\n" + 
2803
			"      Line numbers:\n" + 
2804
			"        [pc: 0, line: 1]\n" + 
2805
			"        [pc: 5, line: 5]\n" + 
2806
			"      Local variable table:\n" + 
2807
			"        [pc: 0, pc: 10] local: this index: 0 type: new X(){}\n";
2808
	} else {
2809
		expectedOutput =
2810
			"  // Method descriptor #12 (LX;)V\n" + 
2811
			"  // Stack: 2, Locals: 2\n" + 
2812
			"  X$1(X arg0);\n" + 
2813
			"     0  aload_0 [this]\n" + 
2814
			"     1  aload_1 [arg0]\n" + 
2815
			"     2  putfield X$1.this$0 : X [14]\n" + 
2816
			"     5  aload_0 [this]\n" + 
2817
			"     6  invokespecial java.lang.Object() [16]\n" + 
2818
			"     9  return\n" + 
2819
			"      Line numbers:\n" + 
2820
			"        [pc: 0, line: 1]\n" + 
2821
			"        [pc: 5, line: 5]\n" + 
2822
			"      Local variable table:\n" + 
2823
			"        [pc: 0, pc: 10] local: this index: 0 type: new X(){}\n";
2824
	}
2825
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X$1.class", "X$1", expectedOutput);
2826
}
2827
//https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2828
//SimpleNameReference, localOfEnclosing, simpleRead, valueNeeded signaled by AbortMethod
2829
public void test0070() throws Exception {
2830
	Map customOptions = getCompilerOptions();
2831
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
2832
	this.runConformTest(
2833
			new String[] {
2834
				"X.java",
2835
				"public class X {\n" + 
2836
				"    int bar() { return 23; }\n" +
2837
				"    public X() {\n" + 
2838
				"        final int i=bar();\n" +
2839
				"        new Runnable() {\n" +
2840
				"            public void run() {\n" +
2841
				"                if (i>3) {}\n" + 	// value is not used
2842
				"                System.out.print(4);\n" +
2843
				"            }\n" + 
2844
				"        }.run();\n" + 
2845
				"    }\n" + 
2846
				"	public static void main(String[] args) {\n" +
2847
				"		new  X();\n" +
2848
				"	}\n" +
2849
				"}"
2850
		},
2851
		"4",
2852
		null/*classLibraries*/,
2853
		true/*shouldFlushOutputDirectory*/,
2854
		null,
2855
		customOptions,
2856
		null);
2857
	String expectedOutput =
2858
			"  // Method descriptor #13 ()V\n" + 
2859
			"  // Stack: 3, Locals: 1\n" + 
2860
			"  public X();\n" + 
2861
			"     0  aload_0 [this]\n" + 
2862
			"     1  invokespecial java.lang.Object() [14]\n" + 
2863
			"     4  aload_0 [this]\n" + 
2864
			"     5  invokevirtual X.bar() : int [16]\n" + 
2865
			"     8  pop\n" + 
2866
			"     9  new X$1 [18]\n" + 
2867
			"    12  dup\n" + 
2868
			"    13  aload_0 [this]\n" + 
2869
			"    14  invokespecial X$1(X) [20]\n" + 
2870
			"    17  invokevirtual X$1.run() : void [23]\n" + 
2871
			"    20  return\n" + 
2872
			"      Line numbers:\n" + 
2873
			"        [pc: 0, line: 3]\n" + 
2874
			"        [pc: 4, line: 4]\n" + 
2875
			"        [pc: 9, line: 5]\n" + 
2876
			"        [pc: 17, line: 10]\n" + 
2877
			"        [pc: 20, line: 11]\n" + 
2878
			"      Local variable table:\n" + 
2879
			"        [pc: 0, pc: 21] local: this index: 0 type: X\n";
2880
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
2881
	if (this.complianceLevel < ClassFileConstants.JDK1_4) {
2882
		expectedOutput =
2883
			"  // Method descriptor #13 (LX;)V\n" + 
2884
			"  // Stack: 2, Locals: 2\n" + 
2885
			"  X$1(X arg0);\n" + 
2886
			"     0  aload_0 [this]\n" + 
2887
			"     1  invokespecial java.lang.Object() [15]\n" + 
2888
			"     4  aload_0 [this]\n" + 
2889
			"     5  aload_1 [arg0]\n" + 
2890
			"     6  putfield X$1.this$0 : X [18]\n" + 
2891
			"     9  return\n" + 
2892
			"      Line numbers:\n" + 
2893
			"        [pc: 0, line: 5]\n" + 
2894
			"        [pc: 4, line: 1]\n" + 
2895
			"      Local variable table:\n" + 
2896
			"        [pc: 0, pc: 10] local: this index: 0 type: new X(){}\n";
2897
	} else if (this.complianceLevel < ClassFileConstants.JDK1_5) {
2898
		expectedOutput =
2899
			"  // Method descriptor #13 (LX;)V\n" + 
2900
			"  // Stack: 2, Locals: 2\n" + 
2901
			"  X$1(X arg0);\n" + 
2902
			"     0  aload_0 [this]\n" + 
2903
			"     1  aload_1 [arg0]\n" + 
2904
			"     2  putfield X$1.this$0 : X [15]\n" + 
2905
			"     5  aload_0 [this]\n" + 
2906
			"     6  invokespecial java.lang.Object() [17]\n" + 
2907
			"     9  return\n" + 
2908
			"      Line numbers:\n" + 
2909
			"        [pc: 0, line: 1]\n" + 
2910
			"        [pc: 5, line: 5]\n" + 
2911
			"      Local variable table:\n" + 
2912
			"        [pc: 0, pc: 10] local: this index: 0 type: new X(){}\n";
2913
	} else {
2914
		expectedOutput =
2915
			"  // Method descriptor #12 (LX;)V\n" + 
2916
			"  // Stack: 2, Locals: 2\n" + 
2917
			"  X$1(X arg0);\n" + 
2918
			"     0  aload_0 [this]\n" + 
2919
			"     1  aload_1 [arg0]\n" + 
2920
			"     2  putfield X$1.this$0 : X [14]\n" + 
2921
			"     5  aload_0 [this]\n" + 
2922
			"     6  invokespecial java.lang.Object() [16]\n" + 
2923
			"     9  return\n" + 
2924
			"      Line numbers:\n" + 
2925
			"        [pc: 0, line: 1]\n" + 
2926
			"        [pc: 5, line: 5]\n" + 
2927
			"      Local variable table:\n" + 
2928
			"        [pc: 0, pc: 10] local: this index: 0 type: new X(){}\n";
2929
	}
2930
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X$1.class", "X$1", expectedOutput);
2931
}
2932
//https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
2933
//SimpleNameReference, localOfEnclosing, simpleRead, valueNeeded signaled by AbortMethod
2934
public void test0071() throws Exception {
2935
	Map customOptions = getCompilerOptions();
2936
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.ERROR);
2937
	this.runConformTest(
2938
		new String[] {
2939
			"X.java",
2940
			"public class X {\n" + 
2941
			"    int bar() { return 23; }\n" +
2942
			"    X() {\n" + 
2943
			"        final int i=bar();\n" +
2944
			"        new Runnable() {\n" +
2945
			"            public void run() {\n" +
2946
			"                if (i>3) { System.out.print(4); }\n" + 	// value is used
2947
			"            }\n" + 
2948
			"        }.run();\n" + 
2949
			"    }\n" + 
2950
			"	public static void main(String[] args) {\n" +
2951
			"		new  X();\n" +
2952
			"	}\n" +
2953
			"}"
2954
		},
2955
		"4",
2956
		null/*classLibraries*/,
2957
		true/*shouldFlushOutputDirectory*/,
2958
		null,
2959
		customOptions,
2960
		null);
2961
	String expectedOutput =
2962
		"  // Method descriptor #13 ()V\n" + 
2963
		"  // Stack: 4, Locals: 2\n" + 
2964
		"  X();\n" + 
2965
		"     0  aload_0 [this]\n" + 
2966
		"     1  invokespecial java.lang.Object() [14]\n" + 
2967
		"     4  aload_0 [this]\n" + 
2968
		"     5  invokevirtual X.bar() : int [16]\n" + 
2969
		"     8  istore_1 [i]\n" + 
2970
		"     9  new X$1 [18]\n" + 
2971
		"    12  dup\n" + 
2972
		"    13  aload_0 [this]\n" + 
2973
		"    14  iload_1 [i]\n" + 
2974
		"    15  invokespecial X$1(X, int) [20]\n" + 
2975
		"    18  invokevirtual X$1.run() : void [23]\n" + 
2976
		"    21  return\n" + 
2977
		"      Line numbers:\n" + 
2978
		"        [pc: 0, line: 3]\n" + 
2979
		"        [pc: 4, line: 4]\n" + 
2980
		"        [pc: 9, line: 5]\n" + 
2981
		"        [pc: 18, line: 9]\n" + 
2982
		"        [pc: 21, line: 10]\n" + 
2983
		"      Local variable table:\n" + 
2984
		"        [pc: 0, pc: 22] local: this index: 0 type: X\n" + 
2985
		"        [pc: 9, pc: 22] local: i index: 1 type: int\n";
2986
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
2987
	if (this.complianceLevel < ClassFileConstants.JDK1_4) {
2988
		expectedOutput =
2989
				"  // Method descriptor #13 (LX;I)V\n" + 
2990
				"  // Stack: 2, Locals: 3\n" + 
2991
				"  X$1(X arg0, int arg1);\n" + 
2992
				"     0  aload_0 [this]\n" + 
2993
				"     1  invokespecial java.lang.Object() [15]\n" + 
2994
				"     4  aload_0 [this]\n" + 
2995
				"     5  aload_1 [arg0]\n" + 
2996
				"     6  putfield X$1.this$0 : X [18]\n" + 
2997
				"     9  aload_0 [this]\n" + 
2998
				"    10  iload_2 [arg1]\n" + 
2999
				"    11  putfield X$1.val$i : int [20]\n" + 
3000
				"    14  return\n" + 
3001
				"      Line numbers:\n" + 
3002
				"        [pc: 0, line: 5]\n" + 
3003
				"        [pc: 4, line: 1]\n" + 
3004
				"      Local variable table:\n" + 
3005
				"        [pc: 0, pc: 15] local: this index: 0 type: new X(){}\n";
3006
	} else if (this.complianceLevel < ClassFileConstants.JDK1_5) {
3007
		expectedOutput =
3008
				"  // Method descriptor #13 (LX;I)V\n" + 
3009
				"  // Stack: 2, Locals: 3\n" + 
3010
				"  X$1(X arg0, int arg1);\n" + 
3011
				"     0  aload_0 [this]\n" + 
3012
				"     1  aload_1 [arg0]\n" + 
3013
				"     2  putfield X$1.this$0 : X [15]\n" + 
3014
				"     5  aload_0 [this]\n" + 
3015
				"     6  iload_2 [arg1]\n" + 
3016
				"     7  putfield X$1.val$i : int [17]\n" + 
3017
				"    10  aload_0 [this]\n" + 
3018
				"    11  invokespecial java.lang.Object() [19]\n" + 
3019
				"    14  return\n" + 
3020
				"      Line numbers:\n" + 
3021
				"        [pc: 0, line: 1]\n" + 
3022
				"        [pc: 10, line: 5]\n" + 
3023
				"      Local variable table:\n" + 
3024
				"        [pc: 0, pc: 15] local: this index: 0 type: new X(){}\n";
3025
	} else {
3026
		expectedOutput =
3027
				"  // Method descriptor #12 (LX;I)V\n" + 
3028
				"  // Stack: 2, Locals: 3\n" + 
3029
				"  X$1(X arg0, int arg1);\n" + 
3030
				"     0  aload_0 [this]\n" + 
3031
				"     1  aload_1 [arg0]\n" + 
3032
				"     2  putfield X$1.this$0 : X [14]\n" + 
3033
				"     5  aload_0 [this]\n" + 
3034
				"     6  iload_2 [arg1]\n" + 
3035
				"     7  putfield X$1.val$i : int [16]\n" + 
3036
				"    10  aload_0 [this]\n" + 
3037
				"    11  invokespecial java.lang.Object() [18]\n" + 
3038
				"    14  return\n" + 
3039
				"      Line numbers:\n" + 
3040
				"        [pc: 0, line: 1]\n" + 
3041
				"        [pc: 10, line: 5]\n" + 
3042
				"      Local variable table:\n" + 
3043
				"        [pc: 0, pc: 15] local: this index: 0 type: new X(){}\n";
3044
	}
3045
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X$1.class", "X$1", expectedOutput);
3046
}
3047
//https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
3048
//SimpleNameReference, localOfEnclosing, simpleRead, valueNeeded signaled by AbortMethod
3049
public void test0072() throws Exception {
3050
	Map customOptions = getCompilerOptions();
3051
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.ERROR);
3052
	this.runConformTest(
3053
		new String[] {
3054
			"X.java",
3055
			"public class X {\n" + 
3056
			"    int bar() { return 23; }\n" +
3057
			"    X() {\n" + 
3058
			"        final int i=bar();\n" +
3059
			"        new Runnable() {\n" +
3060
			"            {\n" +
3061
			"                if (i>3) { System.out.print(4); }\n" + 	// value is used
3062
			"            }\n" + 
3063
			"            public void run() {\n" +
3064
			"            }\n" + 
3065
			"        }.run();\n" + 
3066
			"    }\n" + 
3067
			"	public static void main(String[] args) {\n" +
3068
			"		new  X();\n" +
3069
			"	}\n" +
3070
			"}"
3071
		},
3072
		"4",
3073
		null/*classLibraries*/,
3074
		true/*shouldFlushOutputDirectory*/,
3075
		null,
3076
		customOptions,
3077
		null);
3078
	String expectedOutput =
3079
		"  // Method descriptor #13 ()V\n" + 
3080
		"  // Stack: 4, Locals: 2\n" + 
3081
		"  X();\n" + 
3082
		"     0  aload_0 [this]\n" + 
3083
		"     1  invokespecial java.lang.Object() [14]\n" + 
3084
		"     4  aload_0 [this]\n" + 
3085
		"     5  invokevirtual X.bar() : int [16]\n" + 
3086
		"     8  istore_1 [i]\n" + 
3087
		"     9  new X$1 [18]\n" + 
3088
		"    12  dup\n" + 
3089
		"    13  aload_0 [this]\n" + 
3090
		"    14  iload_1 [i]\n" + 
3091
		"    15  invokespecial X$1(X, int) [20]\n" + 
3092
		"    18  invokevirtual X$1.run() : void [23]\n" + 
3093
		"    21  return\n" + 
3094
		"      Line numbers:\n" + 
3095
		"        [pc: 0, line: 3]\n" + 
3096
		"        [pc: 4, line: 4]\n" + 
3097
		"        [pc: 9, line: 5]\n" + 
3098
		"        [pc: 18, line: 11]\n" + 
3099
		"        [pc: 21, line: 12]\n" + 
3100
		"      Local variable table:\n" + 
3101
		"        [pc: 0, pc: 22] local: this index: 0 type: X\n" + 
3102
		"        [pc: 9, pc: 22] local: i index: 1 type: int\n";
3103
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
3104
	if (this.complianceLevel < ClassFileConstants.JDK1_4) {
3105
		expectedOutput =
3106
			"  // Method descriptor #11 (LX;I)V\n" + 
3107
			"  // Stack: 2, Locals: 3\n" + 
3108
			"  X$1(X arg0, int arg1);\n" + 
3109
			"     0  aload_0 [this]\n" + 
3110
			"     1  invokespecial java.lang.Object() [13]\n" + 
3111
			"     4  aload_0 [this]\n" + 
3112
			"     5  aload_1 [arg0]\n" + 
3113
			"     6  putfield X$1.this$0 : X [16]\n" + 
3114
			"     9  iload_2 [arg1]\n" + 
3115
			"    10  iconst_3\n" + 
3116
			"    11  if_icmple 21\n" + 
3117
			"    14  getstatic java.lang.System.out : java.io.PrintStream [18]\n" + 
3118
			"    17  iconst_4\n" + 
3119
			"    18  invokevirtual java.io.PrintStream.print(int) : void [24]\n" + 
3120
			"    21  return\n" + 
3121
			"      Line numbers:\n" + 
3122
			"        [pc: 0, line: 5]\n" + 
3123
			"        [pc: 9, line: 7]\n" + 
3124
			"        [pc: 21, line: 1]\n" + 
3125
			"      Local variable table:\n" + 
3126
			"        [pc: 0, pc: 22] local: this index: 0 type: new X(){}\n";
3127
	} else if (this.complianceLevel < ClassFileConstants.JDK1_5) {
3128
		expectedOutput =
3129
			"  // Method descriptor #11 (LX;I)V\n" + 
3130
			"  // Stack: 2, Locals: 3\n" + 
3131
			"  X$1(X arg0, int arg1);\n" + 
3132
			"     0  aload_0 [this]\n" + 
3133
			"     1  aload_1 [arg0]\n" + 
3134
			"     2  putfield X$1.this$0 : X [13]\n" + 
3135
			"     5  aload_0 [this]\n" + 
3136
			"     6  invokespecial java.lang.Object() [15]\n" + 
3137
			"     9  iload_2 [arg1]\n" + 
3138
			"    10  iconst_3\n" + 
3139
			"    11  if_icmple 21\n" + 
3140
			"    14  getstatic java.lang.System.out : java.io.PrintStream [18]\n" + 
3141
			"    17  iconst_4\n" + 
3142
			"    18  invokevirtual java.io.PrintStream.print(int) : void [24]\n" + 
3143
			"    21  return\n" + 
3144
			"      Line numbers:\n" + 
3145
			"        [pc: 0, line: 1]\n" + 
3146
			"        [pc: 5, line: 5]\n" + 
3147
			"        [pc: 9, line: 7]\n" + 
3148
			"      Local variable table:\n" + 
3149
			"        [pc: 0, pc: 22] local: this index: 0 type: new X(){}\n";
3150
	} else {
3151
		expectedOutput =
3152
			"  // Method descriptor #10 (LX;I)V\n" + 
3153
			"  // Stack: 2, Locals: 3\n" + 
3154
			"  X$1(X arg0, int arg1);\n" + 
3155
			"     0  aload_0 [this]\n" + 
3156
			"     1  aload_1 [arg0]\n" + 
3157
			"     2  putfield X$1.this$0 : X [12]\n" + 
3158
			"     5  aload_0 [this]\n" + 
3159
			"     6  invokespecial java.lang.Object() [14]\n" + 
3160
			"     9  iload_2 [arg1]\n" + 
3161
			"    10  iconst_3\n" + 
3162
			"    11  if_icmple 21\n" + 
3163
			"    14  getstatic java.lang.System.out : java.io.PrintStream [17]\n" + 
3164
			"    17  iconst_4\n" + 
3165
			"    18  invokevirtual java.io.PrintStream.print(int) : void [23]\n" + 
3166
			"    21  return\n" + 
3167
			"      Line numbers:\n" + 
3168
			"        [pc: 0, line: 1]\n" + 
3169
			"        [pc: 5, line: 5]\n" + 
3170
			"        [pc: 9, line: 7]\n" + 
3171
			"      Local variable table:\n" + 
3172
			"        [pc: 0, pc: 22] local: this index: 0 type: new X(){}\n";
3173
	}
3174
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X$1.class", "X$1", expectedOutput);
3175
}
3176
//https://bugs.eclipse.org/328830  -  Variable should be marked unused when it can be optimized out
3177
//SimpleNameReference, localOfEnclosing, simpleRead, valueNeeded signaled by AbortMethod
3178
public void test0073() throws Exception {
3179
	Map customOptions = getCompilerOptions();
3180
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
3181
	this.runConformTest(
3182
		new String[] {
3183
			"X.java",
3184
			"public class X {\n" + 
3185
			"    int bar() { return 23; }\n" +
3186
			"    X() {\n" + 
3187
			"        final int i=bar();\n" +
3188
			"        new Runnable() {\n" +
3189
			"            {\n" +
3190
			"                if (i>3) {}\n" + 	// value is not used
3191
			"                System.out.print(4);\n" +
3192
			"            }\n" + 
3193
			"            public void run() {\n" +
3194
			"            }\n" + 
3195
			"        }.run();\n" + 
3196
			"    }\n" + 
3197
			"	public static void main(String[] args) {\n" +
3198
			"		new  X();\n" +
3199
			"	}\n" +
3200
			"}"
3201
		},
3202
		"4",
3203
		null/*classLibraries*/,
3204
		true/*shouldFlushOutputDirectory*/,
3205
		null,
3206
		customOptions,
3207
		null);
3208
	String expectedOutput =
3209
		"  // Method descriptor #13 ()V\n" + 
3210
		"  // Stack: 3, Locals: 1\n" + 
3211
		"  X();\n" + 
3212
		"     0  aload_0 [this]\n" + 
3213
		"     1  invokespecial java.lang.Object() [14]\n" + 
3214
		"     4  aload_0 [this]\n" + 
3215
		"     5  invokevirtual X.bar() : int [16]\n" + 
3216
		"     8  pop\n" + 
3217
		"     9  new X$1 [18]\n" + 
3218
		"    12  dup\n" + 
3219
		"    13  aload_0 [this]\n" + 
3220
		"    14  invokespecial X$1(X) [20]\n" + 
3221
		"    17  invokevirtual X$1.run() : void [23]\n" + 
3222
		"    20  return\n" + 
3223
		"      Line numbers:\n" + 
3224
		"        [pc: 0, line: 3]\n" + 
3225
		"        [pc: 4, line: 4]\n" + 
3226
		"        [pc: 9, line: 5]\n" + 
3227
		"        [pc: 17, line: 12]\n" + 
3228
		"        [pc: 20, line: 13]\n" + 
3229
		"      Local variable table:\n" + 
3230
		"        [pc: 0, pc: 21] local: this index: 0 type: X\n";
3231
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
3232
	if (this.complianceLevel < ClassFileConstants.JDK1_4) {
3233
		expectedOutput =
3234
			"  // Method descriptor #11 (LX;)V\n" + 
3235
			"  // Stack: 2, Locals: 2\n" + 
3236
			"  X$1(X arg0);\n" + 
3237
			"     0  aload_0 [this]\n" + 
3238
			"     1  invokespecial java.lang.Object() [13]\n" + 
3239
			"     4  aload_0 [this]\n" + 
3240
			"     5  aload_1 [arg0]\n" + 
3241
			"     6  putfield X$1.this$0 : X [16]\n" + 
3242
			"     9  getstatic java.lang.System.out : java.io.PrintStream [18]\n" + 
3243
			"    12  iconst_4\n" + 
3244
			"    13  invokevirtual java.io.PrintStream.print(int) : void [24]\n" + 
3245
			"    16  return\n" + 
3246
			"      Line numbers:\n" + 
3247
			"        [pc: 0, line: 5]\n" + 
3248
			"        [pc: 9, line: 8]\n" + 
3249
			"        [pc: 16, line: 1]\n" + 
3250
			"      Local variable table:\n" + 
3251
			"        [pc: 0, pc: 17] local: this index: 0 type: new X(){}\n";
3252
	} else if (this.complianceLevel < ClassFileConstants.JDK1_5) {
3253
		expectedOutput =
3254
			"  // Method descriptor #11 (LX;)V\n" + 
3255
			"  // Stack: 2, Locals: 2\n" + 
3256
			"  X$1(X arg0);\n" + 
3257
			"     0  aload_0 [this]\n" + 
3258
			"     1  aload_1 [arg0]\n" + 
3259
			"     2  putfield X$1.this$0 : X [13]\n" + 
3260
			"     5  aload_0 [this]\n" + 
3261
			"     6  invokespecial java.lang.Object() [15]\n" + 
3262
			"     9  getstatic java.lang.System.out : java.io.PrintStream [18]\n" + 
3263
			"    12  iconst_4\n" + 
3264
			"    13  invokevirtual java.io.PrintStream.print(int) : void [24]\n" + 
3265
			"    16  return\n" + 
3266
			"      Line numbers:\n" + 
3267
			"        [pc: 0, line: 1]\n" + 
3268
			"        [pc: 5, line: 5]\n" + 
3269
			"        [pc: 9, line: 8]\n" + 
3270
			"      Local variable table:\n" + 
3271
			"        [pc: 0, pc: 17] local: this index: 0 type: new X(){}\n";
3272
	} else {
3273
		expectedOutput =
3274
			"  // Method descriptor #10 (LX;)V\n" + 
3275
			"  // Stack: 2, Locals: 2\n" + 
3276
			"  X$1(X arg0);\n" + 
3277
			"     0  aload_0 [this]\n" + 
3278
			"     1  aload_1 [arg0]\n" + 
3279
			"     2  putfield X$1.this$0 : X [12]\n" + 
3280
			"     5  aload_0 [this]\n" + 
3281
			"     6  invokespecial java.lang.Object() [14]\n" + 
3282
			"     9  getstatic java.lang.System.out : java.io.PrintStream [17]\n" + 
3283
			"    12  iconst_4\n" + 
3284
			"    13  invokevirtual java.io.PrintStream.print(int) : void [23]\n" + 
3285
			"    16  return\n" + 
3286
			"      Line numbers:\n" + 
3287
			"        [pc: 0, line: 1]\n" + 
3288
			"        [pc: 5, line: 5]\n" + 
3289
			"        [pc: 9, line: 8]\n" + 
3290
			"      Local variable table:\n" + 
3291
			"        [pc: 0, pc: 17] local: this index: 0 type: new X(){}\n";
3292
	}
3293
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X$1.class", "X$1", expectedOutput);
3294
}
2282
}
3295
}

Return to bug 328830