Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 338402 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-52 / +23 lines)
Lines 5891-5909 Link Here
5891
			break;
5891
			break;
5892
 
5892
 
5893
    case 327 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catches"); }  //$NON-NLS-1$
5893
    case 327 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catches"); }  //$NON-NLS-1$
5894
		    consumeStatementTry(false);  
5894
		    consumeStatementTry(false, false);  
5895
			break;
5895
			break;
5896
 
5896
 
5897
    case 328 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catchesopt Finally"); }  //$NON-NLS-1$
5897
    case 328 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catchesopt Finally"); }  //$NON-NLS-1$
5898
		    consumeStatementTry(true);  
5898
		    consumeStatementTry(true, false);  
5899
			break;
5899
			break;
5900
 
5900
 
5901
    case 329 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); }  //$NON-NLS-1$
5901
    case 329 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); }  //$NON-NLS-1$
5902
		    consumeStatementTryWithResources(false);  
5902
		    consumeStatementTry(false, true);  
5903
			break;
5903
			break;
5904
 
5904
 
5905
    case 330 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); }  //$NON-NLS-1$
5905
    case 330 : if (DEBUG) { System.out.println("TryStatementWithResources ::= try ResourceSpecification"); }  //$NON-NLS-1$
5906
		    consumeStatementTryWithResources(true);  
5906
		    consumeStatementTry(true, true);  
5907
			break;
5907
			break;
5908
 
5908
 
5909
    case 331 : if (DEBUG) { System.out.println("ResourceSpecification ::= LPAREN Resources ;opt RPAREN"); }  //$NON-NLS-1$
5909
    case 331 : if (DEBUG) { System.out.println("ResourceSpecification ::= LPAREN Resources ;opt RPAREN"); }  //$NON-NLS-1$
Lines 7382-7424 Link Here
7382
	this.expressionLengthPtr--;
7382
	this.expressionLengthPtr--;
7383
	pushOnAstStack(new ThrowStatement(this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--], this.endStatementPosition));
7383
	pushOnAstStack(new ThrowStatement(this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--], this.endStatementPosition));
7384
}
7384
}
7385
protected void consumeStatementTry(boolean withFinally) {
7385
protected void consumeStatementTry(boolean withFinally, boolean hasResources) {
7386
	//TryStatement ::= 'try'  Block Catches
7386
	// TryStatement ::= 'try'  Block Catches
7387
	//TryStatement ::= 'try'  Block Catchesopt Finally
7387
	// TryStatement ::= 'try'  Block Catchesopt Finally
7388
7389
	int length;
7390
	TryStatement tryStmt = new TryStatement();
7391
	//finally
7392
	if (withFinally) {
7393
		this.astLengthPtr--;
7394
		tryStmt.finallyBlock = (Block) this.astStack[this.astPtr--];
7395
	}
7396
	//catches are handle by two <argument-block> [see statementCatch]
7397
	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
7398
		if (length == 1) {
7399
			tryStmt.catchBlocks = new Block[] {(Block) this.astStack[this.astPtr--]};
7400
			tryStmt.catchArguments = new Argument[] {(Argument) this.astStack[this.astPtr--]};
7401
		} else {
7402
			Block[] bks = (tryStmt.catchBlocks = new Block[length]);
7403
			Argument[] args = (tryStmt.catchArguments = new Argument[length]);
7404
			while (length-- > 0) {
7405
				bks[length] = (Block) this.astStack[this.astPtr--];
7406
				args[length] = (Argument) this.astStack[this.astPtr--];
7407
			}
7408
		}
7409
	}
7410
	//try
7411
	this.astLengthPtr--;
7412
	tryStmt.tryBlock = (Block) this.astStack[this.astPtr--];
7413
7414
	//positions
7415
	tryStmt.sourceEnd = this.endStatementPosition;
7416
	tryStmt.sourceStart = this.intStack[this.intPtr--];
7417
	pushOnAstStack(tryStmt);
7418
}
7419
protected void consumeStatementTryWithResources(boolean withFinally) {
7420
	// TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt
7388
	// TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt
7421
	// TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt Finally
7389
	// TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt Finally
7390
	
7422
	int length;
7391
	int length;
7423
	TryStatement tryStmt = new TryStatement();
7392
	TryStatement tryStmt = new TryStatement();
7424
	//finally
7393
	//finally
Lines 7444-7462 Link Here
7444
	this.astLengthPtr--;
7413
	this.astLengthPtr--;
7445
	tryStmt.tryBlock = (Block) this.astStack[this.astPtr--];
7414
	tryStmt.tryBlock = (Block) this.astStack[this.astPtr--];
7446
7415
7447
	// get the resources
7416
	if (hasResources) {
7448
	length = this.astLengthStack[this.astLengthPtr--];
7417
		// get the resources
7449
	LocalDeclaration[] resources = new LocalDeclaration[length];
7418
		length = this.astLengthStack[this.astLengthPtr--];
7450
	System.arraycopy(
7419
		LocalDeclaration[] resources = new LocalDeclaration[length];
7451
			this.astStack,
7420
		System.arraycopy(
7452
			(this.astPtr -= length) + 1,
7421
				this.astStack,
7453
			resources,
7422
				(this.astPtr -= length) + 1,
7454
			0,
7423
				resources,
7455
			length);
7424
				0,
7456
	if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
7425
				length);
7457
		problemReporter().autoManagedResourcesNotBelow17(resources);
7426
		if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
7458
	} else {
7427
			problemReporter().autoManagedResourcesNotBelow17(resources);
7459
		tryStmt.resources = resources;
7428
		} else {
7429
			tryStmt.resources = resources;
7430
		}
7460
	}
7431
	}
7461
	//positions
7432
	//positions
7462
	tryStmt.sourceEnd = this.endStatementPosition;
7433
	tryStmt.sourceEnd = this.endStatementPosition;
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java (-3 / +7 lines)
Lines 1-9 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 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
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
7
 *
11
 *
8
 * Contributors:
12
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
Lines 535-542 Link Here
535
	/* recovery */
539
	/* recovery */
536
	recordLastStatementIfNeeded();
540
	recordLastStatementIfNeeded();
537
}
541
}
538
protected void consumeStatementTry(boolean arg_0) {
542
protected void consumeStatementTry(boolean arg_0, boolean arg_1) {
539
	super.consumeStatementTry(arg_0);
543
	super.consumeStatementTry(arg_0, arg_1);
540
	/* recovery */
544
	/* recovery */
541
	recordLastStatementIfNeeded();
545
	recordLastStatementIfNeeded();
542
}
546
}
(-)grammar/java.g (-4 / +4 lines)
Lines 1107-1121 Link Here
1107
/:$readableName OnlySynchronized:/
1107
/:$readableName OnlySynchronized:/
1108
1108
1109
TryStatement ::= 'try' TryBlock Catches
1109
TryStatement ::= 'try' TryBlock Catches
1110
/.$putCase consumeStatementTry(false); $break ./
1110
/.$putCase consumeStatementTry(false, false); $break ./
1111
TryStatement ::= 'try' TryBlock Catchesopt Finally
1111
TryStatement ::= 'try' TryBlock Catchesopt Finally
1112
/.$putCase consumeStatementTry(true); $break ./
1112
/.$putCase consumeStatementTry(true, false); $break ./
1113
/:$readableName TryStatement:/
1113
/:$readableName TryStatement:/
1114
1114
1115
TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt
1115
TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt
1116
/.$putCase consumeStatementTryWithResources(false); $break ./
1116
/.$putCase consumeStatementTry(false, true); $break ./
1117
TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt Finally
1117
TryStatementWithResources ::= 'try' ResourceSpecification TryBlock Catchesopt Finally
1118
/.$putCase consumeStatementTryWithResources(true); $break ./
1118
/.$putCase consumeStatementTry(true, true); $break ./
1119
/:$readableName TryStatementWithResources:/
1119
/:$readableName TryStatementWithResources:/
1120
/:$compliance 1.7:/
1120
/:$compliance 1.7:/
1121
1121

Return to bug 338402