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

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DebugAttributeTest.java (-1 / +140 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
2
 * Copyright (c) 2006, 2012 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 19-24 Link Here
19
19
20
public class DebugAttributeTest extends AbstractRegressionTest {
20
public class DebugAttributeTest extends AbstractRegressionTest {
21
21
22
	static {
23
		TESTS_NAMES = new String[]{"test007"};
24
	}
22
	public DebugAttributeTest(String name) {
25
	public DebugAttributeTest(String name) {
23
		super(name);
26
		super(name);
24
	}
27
	}
Lines 285-288 Link Here
285
		assertEquals("Wrong contents", expectedOutput, result);
288
		assertEquals("Wrong contents", expectedOutput, result);
286
	}
289
	}
287
}
290
}
291
292
public void test005() throws Exception {
293
	this.runConformTest(
294
		new String[] {
295
			"X.java",
296
			"public class X {\n" +
297
			"    public static void main(String[] args) {\n" +
298
			"        int[] i1= {1, 2, 3, 4};\n\n" +
299
			"		 foo(1, 2, 3, 4);\n\n" +
300
			"        foo(1,\n" +
301
			"			2,\n" +
302
			"			3,\n" +
303
			"			4);\n" +
304
			"    }\n" +
305
			"	static void foo(int i1, int i2, int i3, int i4) {}\n" +
306
			"}",
307
		},
308
		"");
309
310
	ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
311
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator  +"X.class"));
312
	String actualOutput =
313
		disassembler.disassemble(
314
			classFileBytes,
315
			"\n",
316
			ClassFileBytesDisassembler.DETAILED);
317
318
	String expectedOutput =
319
			"      Line numbers\n" + 
320
			"        [pc: 0, line: 3]\n" + 
321
			"        [pc: 20, line: 5]\n" + 
322
			"        [pc: 27, line: 7]\n" + 
323
			"        [pc: 28, line: 8]\n" + 
324
			"        [pc: 29, line: 9]\n" + 
325
			"        [pc: 30, line: 10]\n" + 
326
			"        [pc: 34, line: 11]\n";
327
328
	int index = actualOutput.indexOf(expectedOutput);
329
	if (index == -1 || expectedOutput.length() == 0) {
330
		System.out.println(Util.displayString(actualOutput, 3));
331
	}
332
	if (index == -1) {
333
		assertEquals("unexpected bytecode sequence", expectedOutput, actualOutput);
334
	}
335
}
336
337
public void test006() throws Exception {
338
	this.runConformTest(
339
		new String[] {
340
			"X.java",
341
			"public class X {\n" +
342
			"    public static void main(String[] args) {\n" +
343
			"        int[] i1= {1, 2, 3, 4};\n\n" +
344
			"		 foo(1, 2, 3, 4);\n\n" +
345
			"        int[] i2 = {1,\n" +
346
			"			2,\n" +
347
			"			3,\n" +
348
			"			4};\n" +
349
			"    }\n" +
350
			"	static void foo(int i1, int i2, int i3, int i4) {}\n" +
351
			"}",
352
		},
353
		"");
354
355
	ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
356
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator  +"X.class"));
357
	String actualOutput =
358
		disassembler.disassemble(
359
			classFileBytes,
360
			"\n",
361
			ClassFileBytesDisassembler.DETAILED);
362
363
	String expectedOutput =
364
			"      Line numbers:\n" + 
365
			"        [pc: 0, line: 3]\n" + 
366
			"        [pc: 20, line: 5]\n" + 
367
			"        [pc: 27, line: 7]\n" + 
368
			"        [pc: 28, line: 8]\n" + 
369
			"        [pc: 29, line: 9]\n" + 
370
			"        [pc: 30, line: 10]\n" + 
371
			"        [pc: 34, line: 11]\n";
372
373
	int index = actualOutput.indexOf(expectedOutput);
374
	if (index == -1 || expectedOutput.length() == 0) {
375
		System.out.println(Util.displayString(actualOutput, 3));
376
	}
377
	if (index == -1) {
378
		assertEquals("unexpected bytecode sequence", expectedOutput, actualOutput);
379
	}
380
}
381
382
public void test007() throws Exception {
383
	this.runConformTest(
384
		new String[] {
385
			"X.java",
386
			"public class X {\n" +
387
			"    public static void main(String[] args) {\n" +
388
			"        int[] i1= {1, 2, 3, 4};\n\n" +
389
			"		 foo(1, 2, 3, 4);\n" +
390
			"		 int[] i2;\n" +
391
			"        i2 = new int[]{1,\n" +
392
			"			2,\n" +
393
			"			3,\n" +
394
			"			4};\n" +
395
			"    }\n" +
396
			"	static void foo(int i1, int i2, int i3, int i4) {}\n" +
397
			"}",
398
		},
399
		"");
400
401
	ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
402
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator  +"X.class"));
403
	String actualOutput =
404
		disassembler.disassemble(
405
			classFileBytes,
406
			"\n",
407
			ClassFileBytesDisassembler.DETAILED);
408
409
	String expectedOutput =
410
			"      Line numbers:\n" + 
411
			"        [pc: 0, line: 3]\n" + 
412
			"        [pc: 20, line: 5]\n" + 
413
			"        [pc: 27, line: 7]\n" + 
414
			"        [pc: 28, line: 8]\n" + 
415
			"        [pc: 29, line: 9]\n" + 
416
			"        [pc: 30, line: 10]\n" + 
417
			"        [pc: 34, line: 11]\n";
418
419
	int index = actualOutput.indexOf(expectedOutput);
420
	if (index == -1 || expectedOutput.length() == 0) {
421
		System.out.println(Util.displayString(actualOutput, 3));
422
	}
423
	if (index == -1) {
424
		assertEquals("unexpected bytecode sequence", expectedOutput, actualOutput);
425
	}
426
}
288
}
427
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java (-1 / +1 lines)
Lines 107-113 Link Here
107
	 ((Reference) this.lhs).generateAssignment(currentScope, codeStream, this, valueRequired);
107
	 ((Reference) this.lhs).generateAssignment(currentScope, codeStream, this, valueRequired);
108
	// variable may have been optimized out
108
	// variable may have been optimized out
109
	// the lhs is responsible to perform the implicitConversion generation for the assignment since optimized for unused local assignment.
109
	// the lhs is responsible to perform the implicitConversion generation for the assignment since optimized for unused local assignment.
110
	codeStream.recordPositionsFrom(pc, this.sourceStart);
110
	codeStream.recordPositionsFrom(pc, this.sourceEnd);
111
}
111
}
112
112
113
FieldBinding getLastField(Expression someExpression) {
113
FieldBinding getLastField(Expression someExpression) {
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java (-1 / +1 lines)
Lines 179-185 Link Here
179
				this.binding.recordInitializationStartPC(codeStream.position);
179
				this.binding.recordInitializationStartPC(codeStream.position);
180
			}
180
			}
181
		}
181
		}
182
		codeStream.recordPositionsFrom(pc, this.sourceStart);
182
		codeStream.recordPositionsFrom(pc, this.declarationSourceEnd);
183
	}
183
	}
184
184
185
	/**
185
	/**
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-1 / +1 lines)
Lines 261-267 Link Here
261
				codeStream.pop();
261
				codeStream.pop();
262
		}
262
		}
263
	}
263
	}
264
	codeStream.recordPositionsFrom(pc, (int)(this.nameSourcePosition >>> 32)); // highlight selector
264
	codeStream.recordPositionsFrom(pc, this.sourceEnd); // highlight selector
265
}
265
}
266
/**
266
/**
267
 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
267
 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 3708-3715 Link Here
3708
}
3708
}
3709
3709
3710
public int indexOfSameLineEntrySincePC(int pc, int line) {
3710
public int indexOfSameLineEntrySincePC(int pc, int line) {
3711
	for (int index = pc, max = this.pcToSourceMapSize; index < max; index+=2) {
3711
	for (int index = 0, max = this.pcToSourceMapSize - 2; index <= max; index+=2) {
3712
		if (this.pcToSourceMap[index+1] == line)
3712
		if (this.pcToSourceMap[index+1] == line && this.pcToSourceMap[index] >= pc)
3713
			return index;
3713
			return index;
3714
	}
3714
	}
3715
	return -1;
3715
	return -1;

Return to bug 339984