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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-40 / +30 lines)
Lines 136-141 Link Here
136
	// a jump to the next bytecode.
136
	// a jump to the next bytecode.
137
	public BranchLabel[] labels = new BranchLabel[LABELS_INCREMENT];
137
	public BranchLabel[] labels = new BranchLabel[LABELS_INCREMENT];
138
	public int lastEntryPC; // last entry recorded
138
	public int lastEntryPC; // last entry recorded
139
	public int lastAbruptCompletion; // position of last instruction which abrupts completion: goto/return/athrow
139
	public int[] lineSeparatorPositions;
140
	public int[] lineSeparatorPositions;
140
	
141
	
141
	public LocalVariableBinding[] locals = new LocalVariableBinding[LOCALS_INCREMENT];
142
	public LocalVariableBinding[] locals = new LocalVariableBinding[LOCALS_INCREMENT];
Lines 239-245 Link Here
239
}
240
}
240
public void addVisibleLocalVariable(LocalVariableBinding localBinding) {
241
public void addVisibleLocalVariable(LocalVariableBinding localBinding) {
241
	if (((this.generateAttributes & ClassFileConstants.ATTR_VARS) == 0)
242
	if (((this.generateAttributes & ClassFileConstants.ATTR_VARS) == 0)
242
		&& ((this.generateAttributes & ClassFileConstants.ATTR_STACK_MAP) == 0))
243
			&& ((this.generateAttributes & ClassFileConstants.ATTR_STACK_MAP) == 0))
243
		return;
244
		return;
244
245
245
	if (visibleLocalsCount >= visibleLocals.length)
246
	if (visibleLocalsCount >= visibleLocals.length)
Lines 354-359 Link Here
354
	}
355
	}
355
	position++;
356
	position++;
356
	bCodeStream[classFileOffset++] = Opcodes.OPC_areturn;
357
	bCodeStream[classFileOffset++] = Opcodes.OPC_areturn;
358
	this.lastAbruptCompletion = this.position;		
357
}
359
}
358
public void arrayAt(int typeBindingID) {
360
public void arrayAt(int typeBindingID) {
359
	switch (typeBindingID) {
361
	switch (typeBindingID) {
Lines 521-526 Link Here
521
	}
523
	}
522
	position++;
524
	position++;
523
	bCodeStream[classFileOffset++] = Opcodes.OPC_athrow;
525
	bCodeStream[classFileOffset++] = Opcodes.OPC_athrow;
526
	this.lastAbruptCompletion = this.position;		
524
}
527
}
525
public void baload() {
528
public void baload() {
526
	if (DEBUG) System.out.println(position + "\t\tbaload"); //$NON-NLS-1$
529
	if (DEBUG) System.out.println(position + "\t\tbaload"); //$NON-NLS-1$
Lines 859-864 Link Here
859
	}
862
	}
860
	position++;
863
	position++;
861
	bCodeStream[classFileOffset++] = Opcodes.OPC_dreturn;
864
	bCodeStream[classFileOffset++] = Opcodes.OPC_dreturn;
865
	this.lastAbruptCompletion = this.position;		
862
}
866
}
863
public void dstore(int iArg) {
867
public void dstore(int iArg) {
864
	if (DEBUG) System.out.println(position + "\t\tdstore:"+iArg); //$NON-NLS-1$
868
	if (DEBUG) System.out.println(position + "\t\tdstore:"+iArg); //$NON-NLS-1$
Lines 1293-1298 Link Here
1293
	}
1297
	}
1294
	position++;
1298
	position++;
1295
	bCodeStream[classFileOffset++] = Opcodes.OPC_freturn;
1299
	bCodeStream[classFileOffset++] = Opcodes.OPC_freturn;
1300
	this.lastAbruptCompletion = this.position;		
1296
}
1301
}
1297
public void fstore(int iArg) {
1302
public void fstore(int iArg) {
1298
	if (DEBUG) System.out.println(position + "\t\tfstore:"+iArg); //$NON-NLS-1$
1303
	if (DEBUG) System.out.println(position + "\t\tfstore:"+iArg); //$NON-NLS-1$
Lines 2944-2950 Link Here
2944
	if (classFileOffset >= bCodeStream.length) {
2949
	if (classFileOffset >= bCodeStream.length) {
2945
		resizeByteArray();
2950
		resizeByteArray();
2946
	}
2951
	}
2947
	this.inlineForwardReferencesFromLabelsTargeting(label, position);
2952
	boolean chained = this.inlineForwardReferencesFromLabelsTargeting(label, position);
2948
	/*
2953
	/*
2949
	 Possible optimization for code such as:
2954
	 Possible optimization for code such as:
2950
	 public Object foo() {
2955
	 public Object foo() {
Lines 2961-2989 Link Here
2961
	}
2966
	}
2962
	The goto around the else block for the first if will
2967
	The goto around the else block for the first if will
2963
	be unreachable, because the thenClause of the second if
2968
	be unreachable, because the thenClause of the second if
2964
	returns.
2969
	returns. Also see 114894
2965
	See inlineForwardReferencesFromLabelsTargeting defined
2966
	on the Label class for the remaining part of this
2967
	optimization.
2968
	 if (!lbl.isBranchTarget(position)) {
2969
		switch(bCodeStream[classFileOffset-1]) {
2970
			case Opcodes.OPC_return :
2971
			case Opcodes.OPC_areturn:
2972
				return;
2973
		}
2974
	}*/
2970
	}*/
2971
	if (chained && this.lastAbruptCompletion == this.position) {
2972
		return;
2973
	}
2975
	position++;
2974
	position++;
2976
	bCodeStream[classFileOffset++] = Opcodes.OPC_goto;
2975
	bCodeStream[classFileOffset++] = Opcodes.OPC_goto;
2977
	label.branch();
2976
	label.branch();
2977
	this.lastAbruptCompletion = this.position;
2978
}
2978
}
2979
final public void goto_w(BranchLabel lbl) {
2979
final public void goto_w(BranchLabel label) {
2980
	if (DEBUG) System.out.println(position + "\t\tgotow:"+lbl); //$NON-NLS-1$
2980
	if (DEBUG) System.out.println(position + "\t\tgotow:"+label); //$NON-NLS-1$
2981
	if (classFileOffset >= bCodeStream.length) {
2981
	if (classFileOffset >= bCodeStream.length) {
2982
		resizeByteArray();
2982
		resizeByteArray();
2983
	}
2983
	}
2984
	position++;
2984
	position++;
2985
	bCodeStream[classFileOffset++] = Opcodes.OPC_goto_w;
2985
	bCodeStream[classFileOffset++] = Opcodes.OPC_goto_w;
2986
	lbl.branchWide();
2986
	label.branchWide();
2987
	this.lastAbruptCompletion = this.position;	
2987
}
2988
}
2988
public void i2b() {
2989
public void i2b() {
2989
	if (DEBUG) System.out.println(position + "\t\ti2b"); //$NON-NLS-1$
2990
	if (DEBUG) System.out.println(position + "\t\ti2b"); //$NON-NLS-1$
Lines 3556-3591 Link Here
3556
/*
3557
/*
3557
 * Some placed labels might be branching to a goto bytecode which we can optimize better.
3558
 * Some placed labels might be branching to a goto bytecode which we can optimize better.
3558
 */
3559
 */
3559
public void inlineForwardReferencesFromLabelsTargeting(BranchLabel label, int gotoLocation) {
3560
public boolean inlineForwardReferencesFromLabelsTargeting(BranchLabel label, int gotoLocation) {
3560
	
3561
/*
3562
 Code required to optimized unreachable gotos.
3563
	public boolean isBranchTarget(int location) {
3564
		Label[] labels = codeStream.labels;
3565
		for (int i = codeStream.countLabels - 1; i >= 0; i--){
3566
			Label label = labels[i];
3567
			if ((label.position == location) && label.isStandardLabel()){
3568
				return true;
3569
			}
3570
		}
3571
		return false;
3572
	}
3573
 */
3574
	
3561
	
3562
	final int NONE = 0, CASE = 1, STANDARD = 2;
3563
	int chaining = NONE;
3575
	for (int i = this.countLabels - 1; i >= 0; i--) {
3564
	for (int i = this.countLabels - 1; i >= 0; i--) {
3576
		BranchLabel currentLabel = labels[i];
3565
		BranchLabel currentLabel = labels[i];
3577
		if (currentLabel.position == gotoLocation) {
3566
		if (currentLabel.position != gotoLocation) break;
3578
			if (currentLabel.isStandardLabel()) {
3567
		if (currentLabel.isStandardLabel()) {
3579
				label.appendForwardReferencesFrom(currentLabel);
3568
			label.appendForwardReferencesFrom(currentLabel);
3580
			}
3569
			chaining |= STANDARD;
3581
			/*
3570
		} else { // case label
3582
			 Code required to optimized unreachable gotos.
3571
			chaining |= CASE;
3583
				label.position = POS_NOT_SET;
3584
			*/
3585
		} else {
3586
			break; // same target labels should be contiguous
3587
		}
3572
		}
3588
	}
3573
	}
3574
	return (chaining & (STANDARD|CASE)) == STANDARD; // check was some standards, and no case
3589
}
3575
}
3590
public void init(ClassFile targetClassFile) {
3576
public void init(ClassFile targetClassFile) {
3591
	this.classFile = targetClassFile;
3577
	this.classFile = targetClassFile;
Lines 3622-3627 Link Here
3622
	}
3608
	}
3623
	System.arraycopy(noLabels, 0, labels, 0, length);
3609
	System.arraycopy(noLabels, 0, labels, 0, length);
3624
	countLabels = 0;
3610
	countLabels = 0;
3611
	this.lastAbruptCompletion = -1;
3625
3612
3626
	stackMax = 0;
3613
	stackMax = 0;
3627
	stackDepth = 0;
3614
	stackDepth = 0;
Lines 4493-4498 Link Here
4493
	}
4480
	}
4494
	position++;
4481
	position++;
4495
	bCodeStream[classFileOffset++] = Opcodes.OPC_ireturn;
4482
	bCodeStream[classFileOffset++] = Opcodes.OPC_ireturn;
4483
	this.lastAbruptCompletion = this.position;		
4496
}
4484
}
4497
public boolean isDefinitelyAssigned(Scope scope, int initStateIndex, LocalVariableBinding local) {
4485
public boolean isDefinitelyAssigned(Scope scope, int initStateIndex, LocalVariableBinding local) {
4498
	// Mirror of UnconditionalFlowInfo.isDefinitelyAssigned(..)
4486
	// Mirror of UnconditionalFlowInfo.isDefinitelyAssigned(..)
Lines 5278-5283 Link Here
5278
	}
5266
	}
5279
	position++;
5267
	position++;
5280
	bCodeStream[classFileOffset++] = Opcodes.OPC_lreturn;
5268
	bCodeStream[classFileOffset++] = Opcodes.OPC_lreturn;
5269
	this.lastAbruptCompletion = this.position;		
5281
}
5270
}
5282
public void lshl() {
5271
public void lshl() {
5283
	if (DEBUG) System.out.println(position + "\t\tlshl"); //$NON-NLS-1$
5272
	if (DEBUG) System.out.println(position + "\t\tlshl"); //$NON-NLS-1$
Lines 5898-5903 Link Here
5898
	}
5887
	}
5899
	position++;
5888
	position++;
5900
	bCodeStream[classFileOffset++] = Opcodes.OPC_return;
5889
	bCodeStream[classFileOffset++] = Opcodes.OPC_return;
5890
	this.lastAbruptCompletion = this.position;	
5901
}
5891
}
5902
public void saload() {
5892
public void saload() {
5903
	if (DEBUG) System.out.println(position + "\t\tsaload"); //$NON-NLS-1$
5893
	if (DEBUG) System.out.println(position + "\t\tsaload"); //$NON-NLS-1$
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java (-42 / +21 lines)
Lines 907-969 Link Here
907
	super.imul();
907
	super.imul();
908
	this.currentFrame.numberOfStackItems--;
908
	this.currentFrame.numberOfStackItems--;
909
}
909
}
910
/*
910
public boolean inlineForwardReferencesFromLabelsTargeting(BranchLabel label, int gotoLocation) {
911
 * Some placed labels might be branching to a goto bytecode which we can optimize better.
912
 */
913
public void inlineForwardReferencesFromLabelsTargeting(BranchLabel label, int gotoLocation) {
914
	
911
	
915
/*
912
	final int NONE = 0, CASE = 1, STANDARD = 2;
916
 Code required to optimized unreachable gotos.
913
	int chaining = NONE;
917
	public boolean isBranchTarget(int location) {
914
918
		Label[] labels = codeStream.labels;
919
		for (int i = codeStream.countLabels - 1; i >= 0; i--){
920
			Label label = labels[i];
921
			if ((label.position == location) && label.isStandardLabel()){
922
				return true;
923
			}
924
		}
925
		return false;
926
	}
927
 */
928
	boolean hasStandardLabel = false;
929
	boolean removeFrame = true;
915
	boolean removeFrame = true;
930
	for (int i = this.countLabels - 1; i >= 0; i--) {
916
	for (int i = this.countLabels - 1; i >= 0; i--) {
931
		BranchLabel currentLabel = labels[i];
917
		BranchLabel currentLabel = labels[i];
932
		if (currentLabel.position == gotoLocation) {
918
		if (currentLabel.position != gotoLocation) break;
933
			if (currentLabel.isStandardLabel()) {
919
		if (currentLabel.isStandardLabel()) {
934
				hasStandardLabel = true;
920
			chaining |= STANDARD;
935
				if (currentLabel.forwardReferenceCount == 0 && ((currentLabel.tagBits & BranchLabel.USED) != 0)) {
921
			if (currentLabel.forwardReferenceCount == 0 && ((currentLabel.tagBits & BranchLabel.USED) != 0)) {
936
					removeFrame = false;
937
				}
938
			} else if (currentLabel.isCaseLabel()) {
939
				removeFrame = false;
922
				removeFrame = false;
940
			}
923
			}
941
		} else {
924
		} else { // case label
942
			break; // same target labels should be contiguous
925
			removeFrame = false;
926
			chaining |= CASE;
943
		}
927
		}
944
	}
928
	}
945
	if (hasStandardLabel) {
929
	if ((chaining & STANDARD) != 0) {
946
		for (int i = this.countLabels - 1; i >= 0; i--) {
930
		for (int i = this.countLabels - 1; i >= 0; i--) {
947
			BranchLabel currentLabel = labels[i];
931
			BranchLabel currentLabel = labels[i];
948
			if (currentLabel.position == gotoLocation) {
932
			if (currentLabel.position != gotoLocation) break;
949
				if (currentLabel.isStandardLabel()){
933
			if (currentLabel.isStandardLabel()) {
950
					label.appendForwardReferencesFrom(currentLabel);
934
				label.appendForwardReferencesFrom(currentLabel);
951
					// we should remove the frame corresponding to otherLabel position in order to prevent unused stack frame
935
				// we should remove the frame corresponding to otherLabel position in order to prevent unused stack frame
952
					if (removeFrame) {
936
				if (removeFrame) {
953
						currentLabel.tagBits &= ~BranchLabel.USED;
937
					currentLabel.tagBits &= ~BranchLabel.USED;
954
						this.removeStackFrameFor(gotoLocation);
938
					this.removeStackFrameFor(gotoLocation);
955
					}
956
				}
939
				}
957
				/*
958
				 Code required to optimized unreachable gotos.
959
					label.position = POS_NOT_SET;
960
				*/
961
			} else {
962
				break; // same target labels should be contiguous
963
			}
940
			}
964
		}
941
		}
965
	}
942
	}
943
	return (chaining & (STANDARD|CASE)) == STANDARD; // check was some standards, and no case	
966
}
944
}
945
967
public void init(ClassFile targetClassFile) {
946
public void init(ClassFile targetClassFile) {
968
	super.init(targetClassFile);
947
	super.init(targetClassFile);
969
	this.framesCounter = 0;
948
	this.framesCounter = 0;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java (-1 / +3 lines)
Lines 176-182 Link Here
176
						elseInitStateIndex);
176
						elseInitStateIndex);
177
					codeStream.addDefinitelyAssignedVariables(currentScope, elseInitStateIndex);
177
					codeStream.addDefinitelyAssignedVariables(currentScope, elseInitStateIndex);
178
				}
178
				}
179
				if (falseLabel != null) falseLabel.place();
179
				if (falseLabel != null) {
180
					falseLabel.place();
181
				}
180
				this.elseStatement.generateCode(currentScope, codeStream);
182
				this.elseStatement.generateCode(currentScope, codeStream);
181
			}
183
			}
182
		} else if (hasElsePart) {
184
		} else if (hasElsePart) {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java (-15 / +1185 lines)
Lines 16-21 Link Here
16
16
17
import org.eclipse.jdt.core.ToolFactory;
17
import org.eclipse.jdt.core.ToolFactory;
18
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
18
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
19
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
20
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
20
import org.eclipse.jdt.core.tests.util.Util;
21
import org.eclipse.jdt.core.tests.util.Util;
21
22
Lines 1405-1410 Link Here
1405
			},
1406
			},
1406
			"");
1407
			"");
1407
	String expectedOutput =
1408
	String expectedOutput =
1409
		"  // Method descriptor #15 (Ljava/lang/String;Ljava/lang/String;[LX$IContributionItem;)V\n" + 
1410
		"  // Stack: 3, Locals: 8\n" + 
1408
		"  public static void findInsertionPoint(java.lang.String startId, java.lang.String sortId, X.IContributionItem[] items);\n" + 
1411
		"  public static void findInsertionPoint(java.lang.String startId, java.lang.String sortId, X.IContributionItem[] items);\n" + 
1409
		"      0  iconst_0\n" + 
1412
		"      0  iconst_0\n" + 
1410
		"      1  istore_3 [insertIndex]\n" + 
1413
		"      1  istore_3 [insertIndex]\n" + 
Lines 1433-1453 Link Here
1433
		"     43  iconst_1\n" + 
1436
		"     43  iconst_1\n" + 
1434
		"     44  iadd\n" + 
1437
		"     44  iadd\n" + 
1435
		"     45  istore 5 [nX]\n" + 
1438
		"     45  istore 5 [nX]\n" + 
1436
		"     47  goto 129\n" + 
1439
		"     47  goto 123\n" + 
1437
		"     50  aload_2 [items]\n" + 
1440
		"     50  aload_2 [items]\n" + 
1438
		"     51  iload 5 [nX]\n" + 
1441
		"     51  iload 5 [nX]\n" + 
1439
		"     53  aaload\n" + 
1442
		"     53  aaload\n" + 
1440
		"     54  astore 6 [item]\n" + 
1443
		"     54  astore 6 [item]\n" + 
1441
		"     56  aload 6 [item]\n" + 
1444
		"     56  aload 6 [item]\n" + 
1442
		"     58  invokeinterface X$IContributionItem.isSeparator() : boolean [28] [nargs: 1]\n" + 
1445
		"     58  invokeinterface X$IContributionItem.isSeparator() : boolean [28] [nargs: 1]\n" + 
1443
		"     63  ifne 140\n" + 
1446
		"     63  ifne 134\n" + 
1444
		"     66  aload 6 [item]\n" + 
1447
		"     66  aload 6 [item]\n" + 
1445
		"     68  invokeinterface X$IContributionItem.isGroupMarker() : boolean [32] [nargs: 1]\n" + 
1448
		"     68  invokeinterface X$IContributionItem.isGroupMarker() : boolean [32] [nargs: 1]\n" + 
1446
		"     73  ifeq 79\n" + 
1449
		"     73  ifeq 79\n" + 
1447
		"     76  goto 140\n" + 
1450
		"     76  goto 134\n" + 
1448
		"     79  aload 6 [item]\n" + 
1451
		"     79  aload 6 [item]\n" + 
1449
		"     81  instanceof X$IActionSetContributionItem [35]\n" + 
1452
		"     81  instanceof X$IActionSetContributionItem [35]\n" + 
1450
		"     84  ifeq 140\n" + 
1453
		"     84  ifeq 134\n" + 
1451
		"     87  aload_1 [sortId]\n" + 
1454
		"     87  aload_1 [sortId]\n" + 
1452
		"     88  ifnull 117\n" + 
1455
		"     88  ifnull 117\n" + 
1453
		"     91  aload 6 [item]\n" + 
1456
		"     91  aload 6 [item]\n" + 
Lines 1459-1477 Link Here
1459
		"    106  invokevirtual java.lang.String.compareTo(java.lang.String) : int [40]\n" + 
1462
		"    106  invokevirtual java.lang.String.compareTo(java.lang.String) : int [40]\n" + 
1460
		"    109  iload 4 [compareMetric]\n" + 
1463
		"    109  iload 4 [compareMetric]\n" + 
1461
		"    111  if_icmpge 117\n" + 
1464
		"    111  if_icmpge 117\n" + 
1462
		"    114  goto 140\n" + 
1465
		"    114  goto 134\n" + 
1463
		"    117  iload 5 [nX]\n" + 
1466
		"    117  iload 5 [nX]\n" + 
1464
		"    119  istore_3 [insertIndex]\n" + 
1467
		"    119  istore_3 [insertIndex]\n" + 
1465
		"    120  goto 126\n" + 
1468
		"    120  iinc 5 1 [nX]\n" + 
1466
		"    123  goto 140\n" + 
1469
		"    123  iload 5 [nX]\n" + 
1467
		"    126  iinc 5 1 [nX]\n" + 
1470
		"    125  aload_2 [items]\n" + 
1468
		"    129  iload 5 [nX]\n" + 
1471
		"    126  arraylength\n" + 
1469
		"    131  aload_2 [items]\n" + 
1472
		"    127  if_icmplt 50\n" + 
1470
		"    132  arraylength\n" + 
1473
		"    130  goto 134\n" + 
1471
		"    133  if_icmplt 50\n" + 
1474
		"    133  astore_3\n" + 
1472
		"    136  goto 140\n" + 
1475
		"    134  return\n" + 
1473
		"    139  astore_3\n" + 
1476
		"      Exception Table:\n" + 
1474
		"    140  return\n";
1477
		"        [pc: 0, pc: 38] -> 133 when : java.lang.Exception\n" + 
1478
		"        [pc: 39, pc: 133] -> 133 when : java.lang.Exception\n" + 
1479
		"      Line numbers:\n" + 
1480
		"        [pc: 0, line: 16]\n" + 
1481
		"        [pc: 2, line: 17]\n" + 
1482
		"        [pc: 5, line: 18]\n" + 
1483
		"        [pc: 20, line: 19]\n" + 
1484
		"        [pc: 23, line: 20]\n" + 
1485
		"        [pc: 26, line: 17]\n" + 
1486
		"        [pc: 32, line: 22]\n" + 
1487
		"        [pc: 38, line: 23]\n" + 
1488
		"        [pc: 39, line: 25]\n" + 
1489
		"        [pc: 42, line: 30]\n" + 
1490
		"        [pc: 50, line: 31]\n" + 
1491
		"        [pc: 56, line: 32]\n" + 
1492
		"        [pc: 76, line: 34]\n" + 
1493
		"        [pc: 79, line: 36]\n" + 
1494
		"        [pc: 87, line: 37]\n" + 
1495
		"        [pc: 91, line: 38]\n" + 
1496
		"        [pc: 96, line: 39]\n" + 
1497
		"        [pc: 101, line: 38]\n" + 
1498
		"        [pc: 103, line: 40]\n" + 
1499
		"        [pc: 114, line: 41]\n" + 
1500
		"        [pc: 117, line: 43]\n" + 
1501
		"        [pc: 120, line: 30]\n" + 
1502
		"        [pc: 133, line: 48]\n" + 
1503
		"        [pc: 134, line: 49]\n" + 
1504
		"      Local variable table:\n" + 
1505
		"        [pc: 0, pc: 135] local: startId index: 0 type: java.lang.String\n" + 
1506
		"        [pc: 0, pc: 135] local: sortId index: 1 type: java.lang.String\n" + 
1507
		"        [pc: 0, pc: 135] local: items index: 2 type: X.IContributionItem[]\n" + 
1508
		"        [pc: 2, pc: 133] local: insertIndex index: 3 type: int\n" + 
1509
		"        [pc: 42, pc: 133] local: compareMetric index: 4 type: int\n" + 
1510
		"        [pc: 47, pc: 130] local: nX index: 5 type: int\n" + 
1511
		"        [pc: 56, pc: 120] local: item index: 6 type: X.IContributionItem\n" + 
1512
		"        [pc: 103, pc: 117] local: testId index: 7 type: java.lang.String\n";
1475
	
1513
	
1476
	try {
1514
	try {
1477
		File f = new File(OUTPUT_DIR + File.separator + "X.class");
1515
		File f = new File(OUTPUT_DIR + File.separator + "X.class");
Lines 2970-2975 Link Here
2970
		assertTrue(false);
3008
		assertTrue(false);
2971
	}	
3009
	}	
2972
}
3010
}
3011
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114894
3012
public void test047() {
3013
	this.runConformTest(
3014
			new String[] {
3015
				"X.java",
3016
				"public class X {\n" + 
3017
				"	boolean bool() { return true; }\n" + 
3018
				"	void foo() {\n" + 
3019
				"		try {\n" + 
3020
				"			if (bool()) {\n" + 
3021
				"				return;\n" + 
3022
				"			}\n" + 
3023
				"		} catch (Exception e) {\n" + 
3024
				"		}\n" + 
3025
				"	}\n" + 
3026
				"	int foo2() {\n" + 
3027
				"		try {\n" + 
3028
				"			while (bool()) {\n" + 
3029
				"				return 0;\n" + 
3030
				"			}\n" + 
3031
				"		} catch (Exception e) {\n" + 
3032
				"		}\n" + 
3033
				"		return 1;\n" +
3034
				"	}\n" + 
3035
				"	long foo3() {\n" + 
3036
				"		try {\n" + 
3037
				"			do {\n" + 
3038
				"				if (true) return 0L;\n" + 
3039
				"			} while (bool());\n" + 
3040
				"		} catch (Exception e) {\n" + 
3041
				"		}\n" + 
3042
				"		return 1L;\n" +
3043
				"	}	\n" + 
3044
				"	float foo4() {\n" + 
3045
				"		try {\n" + 
3046
				"			for (int i  = 0; bool(); i++) {\n" + 
3047
				"				return 0.0F;\n" + 
3048
				"			}\n" + 
3049
				"		} catch (Exception e) {\n" + 
3050
				"		}\n" + 
3051
				"		return 1.0F;\n" +
3052
				"	}		\n" + 
3053
				"	double bar() {\n" + 
3054
				"		if (bool()) {\n" + 
3055
				"			if (bool())\n" + 
3056
				"				return 0.0;\n" + 
3057
				"		} else {\n" + 
3058
				"			if (bool()) {\n" + 
3059
				"				throw new NullPointerException();\n" + 
3060
				"			}\n" + 
3061
				"		}\n" + 
3062
				"		return 1.0;\n" +
3063
				"	}\n" + 
3064
				"	void baz(int i) {\n" + 
3065
				"		if (bool()) {\n" + 
3066
				"			switch(i) {\n" + 
3067
				"				case 0 : return;\n" + 
3068
				"				default : break;\n" + 
3069
				"			}\n" + 
3070
				"		} else {\n" + 
3071
				"			bool();\n" + 
3072
				"		}\n" + 
3073
				"	}\n" + 
3074
				"}\n",
3075
			},
3076
			"");
3077
	
3078
	String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6
3079
		?	"  // Method descriptor #6 ()V\n" + 
3080
			"  // Stack: 1, Locals: 2\n" + 
3081
			"  void foo();\n" + 
3082
			"     0  aload_0 [this]\n" + 
3083
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3084
			"     4  ifeq 9\n" + 
3085
			"     7  return\n" + 
3086
			"     8  astore_1\n" + 
3087
			"     9  return\n" + 
3088
			"      Exception Table:\n" + 
3089
			"        [pc: 0, pc: 7] -> 8 when : java.lang.Exception\n" + 
3090
			"      Line numbers:\n" + 
3091
			"        [pc: 0, line: 5]\n" + 
3092
			"        [pc: 7, line: 6]\n" + 
3093
			"        [pc: 8, line: 8]\n" + 
3094
			"        [pc: 9, line: 10]\n" + 
3095
			"      Local variable table:\n" + 
3096
			"        [pc: 0, pc: 10] local: this index: 0 type: X\n" + 
3097
			"  \n" + 
3098
			"  // Method descriptor #22 ()I\n" + 
3099
			"  // Stack: 1, Locals: 2\n" + 
3100
			"  int foo2();\n" + 
3101
			"     0  aload_0 [this]\n" + 
3102
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3103
			"     4  ifeq 10\n" + 
3104
			"     7  iconst_0\n" + 
3105
			"     8  ireturn\n" + 
3106
			"     9  astore_1\n" + 
3107
			"    10  iconst_1\n" + 
3108
			"    11  ireturn\n" + 
3109
			"      Exception Table:\n" + 
3110
			"        [pc: 0, pc: 7] -> 9 when : java.lang.Exception\n" + 
3111
			"      Line numbers:\n" + 
3112
			"        [pc: 0, line: 13]\n" + 
3113
			"        [pc: 7, line: 14]\n" + 
3114
			"        [pc: 9, line: 16]\n" + 
3115
			"        [pc: 10, line: 18]\n" + 
3116
			"      Local variable table:\n" + 
3117
			"        [pc: 0, pc: 12] local: this index: 0 type: X\n" + 
3118
			"  \n" + 
3119
			"  // Method descriptor #24 ()J\n" + 
3120
			"  // Stack: 2, Locals: 2\n" + 
3121
			"  long foo3();\n" + 
3122
			"    0  lconst_0\n" + 
3123
			"    1  lreturn\n" + 
3124
			"    2  astore_1\n" + 
3125
			"    3  lconst_1\n" + 
3126
			"    4  lreturn\n" + 
3127
			"      Line numbers:\n" + 
3128
			"        [pc: 0, line: 23]\n" + 
3129
			"        [pc: 2, line: 25]\n" + 
3130
			"        [pc: 3, line: 27]\n" + 
3131
			"      Local variable table:\n" + 
3132
			"        [pc: 0, pc: 5] local: this index: 0 type: X\n" + 
3133
			"  \n" + 
3134
			"  // Method descriptor #26 ()F\n" + 
3135
			"  // Stack: 1, Locals: 2\n" + 
3136
			"  float foo4();\n" + 
3137
			"     0  iconst_0\n" + 
3138
			"     1  istore_1 [i]\n" + 
3139
			"     2  goto 7\n" + 
3140
			"     5  fconst_0\n" + 
3141
			"     6  freturn\n" + 
3142
			"     7  aload_0 [this]\n" + 
3143
			"     8  invokevirtual X.bool() : boolean [17]\n" + 
3144
			"    11  ifne 5\n" + 
3145
			"    14  goto 18\n" + 
3146
			"    17  astore_1\n" + 
3147
			"    18  fconst_1\n" + 
3148
			"    19  freturn\n" + 
3149
			"      Exception Table:\n" + 
3150
			"        [pc: 0, pc: 5] -> 17 when : java.lang.Exception\n" + 
3151
			"        [pc: 7, pc: 17] -> 17 when : java.lang.Exception\n" + 
3152
			"      Line numbers:\n" + 
3153
			"        [pc: 0, line: 31]\n" + 
3154
			"        [pc: 5, line: 32]\n" + 
3155
			"        [pc: 7, line: 31]\n" + 
3156
			"        [pc: 17, line: 34]\n" + 
3157
			"        [pc: 18, line: 36]\n" + 
3158
			"      Local variable table:\n" + 
3159
			"        [pc: 0, pc: 20] local: this index: 0 type: X\n" + 
3160
			"        [pc: 2, pc: 14] local: i index: 1 type: int\n" + 
3161
			"  \n" + 
3162
			"  // Method descriptor #30 ()D\n" + 
3163
			"  // Stack: 2, Locals: 1\n" + 
3164
			"  double bar();\n" + 
3165
			"     0  aload_0 [this]\n" + 
3166
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3167
			"     4  ifeq 16\n" + 
3168
			"     7  aload_0 [this]\n" + 
3169
			"     8  invokevirtual X.bool() : boolean [17]\n" + 
3170
			"    11  ifeq 31\n" + 
3171
			"    14  dconst_0\n" + 
3172
			"    15  dreturn\n" + 
3173
			"    16  aload_0 [this]\n" + 
3174
			"    17  invokevirtual X.bool() : boolean [17]\n" + 
3175
			"    20  ifeq 31\n" + 
3176
			"    23  new java.lang.NullPointerException [31]\n" + 
3177
			"    26  dup\n" + 
3178
			"    27  invokespecial java.lang.NullPointerException() [33]\n" + 
3179
			"    30  athrow\n" + 
3180
			"    31  dconst_1\n" + 
3181
			"    32  dreturn\n" + 
3182
			"      Line numbers:\n" + 
3183
			"        [pc: 0, line: 39]\n" + 
3184
			"        [pc: 7, line: 40]\n" + 
3185
			"        [pc: 14, line: 41]\n" + 
3186
			"        [pc: 16, line: 43]\n" + 
3187
			"        [pc: 23, line: 44]\n" + 
3188
			"        [pc: 31, line: 47]\n" + 
3189
			"      Local variable table:\n" + 
3190
			"        [pc: 0, pc: 33] local: this index: 0 type: X\n" + 
3191
			"  \n" + 
3192
			"  // Method descriptor #35 (I)V\n" + 
3193
			"  // Stack: 1, Locals: 2\n" + 
3194
			"  void baz(int i);\n" + 
3195
			"     0  aload_0 [this]\n" + 
3196
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3197
			"     4  ifeq 32\n" + 
3198
			"     7  iload_1 [i]\n" + 
3199
			"     8  tableswitch default: 29\n" + 
3200
			"          case 0: 28\n" + 
3201
			"    28  return\n" + 
3202
			"    29  goto 37\n" + 
3203
			"    32  aload_0 [this]\n" + 
3204
			"    33  invokevirtual X.bool() : boolean [17]\n" + 
3205
			"    36  pop\n" + 
3206
			"    37  return\n" + 
3207
			"      Line numbers:\n" + 
3208
			"        [pc: 0, line: 50]\n" + 
3209
			"        [pc: 7, line: 51]\n" + 
3210
			"        [pc: 28, line: 52]\n" + 
3211
			"        [pc: 32, line: 56]\n" + 
3212
			"        [pc: 37, line: 58]\n" + 
3213
			"      Local variable table:\n" + 
3214
			"        [pc: 0, pc: 38] local: this index: 0 type: X\n" + 
3215
			"        [pc: 0, pc: 38] local: i index: 1 type: int\n"
3216
		:
3217
			"  // Method descriptor #6 ()V\n" + 
3218
			"  // Stack: 1, Locals: 2\n" + 
3219
			"  void foo();\n" + 
3220
			"     0  aload_0 [this]\n" + 
3221
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3222
			"     4  ifeq 9\n" + 
3223
			"     7  return\n" + 
3224
			"     8  astore_1\n" + 
3225
			"     9  return\n" + 
3226
			"      Exception Table:\n" + 
3227
			"        [pc: 0, pc: 7] -> 8 when : java.lang.Exception\n" + 
3228
			"      Line numbers:\n" + 
3229
			"        [pc: 0, line: 5]\n" + 
3230
			"        [pc: 7, line: 6]\n" + 
3231
			"        [pc: 8, line: 8]\n" + 
3232
			"        [pc: 9, line: 10]\n" + 
3233
			"      Local variable table:\n" + 
3234
			"        [pc: 0, pc: 10] local: this index: 0 type: X\n" + 
3235
			"      Stack map table: number of frames 2\n" + 
3236
			"        [pc: 8, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + 
3237
			"        [pc: 9, same]\n" + 
3238
			"  \n" + 
3239
			"  // Method descriptor #23 ()I\n" + 
3240
			"  // Stack: 1, Locals: 2\n" + 
3241
			"  int foo2();\n" + 
3242
			"     0  aload_0 [this]\n" + 
3243
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3244
			"     4  ifeq 10\n" + 
3245
			"     7  iconst_0\n" + 
3246
			"     8  ireturn\n" + 
3247
			"     9  astore_1\n" + 
3248
			"    10  iconst_1\n" + 
3249
			"    11  ireturn\n" + 
3250
			"      Exception Table:\n" + 
3251
			"        [pc: 0, pc: 7] -> 9 when : java.lang.Exception\n" + 
3252
			"      Line numbers:\n" + 
3253
			"        [pc: 0, line: 13]\n" + 
3254
			"        [pc: 7, line: 14]\n" + 
3255
			"        [pc: 9, line: 16]\n" + 
3256
			"        [pc: 10, line: 18]\n" + 
3257
			"      Local variable table:\n" + 
3258
			"        [pc: 0, pc: 12] local: this index: 0 type: X\n" + 
3259
			"      Stack map table: number of frames 3\n" + 
3260
			"        [pc: 7, same]\n" + 
3261
			"        [pc: 9, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + 
3262
			"        [pc: 10, same]\n" + 
3263
			"  \n" + 
3264
			"  // Method descriptor #25 ()J\n" + 
3265
			"  // Stack: 2, Locals: 2\n" + 
3266
			"  long foo3();\n" + 
3267
			"    0  lconst_0\n" + 
3268
			"    1  lreturn\n" + 
3269
			"    2  astore_1\n" + 
3270
			"    3  lconst_1\n" + 
3271
			"    4  lreturn\n" + 
3272
			"      Line numbers:\n" + 
3273
			"        [pc: 0, line: 23]\n" + 
3274
			"        [pc: 2, line: 25]\n" + 
3275
			"        [pc: 3, line: 27]\n" + 
3276
			"      Local variable table:\n" + 
3277
			"        [pc: 0, pc: 5] local: this index: 0 type: X\n" + 
3278
			"      Stack map table: number of frames 2\n" + 
3279
			"        [pc: 0, same]\n" + 
3280
			"        [pc: 2, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + 
3281
			"  \n" + 
3282
			"  // Method descriptor #27 ()F\n" + 
3283
			"  // Stack: 1, Locals: 2\n" + 
3284
			"  float foo4();\n" + 
3285
			"     0  iconst_0\n" + 
3286
			"     1  istore_1 [i]\n" + 
3287
			"     2  goto 7\n" + 
3288
			"     5  fconst_0\n" + 
3289
			"     6  freturn\n" + 
3290
			"     7  aload_0 [this]\n" + 
3291
			"     8  invokevirtual X.bool() : boolean [17]\n" + 
3292
			"    11  ifne 5\n" + 
3293
			"    14  goto 18\n" + 
3294
			"    17  astore_1\n" + 
3295
			"    18  fconst_1\n" + 
3296
			"    19  freturn\n" + 
3297
			"      Exception Table:\n" + 
3298
			"        [pc: 0, pc: 5] -> 17 when : java.lang.Exception\n" + 
3299
			"        [pc: 7, pc: 17] -> 17 when : java.lang.Exception\n" + 
3300
			"      Line numbers:\n" + 
3301
			"        [pc: 0, line: 31]\n" + 
3302
			"        [pc: 5, line: 32]\n" + 
3303
			"        [pc: 7, line: 31]\n" + 
3304
			"        [pc: 17, line: 34]\n" + 
3305
			"        [pc: 18, line: 36]\n" + 
3306
			"      Local variable table:\n" + 
3307
			"        [pc: 0, pc: 20] local: this index: 0 type: X\n" + 
3308
			"        [pc: 2, pc: 14] local: i index: 1 type: int\n" + 
3309
			"      Stack map table: number of frames 4\n" + 
3310
			"        [pc: 5, append: {int}]\n" + 
3311
			"        [pc: 7, same]\n" + 
3312
			"        [pc: 17, full, stack: {java.lang.Exception}, locals: {X}]\n" + 
3313
			"        [pc: 18, same]\n" + 
3314
			"  \n" + 
3315
			"  // Method descriptor #31 ()D\n" + 
3316
			"  // Stack: 2, Locals: 1\n" + 
3317
			"  double bar();\n" + 
3318
			"     0  aload_0 [this]\n" + 
3319
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3320
			"     4  ifeq 16\n" + 
3321
			"     7  aload_0 [this]\n" + 
3322
			"     8  invokevirtual X.bool() : boolean [17]\n" + 
3323
			"    11  ifeq 31\n" + 
3324
			"    14  dconst_0\n" + 
3325
			"    15  dreturn\n" + 
3326
			"    16  aload_0 [this]\n" + 
3327
			"    17  invokevirtual X.bool() : boolean [17]\n" + 
3328
			"    20  ifeq 31\n" + 
3329
			"    23  new java.lang.NullPointerException [32]\n" + 
3330
			"    26  dup\n" + 
3331
			"    27  invokespecial java.lang.NullPointerException() [34]\n" + 
3332
			"    30  athrow\n" + 
3333
			"    31  dconst_1\n" + 
3334
			"    32  dreturn\n" + 
3335
			"      Line numbers:\n" + 
3336
			"        [pc: 0, line: 39]\n" + 
3337
			"        [pc: 7, line: 40]\n" + 
3338
			"        [pc: 14, line: 41]\n" + 
3339
			"        [pc: 16, line: 43]\n" + 
3340
			"        [pc: 23, line: 44]\n" + 
3341
			"        [pc: 31, line: 47]\n" + 
3342
			"      Local variable table:\n" + 
3343
			"        [pc: 0, pc: 33] local: this index: 0 type: X\n" + 
3344
			"      Stack map table: number of frames 2\n" + 
3345
			"        [pc: 16, same]\n" + 
3346
			"        [pc: 31, same]\n" + 
3347
			"  \n" + 
3348
			"  // Method descriptor #36 (I)V\n" + 
3349
			"  // Stack: 1, Locals: 2\n" + 
3350
			"  void baz(int i);\n" + 
3351
			"     0  aload_0 [this]\n" + 
3352
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3353
			"     4  ifeq 32\n" + 
3354
			"     7  iload_1 [i]\n" + 
3355
			"     8  tableswitch default: 29\n" + 
3356
			"          case 0: 28\n" + 
3357
			"    28  return\n" + 
3358
			"    29  goto 37\n" + 
3359
			"    32  aload_0 [this]\n" + 
3360
			"    33  invokevirtual X.bool() : boolean [17]\n" + 
3361
			"    36  pop\n" + 
3362
			"    37  return\n" + 
3363
			"      Line numbers:\n" + 
3364
			"        [pc: 0, line: 50]\n" + 
3365
			"        [pc: 7, line: 51]\n" + 
3366
			"        [pc: 28, line: 52]\n" + 
3367
			"        [pc: 32, line: 56]\n" + 
3368
			"        [pc: 37, line: 58]\n" + 
3369
			"      Local variable table:\n" + 
3370
			"        [pc: 0, pc: 38] local: this index: 0 type: X\n" + 
3371
			"        [pc: 0, pc: 38] local: i index: 1 type: int\n" + 
3372
			"      Stack map table: number of frames 4\n" + 
3373
			"        [pc: 28, same]\n" + 
3374
			"        [pc: 29, same]\n" + 
3375
			"        [pc: 32, same]\n" + 
3376
			"        [pc: 37, same]\n";
3377
	try {
3378
		File f = new File(OUTPUT_DIR + File.separator + "X.class");
3379
		byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
3380
		ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
3381
		String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
3382
		int index = result.indexOf(expectedOutput);
3383
		if (index == -1 || expectedOutput.length() == 0) {
3384
			System.out.println(Util.displayString(result, 3));
3385
		}
3386
		if (index == -1) {
3387
			assertEquals("Wrong contents", expectedOutput, result);
3388
		}
3389
	} catch (org.eclipse.jdt.core.util.ClassFormatException e) {
3390
		assertTrue(false);
3391
	} catch (IOException e) {
3392
		assertTrue(false);
3393
	}	
3394
}
3395
3396
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114894 - variation
3397
public void test048() {
3398
	this.runConformTest(
3399
			new String[] {
3400
				"X.java",
3401
				"public class X {\n" + 
3402
				"	boolean bool() { return true; }\n" + 
3403
				"	void foo() {\n" + 
3404
				"		try {\n" + 
3405
				"			if (bool()) {\n" + 
3406
				"				throw new NullPointerException();\n" + 
3407
				"			}\n" + 
3408
				"		} catch (Exception e) {\n" + 
3409
				"		}\n" + 
3410
				"	}\n" + 
3411
				"	void foo2() {\n" + 
3412
				"		try {\n" + 
3413
				"			while (bool()) {\n" + 
3414
				"				throw new NullPointerException();\n" + 
3415
				"			}\n" + 
3416
				"		} catch (Exception e) {\n" + 
3417
				"		}\n" + 
3418
				"	}\n" + 
3419
				"	void foo3() {\n" + 
3420
				"		try {\n" + 
3421
				"			do {\n" + 
3422
				"				if (true) throw new NullPointerException();\n" + 
3423
				"			} while (bool());\n" + 
3424
				"		} catch (Exception e) {\n" + 
3425
				"		}\n" + 
3426
				"	}	\n" + 
3427
				"	void foo4() {\n" + 
3428
				"		try {\n" + 
3429
				"			for (int i  = 0; bool(); i++) {\n" + 
3430
				"				throw new NullPointerException();\n" + 
3431
				"			}\n" + 
3432
				"		} catch (Exception e) {\n" + 
3433
				"		}\n" + 
3434
				"	}		\n" + 
3435
				"	void bar() {\n" + 
3436
				"		if (bool()) {\n" + 
3437
				"			if (bool())\n" + 
3438
				"				throw new NullPointerException();\n" + 
3439
				"		} else {\n" + 
3440
				"			if (bool()) {\n" + 
3441
				"				throw new NullPointerException();\n" + 
3442
				"			}\n" + 
3443
				"		}\n" + 
3444
				"	}\n" + 
3445
				"	void baz(int i) {\n" + 
3446
				"		if (bool()) {\n" + 
3447
				"			switch(i) {\n" + 
3448
				"				case 0 : throw new NullPointerException();\n" + 
3449
				"				default : break;\n" + 
3450
				"			}\n" + 
3451
				"		} else {\n" + 
3452
				"			bool();\n" + 
3453
				"		}\n" + 
3454
				"	}\n" + 
3455
				"}\n",
3456
			},
3457
			"");
3458
	
3459
	String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6
3460
		?	"  // Method descriptor #6 ()V\n" + 
3461
			"  // Stack: 2, Locals: 2\n" + 
3462
			"  void foo();\n" + 
3463
			"     0  aload_0 [this]\n" + 
3464
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3465
			"     4  ifeq 16\n" + 
3466
			"     7  new java.lang.NullPointerException [19]\n" + 
3467
			"    10  dup\n" + 
3468
			"    11  invokespecial java.lang.NullPointerException() [21]\n" + 
3469
			"    14  athrow\n" + 
3470
			"    15  astore_1\n" + 
3471
			"    16  return\n" + 
3472
			"      Exception Table:\n" + 
3473
			"        [pc: 0, pc: 15] -> 15 when : java.lang.Exception\n" + 
3474
			"      Line numbers:\n" + 
3475
			"        [pc: 0, line: 5]\n" + 
3476
			"        [pc: 7, line: 6]\n" + 
3477
			"        [pc: 15, line: 8]\n" + 
3478
			"        [pc: 16, line: 10]\n" + 
3479
			"      Local variable table:\n" + 
3480
			"        [pc: 0, pc: 17] local: this index: 0 type: X\n" + 
3481
			"  \n" + 
3482
			"  // Method descriptor #6 ()V\n" + 
3483
			"  // Stack: 2, Locals: 2\n" + 
3484
			"  void foo2();\n" + 
3485
			"     0  aload_0 [this]\n" + 
3486
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3487
			"     4  ifeq 16\n" + 
3488
			"     7  new java.lang.NullPointerException [19]\n" + 
3489
			"    10  dup\n" + 
3490
			"    11  invokespecial java.lang.NullPointerException() [21]\n" + 
3491
			"    14  athrow\n" + 
3492
			"    15  astore_1\n" + 
3493
			"    16  return\n" + 
3494
			"      Exception Table:\n" + 
3495
			"        [pc: 0, pc: 15] -> 15 when : java.lang.Exception\n" + 
3496
			"      Line numbers:\n" + 
3497
			"        [pc: 0, line: 13]\n" + 
3498
			"        [pc: 7, line: 14]\n" + 
3499
			"        [pc: 15, line: 16]\n" + 
3500
			"        [pc: 16, line: 18]\n" + 
3501
			"      Local variable table:\n" + 
3502
			"        [pc: 0, pc: 17] local: this index: 0 type: X\n" + 
3503
			"  \n" + 
3504
			"  // Method descriptor #6 ()V\n" + 
3505
			"  // Stack: 2, Locals: 2\n" + 
3506
			"  void foo3();\n" + 
3507
			"     0  new java.lang.NullPointerException [19]\n" + 
3508
			"     3  dup\n" + 
3509
			"     4  invokespecial java.lang.NullPointerException() [21]\n" + 
3510
			"     7  athrow\n" + 
3511
			"     8  astore_1\n" + 
3512
			"     9  return\n" + 
3513
			"      Exception Table:\n" + 
3514
			"        [pc: 0, pc: 8] -> 8 when : java.lang.Exception\n" + 
3515
			"      Line numbers:\n" + 
3516
			"        [pc: 0, line: 22]\n" + 
3517
			"        [pc: 8, line: 24]\n" + 
3518
			"        [pc: 9, line: 26]\n" + 
3519
			"      Local variable table:\n" + 
3520
			"        [pc: 0, pc: 10] local: this index: 0 type: X\n" + 
3521
			"  \n" + 
3522
			"  // Method descriptor #6 ()V\n" + 
3523
			"  // Stack: 2, Locals: 2\n" + 
3524
			"  void foo4();\n" + 
3525
			"     0  iconst_0\n" + 
3526
			"     1  istore_1 [i]\n" + 
3527
			"     2  goto 13\n" + 
3528
			"     5  new java.lang.NullPointerException [19]\n" + 
3529
			"     8  dup\n" + 
3530
			"     9  invokespecial java.lang.NullPointerException() [21]\n" + 
3531
			"    12  athrow\n" + 
3532
			"    13  aload_0 [this]\n" + 
3533
			"    14  invokevirtual X.bool() : boolean [17]\n" + 
3534
			"    17  ifne 5\n" + 
3535
			"    20  goto 24\n" + 
3536
			"    23  astore_1\n" + 
3537
			"    24  return\n" + 
3538
			"      Exception Table:\n" + 
3539
			"        [pc: 0, pc: 23] -> 23 when : java.lang.Exception\n" + 
3540
			"      Line numbers:\n" + 
3541
			"        [pc: 0, line: 29]\n" + 
3542
			"        [pc: 5, line: 30]\n" + 
3543
			"        [pc: 13, line: 29]\n" + 
3544
			"        [pc: 23, line: 32]\n" + 
3545
			"        [pc: 24, line: 34]\n" + 
3546
			"      Local variable table:\n" + 
3547
			"        [pc: 0, pc: 25] local: this index: 0 type: X\n" + 
3548
			"        [pc: 2, pc: 20] local: i index: 1 type: int\n" + 
3549
			"  \n" + 
3550
			"  // Method descriptor #6 ()V\n" + 
3551
			"  // Stack: 2, Locals: 1\n" + 
3552
			"  void bar();\n" + 
3553
			"     0  aload_0 [this]\n" + 
3554
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3555
			"     4  ifeq 22\n" + 
3556
			"     7  aload_0 [this]\n" + 
3557
			"     8  invokevirtual X.bool() : boolean [17]\n" + 
3558
			"    11  ifeq 37\n" + 
3559
			"    14  new java.lang.NullPointerException [19]\n" + 
3560
			"    17  dup\n" + 
3561
			"    18  invokespecial java.lang.NullPointerException() [21]\n" + 
3562
			"    21  athrow\n" + 
3563
			"    22  aload_0 [this]\n" + 
3564
			"    23  invokevirtual X.bool() : boolean [17]\n" + 
3565
			"    26  ifeq 37\n" + 
3566
			"    29  new java.lang.NullPointerException [19]\n" + 
3567
			"    32  dup\n" + 
3568
			"    33  invokespecial java.lang.NullPointerException() [21]\n" + 
3569
			"    36  athrow\n" + 
3570
			"    37  return\n" + 
3571
			"      Line numbers:\n" + 
3572
			"        [pc: 0, line: 36]\n" + 
3573
			"        [pc: 7, line: 37]\n" + 
3574
			"        [pc: 14, line: 38]\n" + 
3575
			"        [pc: 22, line: 40]\n" + 
3576
			"        [pc: 29, line: 41]\n" + 
3577
			"        [pc: 37, line: 44]\n" + 
3578
			"      Local variable table:\n" + 
3579
			"        [pc: 0, pc: 38] local: this index: 0 type: X\n" + 
3580
			"  \n" + 
3581
			"  // Method descriptor #31 (I)V\n" + 
3582
			"  // Stack: 2, Locals: 2\n" + 
3583
			"  void baz(int i);\n" + 
3584
			"     0  aload_0 [this]\n" + 
3585
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3586
			"     4  ifeq 39\n" + 
3587
			"     7  iload_1 [i]\n" + 
3588
			"     8  tableswitch default: 36\n" + 
3589
			"          case 0: 28\n" + 
3590
			"    28  new java.lang.NullPointerException [19]\n" + 
3591
			"    31  dup\n" + 
3592
			"    32  invokespecial java.lang.NullPointerException() [21]\n" + 
3593
			"    35  athrow\n" + 
3594
			"    36  goto 44\n" + 
3595
			"    39  aload_0 [this]\n" + 
3596
			"    40  invokevirtual X.bool() : boolean [17]\n" + 
3597
			"    43  pop\n" + 
3598
			"    44  return\n" + 
3599
			"      Line numbers:\n" + 
3600
			"        [pc: 0, line: 46]\n" + 
3601
			"        [pc: 7, line: 47]\n" + 
3602
			"        [pc: 28, line: 48]\n" + 
3603
			"        [pc: 39, line: 52]\n" + 
3604
			"        [pc: 44, line: 54]\n" + 
3605
			"      Local variable table:\n" + 
3606
			"        [pc: 0, pc: 45] local: this index: 0 type: X\n" + 
3607
			"        [pc: 0, pc: 45] local: i index: 1 type: int\n"
3608
		:
3609
			"  // Method descriptor #6 ()V\n" + 
3610
			"  // Stack: 2, Locals: 2\n" + 
3611
			"  void foo();\n" + 
3612
			"     0  aload_0 [this]\n" + 
3613
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3614
			"     4  ifeq 16\n" + 
3615
			"     7  new java.lang.NullPointerException [19]\n" + 
3616
			"    10  dup\n" + 
3617
			"    11  invokespecial java.lang.NullPointerException() [21]\n" + 
3618
			"    14  athrow\n" + 
3619
			"    15  astore_1\n" + 
3620
			"    16  return\n" + 
3621
			"      Exception Table:\n" + 
3622
			"        [pc: 0, pc: 15] -> 15 when : java.lang.Exception\n" + 
3623
			"      Line numbers:\n" + 
3624
			"        [pc: 0, line: 5]\n" + 
3625
			"        [pc: 7, line: 6]\n" + 
3626
			"        [pc: 15, line: 8]\n" + 
3627
			"        [pc: 16, line: 10]\n" + 
3628
			"      Local variable table:\n" + 
3629
			"        [pc: 0, pc: 17] local: this index: 0 type: X\n" + 
3630
			"      Stack map table: number of frames 2\n" + 
3631
			"        [pc: 15, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + 
3632
			"        [pc: 16, same]\n" + 
3633
			"  \n" + 
3634
			"  // Method descriptor #6 ()V\n" + 
3635
			"  // Stack: 2, Locals: 2\n" + 
3636
			"  void foo2();\n" + 
3637
			"     0  aload_0 [this]\n" + 
3638
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3639
			"     4  ifeq 16\n" + 
3640
			"     7  new java.lang.NullPointerException [19]\n" + 
3641
			"    10  dup\n" + 
3642
			"    11  invokespecial java.lang.NullPointerException() [21]\n" + 
3643
			"    14  athrow\n" + 
3644
			"    15  astore_1\n" + 
3645
			"    16  return\n" + 
3646
			"      Exception Table:\n" + 
3647
			"        [pc: 0, pc: 15] -> 15 when : java.lang.Exception\n" + 
3648
			"      Line numbers:\n" + 
3649
			"        [pc: 0, line: 13]\n" + 
3650
			"        [pc: 7, line: 14]\n" + 
3651
			"        [pc: 15, line: 16]\n" + 
3652
			"        [pc: 16, line: 18]\n" + 
3653
			"      Local variable table:\n" + 
3654
			"        [pc: 0, pc: 17] local: this index: 0 type: X\n" + 
3655
			"      Stack map table: number of frames 3\n" + 
3656
			"        [pc: 7, same]\n" + 
3657
			"        [pc: 15, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + 
3658
			"        [pc: 16, same]\n" + 
3659
			"  \n" + 
3660
			"  // Method descriptor #6 ()V\n" + 
3661
			"  // Stack: 2, Locals: 2\n" + 
3662
			"  void foo3();\n" + 
3663
			"     0  new java.lang.NullPointerException [19]\n" + 
3664
			"     3  dup\n" + 
3665
			"     4  invokespecial java.lang.NullPointerException() [21]\n" + 
3666
			"     7  athrow\n" + 
3667
			"     8  astore_1\n" + 
3668
			"     9  return\n" + 
3669
			"      Exception Table:\n" + 
3670
			"        [pc: 0, pc: 8] -> 8 when : java.lang.Exception\n" + 
3671
			"      Line numbers:\n" + 
3672
			"        [pc: 0, line: 22]\n" + 
3673
			"        [pc: 8, line: 24]\n" + 
3674
			"        [pc: 9, line: 26]\n" + 
3675
			"      Local variable table:\n" + 
3676
			"        [pc: 0, pc: 10] local: this index: 0 type: X\n" + 
3677
			"      Stack map table: number of frames 2\n" + 
3678
			"        [pc: 0, same]\n" + 
3679
			"        [pc: 8, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + 
3680
			"  \n" + 
3681
			"  // Method descriptor #6 ()V\n" + 
3682
			"  // Stack: 2, Locals: 2\n" + 
3683
			"  void foo4();\n" + 
3684
			"     0  iconst_0\n" + 
3685
			"     1  istore_1 [i]\n" + 
3686
			"     2  goto 13\n" + 
3687
			"     5  new java.lang.NullPointerException [19]\n" + 
3688
			"     8  dup\n" + 
3689
			"     9  invokespecial java.lang.NullPointerException() [21]\n" + 
3690
			"    12  athrow\n" + 
3691
			"    13  aload_0 [this]\n" + 
3692
			"    14  invokevirtual X.bool() : boolean [17]\n" + 
3693
			"    17  ifne 5\n" + 
3694
			"    20  goto 24\n" + 
3695
			"    23  astore_1\n" + 
3696
			"    24  return\n" + 
3697
			"      Exception Table:\n" + 
3698
			"        [pc: 0, pc: 23] -> 23 when : java.lang.Exception\n" + 
3699
			"      Line numbers:\n" + 
3700
			"        [pc: 0, line: 29]\n" + 
3701
			"        [pc: 5, line: 30]\n" + 
3702
			"        [pc: 13, line: 29]\n" + 
3703
			"        [pc: 23, line: 32]\n" + 
3704
			"        [pc: 24, line: 34]\n" + 
3705
			"      Local variable table:\n" + 
3706
			"        [pc: 0, pc: 25] local: this index: 0 type: X\n" + 
3707
			"        [pc: 2, pc: 20] local: i index: 1 type: int\n" + 
3708
			"      Stack map table: number of frames 4\n" + 
3709
			"        [pc: 5, append: {int}]\n" + 
3710
			"        [pc: 13, same]\n" + 
3711
			"        [pc: 23, full, stack: {java.lang.Exception}, locals: {X}]\n" + 
3712
			"        [pc: 24, same]\n" + 
3713
			"  \n" + 
3714
			"  // Method descriptor #6 ()V\n" + 
3715
			"  // Stack: 2, Locals: 1\n" + 
3716
			"  void bar();\n" + 
3717
			"     0  aload_0 [this]\n" + 
3718
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3719
			"     4  ifeq 22\n" + 
3720
			"     7  aload_0 [this]\n" + 
3721
			"     8  invokevirtual X.bool() : boolean [17]\n" + 
3722
			"    11  ifeq 37\n" + 
3723
			"    14  new java.lang.NullPointerException [19]\n" + 
3724
			"    17  dup\n" + 
3725
			"    18  invokespecial java.lang.NullPointerException() [21]\n" + 
3726
			"    21  athrow\n" + 
3727
			"    22  aload_0 [this]\n" + 
3728
			"    23  invokevirtual X.bool() : boolean [17]\n" + 
3729
			"    26  ifeq 37\n" + 
3730
			"    29  new java.lang.NullPointerException [19]\n" + 
3731
			"    32  dup\n" + 
3732
			"    33  invokespecial java.lang.NullPointerException() [21]\n" + 
3733
			"    36  athrow\n" + 
3734
			"    37  return\n" + 
3735
			"      Line numbers:\n" + 
3736
			"        [pc: 0, line: 36]\n" + 
3737
			"        [pc: 7, line: 37]\n" + 
3738
			"        [pc: 14, line: 38]\n" + 
3739
			"        [pc: 22, line: 40]\n" + 
3740
			"        [pc: 29, line: 41]\n" + 
3741
			"        [pc: 37, line: 44]\n" + 
3742
			"      Local variable table:\n" + 
3743
			"        [pc: 0, pc: 38] local: this index: 0 type: X\n" + 
3744
			"      Stack map table: number of frames 2\n" + 
3745
			"        [pc: 22, same]\n" + 
3746
			"        [pc: 37, same]\n" + 
3747
			"  \n" + 
3748
			"  // Method descriptor #32 (I)V\n" + 
3749
			"  // Stack: 2, Locals: 2\n" + 
3750
			"  void baz(int i);\n" + 
3751
			"     0  aload_0 [this]\n" + 
3752
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3753
			"     4  ifeq 39\n" + 
3754
			"     7  iload_1 [i]\n" + 
3755
			"     8  tableswitch default: 36\n" + 
3756
			"          case 0: 28\n" + 
3757
			"    28  new java.lang.NullPointerException [19]\n" + 
3758
			"    31  dup\n" + 
3759
			"    32  invokespecial java.lang.NullPointerException() [21]\n" + 
3760
			"    35  athrow\n" + 
3761
			"    36  goto 44\n" + 
3762
			"    39  aload_0 [this]\n" + 
3763
			"    40  invokevirtual X.bool() : boolean [17]\n" + 
3764
			"    43  pop\n" + 
3765
			"    44  return\n" + 
3766
			"      Line numbers:\n" + 
3767
			"        [pc: 0, line: 46]\n" + 
3768
			"        [pc: 7, line: 47]\n" + 
3769
			"        [pc: 28, line: 48]\n" + 
3770
			"        [pc: 39, line: 52]\n" + 
3771
			"        [pc: 44, line: 54]\n" + 
3772
			"      Local variable table:\n" + 
3773
			"        [pc: 0, pc: 45] local: this index: 0 type: X\n" + 
3774
			"        [pc: 0, pc: 45] local: i index: 1 type: int\n" + 
3775
			"      Stack map table: number of frames 4\n" + 
3776
			"        [pc: 28, same]\n" + 
3777
			"        [pc: 36, same]\n" + 
3778
			"        [pc: 39, same]\n" + 
3779
			"        [pc: 44, same]\n";
3780
	try {
3781
		File f = new File(OUTPUT_DIR + File.separator + "X.class");
3782
		byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
3783
		ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
3784
		String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
3785
		int index = result.indexOf(expectedOutput);
3786
		if (index == -1 || expectedOutput.length() == 0) {
3787
			System.out.println(Util.displayString(result, 3));
3788
		}
3789
		if (index == -1) {
3790
			assertEquals("Wrong contents", expectedOutput, result);
3791
		}
3792
	} catch (org.eclipse.jdt.core.util.ClassFormatException e) {
3793
		assertTrue(false);
3794
	} catch (IOException e) {
3795
		assertTrue(false);
3796
	}	
3797
}
3798
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114894 - variation
3799
public void test049() {
3800
	this.runConformTest(
3801
			new String[] {
3802
				"X.java",
3803
				"public class X {\n" + 
3804
				"	boolean bool() { return true; }\n" + 
3805
				"	void foo() {\n" + 
3806
				"		check: try {\n" + 
3807
				"			if (bool()) {\n" + 
3808
				"				break check;\n" + 
3809
				"			}\n" + 
3810
				"		} catch (Exception e) {\n" + 
3811
				"		}\n" + 
3812
				"	}\n" + 
3813
				"	void foo2() {\n" + 
3814
				"		check: try {\n" + 
3815
				"			while (bool()) {\n" + 
3816
				"				break check;\n" + 
3817
				"			}\n" + 
3818
				"		} catch (Exception e) {\n" + 
3819
				"		}\n" + 
3820
				"	}\n" + 
3821
				"	void foo3() {\n" + 
3822
				"		check: try {\n" + 
3823
				"			do {\n" + 
3824
				"				if (true) break check;\n" + 
3825
				"			} while (bool());\n" + 
3826
				"		} catch (Exception e) {\n" + 
3827
				"		}\n" + 
3828
				"	}	\n" + 
3829
				"	void foo4() {\n" + 
3830
				"		check: try {\n" + 
3831
				"			for (int i  = 0; bool(); i++) {\n" + 
3832
				"				break check;\n" + 
3833
				"			}\n" + 
3834
				"		} catch (Exception e) {\n" + 
3835
				"		}\n" + 
3836
				"	}		\n" + 
3837
				"	void bar() {\n" + 
3838
				"		check: if (bool()) {\n" + 
3839
				"			if (bool())\n" + 
3840
				"				break check;\n" + 
3841
				"		} else {\n" + 
3842
				"			if (bool()) {\n" + 
3843
				"				break check;\n" + 
3844
				"			}\n" + 
3845
				"		}\n" + 
3846
				"	}\n" + 
3847
				"	void baz(int i) {\n" + 
3848
				"		check: if (bool()) {\n" + 
3849
				"			switch(i) {\n" + 
3850
				"				case 0 : break check;\n" + 
3851
				"				default : break;\n" + 
3852
				"			}\n" + 
3853
				"		} else {\n" + 
3854
				"			bool();\n" + 
3855
				"		}\n" + 
3856
				"	}\n" + 
3857
				"}\n",
3858
			},
3859
			"");
3860
	
3861
	String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6
3862
		?	"  // Method descriptor #6 ()V\n" + 
3863
			"  // Stack: 1, Locals: 2\n" + 
3864
			"  void foo();\n" + 
3865
			"     0  aload_0 [this]\n" + 
3866
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3867
			"     4  ifeq 11\n" + 
3868
			"     7  goto 11\n" + 
3869
			"    10  astore_1\n" + 
3870
			"    11  return\n" + 
3871
			"      Exception Table:\n" + 
3872
			"        [pc: 0, pc: 7] -> 10 when : java.lang.Exception\n" + 
3873
			"      Line numbers:\n" + 
3874
			"        [pc: 0, line: 5]\n" + 
3875
			"        [pc: 7, line: 6]\n" + 
3876
			"        [pc: 10, line: 8]\n" + 
3877
			"        [pc: 11, line: 10]\n" + 
3878
			"      Local variable table:\n" + 
3879
			"        [pc: 0, pc: 12] local: this index: 0 type: X\n" + 
3880
			"  \n" + 
3881
			"  // Method descriptor #6 ()V\n" + 
3882
			"  // Stack: 1, Locals: 2\n" + 
3883
			"  void foo2();\n" + 
3884
			"     0  aload_0 [this]\n" + 
3885
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3886
			"     4  ifeq 11\n" + 
3887
			"     7  goto 11\n" + 
3888
			"    10  astore_1\n" + 
3889
			"    11  return\n" + 
3890
			"      Exception Table:\n" + 
3891
			"        [pc: 0, pc: 7] -> 10 when : java.lang.Exception\n" + 
3892
			"      Line numbers:\n" + 
3893
			"        [pc: 0, line: 13]\n" + 
3894
			"        [pc: 7, line: 14]\n" + 
3895
			"        [pc: 10, line: 16]\n" + 
3896
			"        [pc: 11, line: 18]\n" + 
3897
			"      Local variable table:\n" + 
3898
			"        [pc: 0, pc: 12] local: this index: 0 type: X\n" + 
3899
			"  \n" + 
3900
			"  // Method descriptor #6 ()V\n" + 
3901
			"  // Stack: 1, Locals: 2\n" + 
3902
			"  void foo3();\n" + 
3903
			"    0  goto 4\n" + 
3904
			"    3  astore_1\n" + 
3905
			"    4  return\n" + 
3906
			"      Line numbers:\n" + 
3907
			"        [pc: 0, line: 22]\n" + 
3908
			"        [pc: 3, line: 24]\n" + 
3909
			"        [pc: 4, line: 26]\n" + 
3910
			"      Local variable table:\n" + 
3911
			"        [pc: 0, pc: 5] local: this index: 0 type: X\n" + 
3912
			"  \n" + 
3913
			"  // Method descriptor #6 ()V\n" + 
3914
			"  // Stack: 1, Locals: 2\n" + 
3915
			"  void foo4();\n" + 
3916
			"     0  iconst_0\n" + 
3917
			"     1  istore_1 [i]\n" + 
3918
			"     2  aload_0 [this]\n" + 
3919
			"     3  invokevirtual X.bool() : boolean [17]\n" + 
3920
			"     6  ifne 2\n" + 
3921
			"     9  goto 13\n" + 
3922
			"    12  astore_1\n" + 
3923
			"    13  return\n" + 
3924
			"      Exception Table:\n" + 
3925
			"        [pc: 0, pc: 12] -> 12 when : java.lang.Exception\n" + 
3926
			"      Line numbers:\n" + 
3927
			"        [pc: 0, line: 29]\n" + 
3928
			"        [pc: 12, line: 32]\n" + 
3929
			"        [pc: 13, line: 34]\n" + 
3930
			"      Local variable table:\n" + 
3931
			"        [pc: 0, pc: 14] local: this index: 0 type: X\n" + 
3932
			"        [pc: 2, pc: 9] local: i index: 1 type: int\n" + 
3933
			"  \n" + 
3934
			"  // Method descriptor #6 ()V\n" + 
3935
			"  // Stack: 1, Locals: 1\n" + 
3936
			"  void bar();\n" + 
3937
			"     0  aload_0 [this]\n" + 
3938
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3939
			"     4  ifeq 17\n" + 
3940
			"     7  aload_0 [this]\n" + 
3941
			"     8  invokevirtual X.bool() : boolean [17]\n" + 
3942
			"    11  ifeq 24\n" + 
3943
			"    14  goto 24\n" + 
3944
			"    17  aload_0 [this]\n" + 
3945
			"    18  invokevirtual X.bool() : boolean [17]\n" + 
3946
			"    21  ifeq 24\n" + 
3947
			"    24  return\n" + 
3948
			"      Line numbers:\n" + 
3949
			"        [pc: 0, line: 36]\n" + 
3950
			"        [pc: 7, line: 37]\n" + 
3951
			"        [pc: 14, line: 38]\n" + 
3952
			"        [pc: 17, line: 40]\n" + 
3953
			"        [pc: 24, line: 44]\n" + 
3954
			"      Local variable table:\n" + 
3955
			"        [pc: 0, pc: 25] local: this index: 0 type: X\n" + 
3956
			"  \n" + 
3957
			"  // Method descriptor #28 (I)V\n" + 
3958
			"  // Stack: 1, Locals: 2\n" + 
3959
			"  void baz(int i);\n" + 
3960
			"     0  aload_0 [this]\n" + 
3961
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3962
			"     4  ifeq 34\n" + 
3963
			"     7  iload_1 [i]\n" + 
3964
			"     8  tableswitch default: 31\n" + 
3965
			"          case 0: 28\n" + 
3966
			"    28  goto 39\n" + 
3967
			"    31  goto 39\n" + 
3968
			"    34  aload_0 [this]\n" + 
3969
			"    35  invokevirtual X.bool() : boolean [17]\n" + 
3970
			"    38  pop\n" + 
3971
			"    39  return\n" + 
3972
			"      Line numbers:\n" + 
3973
			"        [pc: 0, line: 46]\n" + 
3974
			"        [pc: 7, line: 47]\n" + 
3975
			"        [pc: 28, line: 48]\n" + 
3976
			"        [pc: 34, line: 52]\n" + 
3977
			"        [pc: 39, line: 54]\n" + 
3978
			"      Local variable table:\n" + 
3979
			"        [pc: 0, pc: 40] local: this index: 0 type: X\n" + 
3980
			"        [pc: 0, pc: 40] local: i index: 1 type: int\n"
3981
		:	
3982
			"  // Method descriptor #6 ()V\n" + 
3983
			"  // Stack: 1, Locals: 2\n" + 
3984
			"  void foo();\n" + 
3985
			"     0  aload_0 [this]\n" + 
3986
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
3987
			"     4  ifeq 11\n" + 
3988
			"     7  goto 11\n" + 
3989
			"    10  astore_1\n" + 
3990
			"    11  return\n" + 
3991
			"      Exception Table:\n" + 
3992
			"        [pc: 0, pc: 7] -> 10 when : java.lang.Exception\n" + 
3993
			"      Line numbers:\n" + 
3994
			"        [pc: 0, line: 5]\n" + 
3995
			"        [pc: 7, line: 6]\n" + 
3996
			"        [pc: 10, line: 8]\n" + 
3997
			"        [pc: 11, line: 10]\n" + 
3998
			"      Local variable table:\n" + 
3999
			"        [pc: 0, pc: 12] local: this index: 0 type: X\n" + 
4000
			"      Stack map table: number of frames 2\n" + 
4001
			"        [pc: 10, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + 
4002
			"        [pc: 11, same]\n" + 
4003
			"  \n" + 
4004
			"  // Method descriptor #6 ()V\n" + 
4005
			"  // Stack: 1, Locals: 2\n" + 
4006
			"  void foo2();\n" + 
4007
			"     0  aload_0 [this]\n" + 
4008
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
4009
			"     4  ifeq 11\n" + 
4010
			"     7  goto 11\n" + 
4011
			"    10  astore_1\n" + 
4012
			"    11  return\n" + 
4013
			"      Exception Table:\n" + 
4014
			"        [pc: 0, pc: 7] -> 10 when : java.lang.Exception\n" + 
4015
			"      Line numbers:\n" + 
4016
			"        [pc: 0, line: 13]\n" + 
4017
			"        [pc: 7, line: 14]\n" + 
4018
			"        [pc: 10, line: 16]\n" + 
4019
			"        [pc: 11, line: 18]\n" + 
4020
			"      Local variable table:\n" + 
4021
			"        [pc: 0, pc: 12] local: this index: 0 type: X\n" + 
4022
			"      Stack map table: number of frames 3\n" + 
4023
			"        [pc: 7, same]\n" + 
4024
			"        [pc: 10, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + 
4025
			"        [pc: 11, same]\n" + 
4026
			"  \n" + 
4027
			"  // Method descriptor #6 ()V\n" + 
4028
			"  // Stack: 1, Locals: 2\n" + 
4029
			"  void foo3();\n" + 
4030
			"    0  goto 4\n" + 
4031
			"    3  astore_1\n" + 
4032
			"    4  return\n" + 
4033
			"      Line numbers:\n" + 
4034
			"        [pc: 0, line: 22]\n" + 
4035
			"        [pc: 3, line: 24]\n" + 
4036
			"        [pc: 4, line: 26]\n" + 
4037
			"      Local variable table:\n" + 
4038
			"        [pc: 0, pc: 5] local: this index: 0 type: X\n" + 
4039
			"      Stack map table: number of frames 3\n" + 
4040
			"        [pc: 0, same]\n" + 
4041
			"        [pc: 3, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + 
4042
			"        [pc: 4, same]\n" + 
4043
			"  \n" + 
4044
			"  // Method descriptor #6 ()V\n" + 
4045
			"  // Stack: 1, Locals: 2\n" + 
4046
			"  void foo4();\n" + 
4047
			"     0  iconst_0\n" + 
4048
			"     1  istore_1 [i]\n" + 
4049
			"     2  aload_0 [this]\n" + 
4050
			"     3  invokevirtual X.bool() : boolean [17]\n" + 
4051
			"     6  ifne 2\n" + 
4052
			"     9  goto 13\n" + 
4053
			"    12  astore_1\n" + 
4054
			"    13  return\n" + 
4055
			"      Exception Table:\n" + 
4056
			"        [pc: 0, pc: 12] -> 12 when : java.lang.Exception\n" + 
4057
			"      Line numbers:\n" + 
4058
			"        [pc: 0, line: 29]\n" + 
4059
			"        [pc: 12, line: 32]\n" + 
4060
			"        [pc: 13, line: 34]\n" + 
4061
			"      Local variable table:\n" + 
4062
			"        [pc: 0, pc: 14] local: this index: 0 type: X\n" + 
4063
			"        [pc: 2, pc: 9] local: i index: 1 type: int\n" + 
4064
			"      Stack map table: number of frames 3\n" + 
4065
			"        [pc: 2, append: {int}]\n" + 
4066
			"        [pc: 12, full, stack: {java.lang.Exception}, locals: {X}]\n" + 
4067
			"        [pc: 13, same]\n" + 
4068
			"  \n" + 
4069
			"  // Method descriptor #6 ()V\n" + 
4070
			"  // Stack: 1, Locals: 1\n" + 
4071
			"  void bar();\n" + 
4072
			"     0  aload_0 [this]\n" + 
4073
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
4074
			"     4  ifeq 17\n" + 
4075
			"     7  aload_0 [this]\n" + 
4076
			"     8  invokevirtual X.bool() : boolean [17]\n" + 
4077
			"    11  ifeq 24\n" + 
4078
			"    14  goto 24\n" + 
4079
			"    17  aload_0 [this]\n" + 
4080
			"    18  invokevirtual X.bool() : boolean [17]\n" + 
4081
			"    21  ifeq 24\n" + 
4082
			"    24  return\n" + 
4083
			"      Line numbers:\n" + 
4084
			"        [pc: 0, line: 36]\n" + 
4085
			"        [pc: 7, line: 37]\n" + 
4086
			"        [pc: 14, line: 38]\n" + 
4087
			"        [pc: 17, line: 40]\n" + 
4088
			"        [pc: 24, line: 44]\n" + 
4089
			"      Local variable table:\n" + 
4090
			"        [pc: 0, pc: 25] local: this index: 0 type: X\n" + 
4091
			"      Stack map table: number of frames 2\n" + 
4092
			"        [pc: 17, same]\n" + 
4093
			"        [pc: 24, same]\n" + 
4094
			"  \n" + 
4095
			"  // Method descriptor #29 (I)V\n" + 
4096
			"  // Stack: 1, Locals: 2\n" + 
4097
			"  void baz(int i);\n" + 
4098
			"     0  aload_0 [this]\n" + 
4099
			"     1  invokevirtual X.bool() : boolean [17]\n" + 
4100
			"     4  ifeq 34\n" + 
4101
			"     7  iload_1 [i]\n" + 
4102
			"     8  tableswitch default: 31\n" + 
4103
			"          case 0: 28\n" + 
4104
			"    28  goto 39\n" + 
4105
			"    31  goto 39\n" + 
4106
			"    34  aload_0 [this]\n" + 
4107
			"    35  invokevirtual X.bool() : boolean [17]\n" + 
4108
			"    38  pop\n" + 
4109
			"    39  return\n" + 
4110
			"      Line numbers:\n" + 
4111
			"        [pc: 0, line: 46]\n" + 
4112
			"        [pc: 7, line: 47]\n" + 
4113
			"        [pc: 28, line: 48]\n" + 
4114
			"        [pc: 34, line: 52]\n" + 
4115
			"        [pc: 39, line: 54]\n" + 
4116
			"      Local variable table:\n" + 
4117
			"        [pc: 0, pc: 40] local: this index: 0 type: X\n" + 
4118
			"        [pc: 0, pc: 40] local: i index: 1 type: int\n" + 
4119
			"      Stack map table: number of frames 4\n" + 
4120
			"        [pc: 28, same]\n" + 
4121
			"        [pc: 31, same]\n" + 
4122
			"        [pc: 34, same]\n" + 
4123
			"        [pc: 39, same]\n";
4124
	
4125
	try {
4126
		File f = new File(OUTPUT_DIR + File.separator + "X.class");
4127
		byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
4128
		ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
4129
		String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
4130
		int index = result.indexOf(expectedOutput);
4131
		if (index == -1 || expectedOutput.length() == 0) {
4132
			System.out.println(Util.displayString(result, 3));
4133
		}
4134
		if (index == -1) {
4135
			assertEquals("Wrong contents", expectedOutput, result);
4136
		}
4137
	} catch (org.eclipse.jdt.core.util.ClassFormatException e) {
4138
		assertTrue(false);
4139
	} catch (IOException e) {
4140
		assertTrue(false);
4141
	}	
4142
}
2973
public static Class testClass() {
4143
public static Class testClass() {
2974
	return TryStatementTest.class;
4144
	return TryStatementTest.class;
2975
}
4145
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java (+222 lines)
Lines 16-21 Link Here
16
import org.eclipse.jdt.core.ToolFactory;
16
import org.eclipse.jdt.core.ToolFactory;
17
import org.eclipse.jdt.core.tests.util.Util;
17
import org.eclipse.jdt.core.tests.util.Util;
18
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
18
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
19
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
20
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
19
21
20
import junit.framework.Test;
22
import junit.framework.Test;
21
23
Lines 355-360 Link Here
355
		assertTrue("IOException", false);
357
		assertTrue("IOException", false);
356
	}		
358
	}		
357
}
359
}
360
public void test013() {
361
	this.runConformTest(new String[] {
362
		"X.java",
363
		"public class X {\n" + 
364
		"\n" + 
365
		"	public static void main(String[] args) {\n" + 
366
		"		X x;\n" + 
367
		"		Object o = null;\n" + 
368
		"		for (int i = 0; i < 10; i++) {\n" + 
369
		"			if (i < 90) {\n" + 
370
		"				x = new X();\n" + 
371
		"				if (i > 4) {\n" + 
372
		"					o = new Object();\n" + 
373
		"				} else {\n" + 
374
		"					o = null;\n" + 
375
		"				}\n" + 
376
		"				switch (2) {\n" + 
377
		"					case 0:\n" + 
378
		"						if (o instanceof String) {\n" + 
379
		"							System.out.print(\"1\");\n" + 
380
		"							return;\n" + 
381
		"						} else {\n" + 
382
		"							break;\n" + 
383
		"						}\n" + 
384
		"					default: {\n" + 
385
		"						Object diff = o;\n" + 
386
		"						if (diff != null) {\n" + 
387
		"							System.out.print(\"2\");\n" + 
388
		"						}\n" + 
389
		"						break;\n" + 
390
		"					}\n" + 
391
		"				}\n" + 
392
		"				System.out.print(\"3\");				\n" + 
393
		"			}\n" + 
394
		"		}\n" + 
395
		"	}\n" + 
396
		"}\n",
397
	},
398
	"333332323232323");
399
400
	String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6
401
		?	"  // Method descriptor #15 ([Ljava/lang/String;)V\n" + 
402
			"  // Stack: 2, Locals: 5\n" + 
403
			"  public static void main(java.lang.String[] args);\n" + 
404
			"      0  aconst_null\n" + 
405
			"      1  astore_2 [o]\n" + 
406
			"      2  iconst_0\n" + 
407
			"      3  istore_3 [i]\n" + 
408
			"      4  goto 103\n" + 
409
			"      7  iload_3 [i]\n" + 
410
			"      8  bipush 90\n" + 
411
			"     10  if_icmpge 100\n" + 
412
			"     13  new X [1]\n" + 
413
			"     16  dup\n" + 
414
			"     17  invokespecial X() [16]\n" + 
415
			"     20  astore_1 [x]\n" + 
416
			"     21  iload_3 [i]\n" + 
417
			"     22  iconst_4\n" + 
418
			"     23  if_icmple 37\n" + 
419
			"     26  new java.lang.Object [3]\n" + 
420
			"     29  dup\n" + 
421
			"     30  invokespecial java.lang.Object() [8]\n" + 
422
			"     33  astore_2 [o]\n" + 
423
			"     34  goto 39\n" + 
424
			"     37  aconst_null\n" + 
425
			"     38  astore_2 [o]\n" + 
426
			"     39  iconst_2\n" + 
427
			"     40  tableswitch default: 76\n" + 
428
			"          case 0: 60\n" + 
429
			"     60  aload_2 [o]\n" + 
430
			"     61  instanceof java.lang.String [17]\n" + 
431
			"     64  ifeq 92\n" + 
432
			"     67  getstatic java.lang.System.out : java.io.PrintStream [19]\n" + 
433
			"     70  ldc <String \"1\"> [25]\n" + 
434
			"     72  invokevirtual java.io.PrintStream.print(java.lang.String) : void [27]\n" + 
435
			"     75  return\n" + 
436
			"     76  aload_2 [o]\n" + 
437
			"     77  astore 4 [diff]\n" + 
438
			"     79  aload 4 [diff]\n" + 
439
			"     81  ifnull 92\n" + 
440
			"     84  getstatic java.lang.System.out : java.io.PrintStream [19]\n" + 
441
			"     87  ldc <String \"2\"> [33]\n" + 
442
			"     89  invokevirtual java.io.PrintStream.print(java.lang.String) : void [27]\n" + 
443
			"     92  getstatic java.lang.System.out : java.io.PrintStream [19]\n" + 
444
			"     95  ldc <String \"3\"> [35]\n" + 
445
			"     97  invokevirtual java.io.PrintStream.print(java.lang.String) : void [27]\n" + 
446
			"    100  iinc 3 1 [i]\n" + 
447
			"    103  iload_3 [i]\n" + 
448
			"    104  bipush 10\n" + 
449
			"    106  if_icmplt 7\n" + 
450
			"    109  return\n" + 
451
			"      Line numbers:\n" + 
452
			"        [pc: 0, line: 5]\n" + 
453
			"        [pc: 2, line: 6]\n" + 
454
			"        [pc: 7, line: 7]\n" + 
455
			"        [pc: 13, line: 8]\n" + 
456
			"        [pc: 21, line: 9]\n" + 
457
			"        [pc: 26, line: 10]\n" + 
458
			"        [pc: 37, line: 12]\n" + 
459
			"        [pc: 39, line: 14]\n" + 
460
			"        [pc: 60, line: 16]\n" + 
461
			"        [pc: 67, line: 17]\n" + 
462
			"        [pc: 75, line: 18]\n" + 
463
			"        [pc: 76, line: 23]\n" + 
464
			"        [pc: 79, line: 24]\n" + 
465
			"        [pc: 84, line: 25]\n" + 
466
			"        [pc: 92, line: 30]\n" + 
467
			"        [pc: 100, line: 6]\n" + 
468
			"        [pc: 109, line: 33]\n" + 
469
			"      Local variable table:\n" + 
470
			"        [pc: 0, pc: 110] local: args index: 0 type: java.lang.String[]\n" + 
471
			"        [pc: 21, pc: 100] local: x index: 1 type: X\n" + 
472
			"        [pc: 2, pc: 110] local: o index: 2 type: java.lang.Object\n" + 
473
			"        [pc: 4, pc: 109] local: i index: 3 type: int\n" + 
474
			"        [pc: 79, pc: 92] local: diff index: 4 type: java.lang.Object\n"
475
		:
476
			"  // Method descriptor #15 ([Ljava/lang/String;)V\n" + 
477
			"  // Stack: 2, Locals: 5\n" + 
478
			"  public static void main(java.lang.String[] args);\n" + 
479
			"      0  aconst_null\n" + 
480
			"      1  astore_2 [o]\n" + 
481
			"      2  iconst_0\n" + 
482
			"      3  istore_3 [i]\n" + 
483
			"      4  goto 103\n" + 
484
			"      7  iload_3 [i]\n" + 
485
			"      8  bipush 90\n" + 
486
			"     10  if_icmpge 100\n" + 
487
			"     13  new X [1]\n" + 
488
			"     16  dup\n" + 
489
			"     17  invokespecial X() [16]\n" + 
490
			"     20  astore_1 [x]\n" + 
491
			"     21  iload_3 [i]\n" + 
492
			"     22  iconst_4\n" + 
493
			"     23  if_icmple 37\n" + 
494
			"     26  new java.lang.Object [3]\n" + 
495
			"     29  dup\n" + 
496
			"     30  invokespecial java.lang.Object() [8]\n" + 
497
			"     33  astore_2 [o]\n" + 
498
			"     34  goto 39\n" + 
499
			"     37  aconst_null\n" + 
500
			"     38  astore_2 [o]\n" + 
501
			"     39  iconst_2\n" + 
502
			"     40  tableswitch default: 76\n" + 
503
			"          case 0: 60\n" + 
504
			"     60  aload_2 [o]\n" + 
505
			"     61  instanceof java.lang.String [17]\n" + 
506
			"     64  ifeq 92\n" + 
507
			"     67  getstatic java.lang.System.out : java.io.PrintStream [19]\n" + 
508
			"     70  ldc <String \"1\"> [25]\n" + 
509
			"     72  invokevirtual java.io.PrintStream.print(java.lang.String) : void [27]\n" + 
510
			"     75  return\n" + 
511
			"     76  aload_2 [o]\n" + 
512
			"     77  astore 4 [diff]\n" + 
513
			"     79  aload 4 [diff]\n" + 
514
			"     81  ifnull 92\n" + 
515
			"     84  getstatic java.lang.System.out : java.io.PrintStream [19]\n" + 
516
			"     87  ldc <String \"2\"> [33]\n" + 
517
			"     89  invokevirtual java.io.PrintStream.print(java.lang.String) : void [27]\n" + 
518
			"     92  getstatic java.lang.System.out : java.io.PrintStream [19]\n" + 
519
			"     95  ldc <String \"3\"> [35]\n" + 
520
			"     97  invokevirtual java.io.PrintStream.print(java.lang.String) : void [27]\n" + 
521
			"    100  iinc 3 1 [i]\n" + 
522
			"    103  iload_3 [i]\n" + 
523
			"    104  bipush 10\n" + 
524
			"    106  if_icmplt 7\n" + 
525
			"    109  return\n" + 
526
			"      Line numbers:\n" + 
527
			"        [pc: 0, line: 5]\n" + 
528
			"        [pc: 2, line: 6]\n" + 
529
			"        [pc: 7, line: 7]\n" + 
530
			"        [pc: 13, line: 8]\n" + 
531
			"        [pc: 21, line: 9]\n" + 
532
			"        [pc: 26, line: 10]\n" + 
533
			"        [pc: 37, line: 12]\n" + 
534
			"        [pc: 39, line: 14]\n" + 
535
			"        [pc: 60, line: 16]\n" + 
536
			"        [pc: 67, line: 17]\n" + 
537
			"        [pc: 75, line: 18]\n" + 
538
			"        [pc: 76, line: 23]\n" + 
539
			"        [pc: 79, line: 24]\n" + 
540
			"        [pc: 84, line: 25]\n" + 
541
			"        [pc: 92, line: 30]\n" + 
542
			"        [pc: 100, line: 6]\n" + 
543
			"        [pc: 109, line: 33]\n" + 
544
			"      Local variable table:\n" + 
545
			"        [pc: 0, pc: 110] local: args index: 0 type: java.lang.String[]\n" + 
546
			"        [pc: 21, pc: 100] local: x index: 1 type: X\n" + 
547
			"        [pc: 2, pc: 110] local: o index: 2 type: java.lang.Object\n" + 
548
			"        [pc: 4, pc: 109] local: i index: 3 type: int\n" + 
549
			"        [pc: 79, pc: 92] local: diff index: 4 type: java.lang.Object\n" + 
550
			"      Stack map table: number of frames 8\n" + 
551
			"        [pc: 7, full, stack: {}, locals: {java.lang.String[], _, java.lang.Object, int}]\n" + 
552
			"        [pc: 37, full, stack: {}, locals: {java.lang.String[], X, java.lang.Object, int}]\n" + 
553
			"        [pc: 39, same]\n" + 
554
			"        [pc: 60, same]\n" + 
555
			"        [pc: 76, same]\n" + 
556
			"        [pc: 92, same]\n" + 
557
			"        [pc: 100, full, stack: {}, locals: {java.lang.String[], _, java.lang.Object, int}]\n" + 
558
			"        [pc: 103, same]\n";
559
	
560
	try {
561
		File f = new File(OUTPUT_DIR + File.separator + "X.class");
562
		byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
563
		ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
564
		String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
565
		int index = result.indexOf(expectedOutput);
566
		if (index == -1 || expectedOutput.length() == 0) {
567
			System.out.println(Util.displayString(result, 3));
568
		}
569
		if (index == -1) {
570
			assertEquals("Wrong contents", expectedOutput, result);
571
		}
572
	} catch (org.eclipse.jdt.core.util.ClassFormatException e) {
573
		e.printStackTrace();
574
		assertTrue("ClassFormatException", false);
575
	} catch (IOException e) {
576
		e.printStackTrace();
577
		assertTrue("IOException", false);
578
	}		
579
}
358
public static Class testClass() {
580
public static Class testClass() {
359
	return SwitchTest.class;
581
	return SwitchTest.class;
360
}
582
}

Return to bug 114894