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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/DebugAttributeTest.java (+100 lines)
Lines 133-136 Link Here
133
		assertEquals("Wrong contents", expectedOutput, result);
133
		assertEquals("Wrong contents", expectedOutput, result);
134
	}
134
	}
135
}
135
}
136
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258950
137
public void test003() throws Exception {
138
	this.runConformTest(
139
		new String[] {
140
			"X.java",
141
			"import java.util.List;\n" +
142
			"import java.util.ArrayList;\n" +
143
			"import java.util.Iterator;\n" +
144
			"public class X {\n" +
145
			"	public static void main(String[] args) {\n" +
146
			"		List l = new ArrayList();\n" +
147
			"		List l2 = new ArrayList();\n" +
148
			"		l.add(new X());\n" +
149
			"		for (Iterator iterator = l.iterator(); iterator.hasNext() ;) {\n" +
150
			"			l2.add(((X) iterator.next()).toString()\n" + 
151
			"				.substring(3));\n" +
152
			"		}\n" + 
153
			"		for (Iterator iterator = l2.iterator(); iterator.hasNext() ;) {\n" +
154
			"			System.out.println(iterator.next());\n" +
155
			"		}\n" + 
156
			"	}" +
157
			"	public String toString() {\n" +
158
			"		return \"NO_SUCCESS\";\n" +
159
			"	}\n" +
160
			"}",
161
		},
162
		"SUCCESS");
163
164
	String expectedOutput =
165
		"  // Method descriptor #15 ([Ljava/lang/String;)V\n" + 
166
		"  // Stack: 3, Locals: 4\n" + 
167
		"  public static void main(java.lang.String[] args);\n" + 
168
		"      0  new java.util.ArrayList [16]\n" + 
169
		"      3  dup\n" + 
170
		"      4  invokespecial java.util.ArrayList() [18]\n" + 
171
		"      7  astore_1 [l]\n" + 
172
		"      8  new java.util.ArrayList [16]\n" + 
173
		"     11  dup\n" + 
174
		"     12  invokespecial java.util.ArrayList() [18]\n" + 
175
		"     15  astore_2 [l2]\n" + 
176
		"     16  aload_1 [l]\n" + 
177
		"     17  new X [1]\n" + 
178
		"     20  dup\n" + 
179
		"     21  invokespecial X() [19]\n" + 
180
		"     24  invokeinterface java.util.List.add(java.lang.Object) : boolean [20] [nargs: 2]\n" + 
181
		"     29  pop\n" + 
182
		"     30  aload_1 [l]\n" + 
183
		"     31  invokeinterface java.util.List.iterator() : java.util.Iterator [26] [nargs: 1]\n" + 
184
		"     36  astore_3 [iterator]\n" + 
185
		"     37  goto 63\n" + 
186
		"     40  aload_2 [l2]\n" + 
187
		"     41  aload_3 [iterator]\n" + 
188
		"     42  invokeinterface java.util.Iterator.next() : java.lang.Object [30] [nargs: 1]\n" + 
189
		"     47  checkcast X [1]\n" + 
190
		"     50  invokevirtual X.toString() : java.lang.String [36]\n" + 
191
		"     53  iconst_3\n" + 
192
		"     54  invokevirtual java.lang.String.substring(int) : java.lang.String [40]\n" + 
193
		"     57  invokeinterface java.util.List.add(java.lang.Object) : boolean [20] [nargs: 2]\n" + 
194
		"     62  pop\n" + 
195
		"     63  aload_3 [iterator]\n" + 
196
		"     64  invokeinterface java.util.Iterator.hasNext() : boolean [46] [nargs: 1]\n" + 
197
		"     69  ifne 40\n" + 
198
		"     72  aload_2 [l2]\n" + 
199
		"     73  invokeinterface java.util.List.iterator() : java.util.Iterator [26] [nargs: 1]\n" + 
200
		"     78  astore_3 [iterator]\n" + 
201
		"     79  goto 94\n" + 
202
		"     82  getstatic java.lang.System.out : java.io.PrintStream [50]\n" + 
203
		"     85  aload_3 [iterator]\n" + 
204
		"     86  invokeinterface java.util.Iterator.next() : java.lang.Object [30] [nargs: 1]\n" + 
205
		"     91  invokevirtual java.io.PrintStream.println(java.lang.Object) : void [56]\n" + 
206
		"     94  aload_3 [iterator]\n" + 
207
		"     95  invokeinterface java.util.Iterator.hasNext() : boolean [46] [nargs: 1]\n" + 
208
		"    100  ifne 82\n" + 
209
		"    103  return\n" + 
210
		"      Line numbers:\n" + 
211
		"        [pc: 0, line: 6]\n" + 
212
		"        [pc: 8, line: 7]\n" + 
213
		"        [pc: 16, line: 8]\n" + 
214
		"        [pc: 30, line: 9]\n" + 
215
		"        [pc: 40, line: 10]\n" + 
216
		"        [pc: 53, line: 11]\n" + 
217
		"        [pc: 57, line: 10]\n" + 
218
		"        [pc: 63, line: 9]\n" + 
219
		"        [pc: 72, line: 13]\n" + 
220
		"        [pc: 82, line: 14]\n" + 
221
		"        [pc: 94, line: 13]\n" + 
222
		"        [pc: 103, line: 16]\n";
223
224
	File f = new File(OUTPUT_DIR + File.separator + "X.class");
225
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
226
	ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
227
	String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
228
	int index = result.indexOf(expectedOutput);
229
	if (index == -1 || expectedOutput.length() == 0) {
230
		System.out.println(Util.displayString(result, 3));
231
	}
232
	if (index == -1) {
233
		assertEquals("Wrong contents", expectedOutput, result);
234
	}
235
}
136
}
236
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-2 / +1 lines)
Lines 140-150 Link Here
140
			codeStream.checkcast(this.actualReceiverType);
140
			codeStream.checkcast(this.actualReceiverType);
141
		}
141
		}
142
		codeStream.recordPositionsFrom(pc, this.sourceStart);
142
		codeStream.recordPositionsFrom(pc, this.sourceStart);
143
144
	}
143
	}
145
	// generate arguments
144
	// generate arguments
146
	generateArguments(this.binding, this.arguments, currentScope, codeStream);
145
	generateArguments(this.binding, this.arguments, currentScope, codeStream);
147
146
	pc = codeStream.position;
148
	// actual message invocation
147
	// actual message invocation
149
	if (this.syntheticAccessor == null){
148
	if (this.syntheticAccessor == null){
150
		TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());
149
		TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());

Return to bug 259129