Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f72261c2770870fbc338f1ea989c83a9130e1e0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/*******************************************************************************
 * Copyright (c) 2009, 2011 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Stephan Herrmann - Contribution for Bug 343713 - [compiler] bogus line number in constructor of inner class in 1.5 compliance
 *******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;

import java.io.File;

import junit.framework.Test;

public class InnerEmulationTest_1_5 extends AbstractRegressionTest {
static {
//		TESTS_NAMES = new String[] { "Bug58069" };
//		TESTS_NUMBERS = new int[] { 13 };
//		TESTS_RANGE = new int[] { 144, -1 };
}
public InnerEmulationTest_1_5(String name) {
	super(name);
}
public static Test suite() {
	return buildMinimalComplianceTestSuite(testClass(), F_1_5);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test1() throws Exception {
	this.runConformTest(new String[] {
		"X.java",
		"import java.util.Collection;\n" +
		"import java.util.Map;\n" +
		"public class X {\n" +
		"	public void foo(Collection<? extends Map.Entry> args) { /* dummy */ }\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #25 java/util/Map$Entry, outer class info: #27 java/util/Map\n" + 
		"     inner name: #29 Entry, accessflags: 1545 public abstract static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test2() throws Exception {
	this.runConformTest(new String[] {
		"p/X.java",
		"package p;\n" +
		"import java.util.Collection;\n" +
		"import java.util.Map;\n" +
		"public class X {\n" +
		"	public void foo(Map.Entry args) { /* dummy */ }\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
		"     inner name: #25 Entry, accessflags: 1545 public abstract static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test3() throws Exception {
	this.runConformTest(new String[] {
		"X.java",
		"import java.util.Map;\n" + 
		"import java.util.List;\n" + 
		"public class X {\n" + 
		"	<U extends List<?>, T extends Map.Entry> X(List<U> lu, T t) {\n" + 
		"	}\n" + 
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #27 java/util/Map$Entry, outer class info: #29 java/util/Map\n" + 
		"     inner name: #31 Entry, accessflags: 1545 public abstract static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test4() throws Exception {
	this.runConformTest(new String[] {
		"X.java",
		"import java.util.Map;\n" + 
		"import java.util.List;\n" + 
		"public class X<T extends Object & Comparable<? super Map.Entry>> {}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
		"     inner name: #25 Entry, accessflags: 1545 public abstract static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test5() throws Exception {
	this.runConformTest(new String[] {
		"p/X.java",
		"package p;\n" +
		"import java.util.Collection;\n" +
		"import java.util.Map;\n" +
		"public class X {\n" +
		"	public void foo(Map.Entry<String, String> args) { /* dummy */ }\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #25 java/util/Map$Entry, outer class info: #27 java/util/Map\n" + 
		"     inner name: #29 Entry, accessflags: 1545 public abstract static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test6() throws Exception {
	this.runConformTest(new String[] {
		"p/X.java",
		"package p;\n" +
		"import java.util.Collection;\n" +
		"import java.util.Map;\n" +
		"public class X {\n" +
		"	Map.Entry<String, String> f;\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
		"     inner name: #25 Entry, accessflags: 1545 public abstract static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test7() throws Exception {
	this.runConformTest(new String[] {
		"p/X.java",
		"package p;\n" +
		"import java.util.Collection;\n" +
		"import java.util.Map;\n" +
		"public class X<E extends Object & Map.Entry<String, E>> {\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
		"     inner name: #25 Entry, accessflags: 1545 public abstract static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test8() throws Exception {
	this.runConformTest(new String[] {
		"p/X.java",
		"package p;\n" +
		"import java.util.Collection;\n" +
		"import java.util.Map;\n" +
		"class A {\n" +
		"	static class B{}\n" +
		"}\n" +
		"public class X<E extends Object & Map.Entry<E, A.B>> {\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
		"     inner name: #25 Entry, accessflags: 1545 public abstract static],\n" + 
		"    [inner class info: #26 p/A$B, outer class info: #28 p/A\n" + 
		"     inner name: #30 B, accessflags: 8 static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test9() throws Exception {
	this.runConformTest(new String[] {
		"p/X.java",
		"package p;\n" +
		"import java.util.Collection;\n" +
		"import java.util.Map;\n" +
		"class A {\n" +
		"	static class B{}\n" +
		"}\n" +
		"public class X {\n" +
		"	<E extends Object & Map.Entry<E, A.B>> void foo(E e) {}\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #25 java/util/Map$Entry, outer class info: #27 java/util/Map\n" + 
		"     inner name: #29 Entry, accessflags: 1545 public abstract static],\n" + 
		"    [inner class info: #30 p/A$B, outer class info: #32 p/A\n" + 
		"     inner name: #34 B, accessflags: 8 static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test10() throws Exception {
	this.runConformTest(new String[] {
		"p/X.java",
		"package p;\n" +
		"import java.util.Collection;\n" +
		"import java.util.Map;\n" +
		"class A {\n" +
		"	static interface B<U, T>{}\n" +
		"}\n" +
		"class C {\n" +
		"	static class D<U, T>{}\n" +
		"}\n" +
		"public class X {\n" +
		"	<E extends Object & A.B<E, Map.Entry<E, C.D>>> void foo(E e) {}\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #25 java/util/Map$Entry, outer class info: #27 java/util/Map\n" + 
		"     inner name: #29 Entry, accessflags: 1545 public abstract static],\n" + 
		"    [inner class info: #30 p/A$B, outer class info: #32 p/A\n" + 
		"     inner name: #34 B, accessflags: 1544 abstract static],\n" + 
		"    [inner class info: #35 p/C$D, outer class info: #37 p/C\n" + 
		"     inner name: #39 D, accessflags: 8 static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test11() throws Exception {
	this.runConformTest(new String[] {
		"X.java",
		"import java.util.*;\n" +
		"\n" +
		" public class X {\n" +
		" \n" +
		"	static abstract class SelfType<T extends SelfType<T>>{\n" +
		"	}\n" +
		" \n" +
		"	static class SuperType extends SelfType<SuperType>{\n" +
		"	}\n" +
		" \n" +
		"	static class SubType extends SuperType{}\n" +
		" \n" +
		"	static <T extends SelfType<T>> List<T> makeSingletonList(T t){\n" +
		"		return Collections.singletonList(t);\n" +
		"	}\n" +
		" \n" +
		"	static <T extends SelfType<T>,S extends T> List<T> makeSingletonList2(S s){\n" +
		"		return Collections.singletonList((T)s); // #0\n" +
		"	}\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #35 X$SelfType, outer class info: #1 X\n" + 
		"     inner name: #37 SelfType, accessflags: 1032 abstract static],\n" + 
		"    [inner class info: #38 X$SubType, outer class info: #1 X\n" + 
		"     inner name: #40 SubType, accessflags: 8 static],\n" + 
		"    [inner class info: #41 X$SuperType, outer class info: #1 X\n" + 
		"     inner name: #43 SuperType, accessflags: 8 static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test12() throws Exception {
	this.runConformTest(new String[] {
		"p/X.java",
		"package p;\n" +
		"import java.util.Collection;\n" +
		"import java.util.Map;\n" +
		"public class X {\n" +
		"	Collection<Map.Entry> field;\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
		"     inner name: #25 Entry, accessflags: 1545 public abstract static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test13() throws Exception {
	this.runConformTest(new String[] {
		"p/X.java",
		"package p;\n" +
		"import java.util.Collection;\n" +
		"import java.util.Map;\n" +
		"class A {\n" +
		"	static interface B<U, T>{}\n" +
		"}\n" +
		"class C {\n" +
		"	static class D<U, T>{}\n" +
		"}\n" +
		"public class X extends C.D implements A.B {\n" +
		"}"
	});
	String expectedOutput =
		"  Inner classes:\n" + 
		"    [inner class info: #5 p/A$B, outer class info: #19 p/A\n" + 
		"     inner name: #21 B, accessflags: 1544 abstract static],\n" + 
		"    [inner class info: #3 p/C$D, outer class info: #22 p/C\n" + 
		"     inner name: #24 D, accessflags: 8 static]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=343713
// [compiler] bogus line number in constructor of inner class in 1.5 compliance
public void test14() throws Exception {
	runConformTest(new String[] {
		"LineNumberBug.java",
		"public class LineNumberBug {\n" + 
		"    class Inner {\n" + 
		"		public Inner() {\n" + 
		"			System.out.println(\"Inner()\");\n" + 
		"		}\n" + 
		"    }\n" + 
		"	public static void main(String[] args) {\n" + 
		"		new LineNumberBug().new Inner();\n" + 
		"	}\n" + 
		"}\n"
	});
	String expectedOutput =
		"  // Method descriptor #8 (LLineNumberBug;)V\n" + 
		"  // Stack: 2, Locals: 2\n" + 
		"  public LineNumberBug$Inner(LineNumberBug arg0);\n" + 
		"     0  aload_0 [this]\n" + 
		"     1  aload_1 [arg0]\n" + 
		"     2  putfield LineNumberBug$Inner.this$0 : LineNumberBug [10]\n" + 
		"     5  aload_0 [this]\n" + 
		"     6  invokespecial java.lang.Object() [12]\n" + 
		"     9  getstatic java.lang.System.out : java.io.PrintStream [15]\n" + 
		"    12  ldc <String \"Inner()\"> [21]\n" + 
		"    14  invokevirtual java.io.PrintStream.println(java.lang.String) : void [23]\n" + 
		"    17  return\n" + 
		"      Line numbers:\n" + 
		"        [pc: 0, line: 3]\n" + 
		"        [pc: 9, line: 4]\n" +
		"        [pc: 17, line: 5]\n";
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "LineNumberBug$Inner.class", "LineNumberBug$Inner", expectedOutput);	
}
public static Class testClass() {
	return InnerEmulationTest_1_5.class;
}
}

Back to the top