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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java (+2 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann - Contribution for Bug 343713 - [compiler] bogus line number in constructor of inner class in 1.5 compliance
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.ast;
12
package org.eclipse.jdt.internal.compiler.ast;
12
13
Lines 335-340 Link Here
335
336
336
		if (needFieldInitializations && preInitSyntheticFields){
337
		if (needFieldInitializations && preInitSyntheticFields){
337
			generateSyntheticFieldInitializationsIfNecessary(this.scope, codeStream, declaringClass);
338
			generateSyntheticFieldInitializationsIfNecessary(this.scope, codeStream, declaringClass);
339
			codeStream.recordPositionsFrom(0, this.bodyStart);
338
		}
340
		}
339
		// generate constructor call
341
		// generate constructor call
340
		if (this.constructorCall != null) {
342
		if (this.constructorCall != null) {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest_1_5.java (-1 / +37 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
2
 * Copyright (c) 2009, 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
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann - Contribution for Bug 343713 - [compiler] bogus line number in constructor of inner class in 1.5 compliance
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 286-291 Link Here
286
		"     inner name: #24 D, accessflags: 8 static]\n";
287
		"     inner name: #24 D, accessflags: 8 static]\n";
287
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
288
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
288
}
289
}
290
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=343713
291
// [compiler] bogus line number in constructor of inner class in 1.5 compliance
292
public void test14() throws Exception {
293
	runConformTest(new String[] {
294
		"LineNumberBug.java",
295
		"public class LineNumberBug {\n" + 
296
		"    class Inner {\n" + 
297
		"		public Inner() {\n" + 
298
		"			System.out.println(\"Inner()\");\n" + 
299
		"		}\n" + 
300
		"    }\n" + 
301
		"	public static void main(String[] args) {\n" + 
302
		"		new LineNumberBug().new Inner();\n" + 
303
		"	}\n" + 
304
		"}\n"
305
	});
306
	String expectedOutput =
307
		"  // Method descriptor #8 (LLineNumberBug;)V\n" + 
308
		"  // Stack: 2, Locals: 2\n" + 
309
		"  public LineNumberBug$Inner(LineNumberBug arg0);\n" + 
310
		"     0  aload_0 [this]\n" + 
311
		"     1  aload_1 [arg0]\n" + 
312
		"     2  putfield LineNumberBug$Inner.this$0 : LineNumberBug [10]\n" + 
313
		"     5  aload_0 [this]\n" + 
314
		"     6  invokespecial java.lang.Object() [12]\n" + 
315
		"     9  getstatic java.lang.System.out : java.io.PrintStream [15]\n" + 
316
		"    12  ldc <String \"Inner()\"> [21]\n" + 
317
		"    14  invokevirtual java.io.PrintStream.println(java.lang.String) : void [23]\n" + 
318
		"    17  return\n" + 
319
		"      Line numbers:\n" + 
320
		"        [pc: 0, line: 3]\n" + 
321
		"        [pc: 9, line: 4]\n" +
322
		"        [pc: 17, line: 5]\n";
323
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "LineNumberBug$Inner.class", "LineNumberBug$Inner", expectedOutput);	
324
}
289
public static Class testClass() {
325
public static Class testClass() {
290
	return InnerEmulationTest_1_5.class;
326
	return InnerEmulationTest_1_5.class;
291
}
327
}

Return to bug 343713