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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java (+1 lines)
Lines 91-96 Link Here
91
	since_1_5.add(BatchCompilerTest.class);
91
	since_1_5.add(BatchCompilerTest.class);
92
	since_1_5.add(ExternalizeStringLiterals15Test.class);
92
	since_1_5.add(ExternalizeStringLiterals15Test.class);
93
	since_1_5.add(Deprecated15Test.class);
93
	since_1_5.add(Deprecated15Test.class);
94
	since_1_5.add(InnerEmulationTest_1_5.class);
94
95
95
	// Tests to run when compliance is greater than 1.5
96
	// Tests to run when compliance is greater than 1.5
96
	ArrayList since_1_6 = new ArrayList();
97
	ArrayList since_1_6 = new ArrayList();
(-)src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest_1_5.java (+251 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
import java.io.File;
14
15
import junit.framework.Test;
16
17
public class InnerEmulationTest_1_5 extends AbstractRegressionTest {
18
static {
19
//		TESTS_NAMES = new String[] { "Bug58069" };
20
//		TESTS_NUMBERS = new int[] { 12 };
21
//		TESTS_RANGE = new int[] { 144, -1 };
22
}
23
public InnerEmulationTest_1_5(String name) {
24
	super(name);
25
}
26
public static Test suite() {
27
	return buildMinimalComplianceTestSuite(testClass(), F_1_5);
28
}
29
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
30
public void test1() throws Exception {
31
	this.runConformTest(new String[] {
32
		"X.java",
33
		"import java.util.Collection;\n" +
34
		"import java.util.Map;\n" +
35
		"public class X {\n" +
36
		"	public void foo(Collection<? extends Map.Entry> args) { /* dummy */ }\n" +
37
		"}"
38
	});
39
	String expectedOutput =
40
		"  Inner classes:\n" + 
41
		"    [inner class info: #25 java/util/Map$Entry, outer class info: #27 java/util/Map\n" + 
42
		"     inner name: #29 Entry, accessflags: 1545 public abstract static]\n";
43
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
44
}
45
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
46
public void test2() throws Exception {
47
	this.runConformTest(new String[] {
48
		"p/X.java",
49
		"package p;\n" +
50
		"import java.util.Collection;\n" +
51
		"import java.util.Map;\n" +
52
		"public class X {\n" +
53
		"	public void foo(Map.Entry args) { /* dummy */ }\n" +
54
		"}"
55
	});
56
	String expectedOutput =
57
		"  Inner classes:\n" + 
58
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
59
		"     inner name: #25 Entry, accessflags: 1545 public abstract static]\n";
60
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
61
}
62
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
63
public void test3() throws Exception {
64
	this.runConformTest(new String[] {
65
		"X.java",
66
		"import java.util.Map;\n" + 
67
		"import java.util.List;\n" + 
68
		"public class X {\n" + 
69
		"	<U extends List<?>, T extends Map.Entry> X(List<U> lu, T t) {\n" + 
70
		"	}\n" + 
71
		"}"
72
	});
73
	String expectedOutput =
74
		"  Inner classes:\n" + 
75
		"    [inner class info: #27 java/util/Map$Entry, outer class info: #29 java/util/Map\n" + 
76
		"     inner name: #31 Entry, accessflags: 1545 public abstract static]\n";
77
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
78
}
79
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
80
public void test4() throws Exception {
81
	this.runConformTest(new String[] {
82
		"X.java",
83
		"import java.util.Map;\n" + 
84
		"import java.util.List;\n" + 
85
		"public class X<T extends Object & Comparable<? super Map.Entry>> {}"
86
	});
87
	String expectedOutput =
88
		"  Inner classes:\n" + 
89
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
90
		"     inner name: #25 Entry, accessflags: 1545 public abstract static]\n";
91
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
92
}
93
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
94
public void test5() throws Exception {
95
	this.runConformTest(new String[] {
96
		"p/X.java",
97
		"package p;\n" +
98
		"import java.util.Collection;\n" +
99
		"import java.util.Map;\n" +
100
		"public class X {\n" +
101
		"	public void foo(Map.Entry<String, String> args) { /* dummy */ }\n" +
102
		"}"
103
	});
104
	String expectedOutput =
105
		"  Inner classes:\n" + 
106
		"    [inner class info: #25 java/util/Map$Entry, outer class info: #27 java/util/Map\n" + 
107
		"     inner name: #29 Entry, accessflags: 1545 public abstract static]\n";
108
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
109
}
110
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
111
public void test6() throws Exception {
112
	this.runConformTest(new String[] {
113
		"p/X.java",
114
		"package p;\n" +
115
		"import java.util.Collection;\n" +
116
		"import java.util.Map;\n" +
117
		"public class X {\n" +
118
		"	Map.Entry<String, String> f;\n" +
119
		"}"
120
	});
121
	String expectedOutput =
122
		"  Inner classes:\n" + 
123
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
124
		"     inner name: #25 Entry, accessflags: 1545 public abstract static]\n";
125
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
126
}
127
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
128
public void test7() throws Exception {
129
	this.runConformTest(new String[] {
130
		"p/X.java",
131
		"package p;\n" +
132
		"import java.util.Collection;\n" +
133
		"import java.util.Map;\n" +
134
		"public class X<E extends Object & Map.Entry<String, E>> {\n" +
135
		"}"
136
	});
137
	String expectedOutput =
138
		"  Inner classes:\n" + 
139
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
140
		"     inner name: #25 Entry, accessflags: 1545 public abstract static]\n";
141
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
142
}
143
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
144
public void test8() throws Exception {
145
	this.runConformTest(new String[] {
146
		"p/X.java",
147
		"package p;\n" +
148
		"import java.util.Collection;\n" +
149
		"import java.util.Map;\n" +
150
		"class A {\n" +
151
		"	static class B{}\n" +
152
		"}\n" +
153
		"public class X<E extends Object & Map.Entry<E, A.B>> {\n" +
154
		"}"
155
	});
156
	String expectedOutput =
157
		"  Inner classes:\n" + 
158
		"    [inner class info: #21 java/util/Map$Entry, outer class info: #23 java/util/Map\n" + 
159
		"     inner name: #25 Entry, accessflags: 1545 public abstract static],\n" + 
160
		"    [inner class info: #26 p/A$B, outer class info: #28 p/A\n" + 
161
		"     inner name: #30 B, accessflags: 8 static]\n";
162
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
163
}
164
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
165
public void test9() throws Exception {
166
	this.runConformTest(new String[] {
167
		"p/X.java",
168
		"package p;\n" +
169
		"import java.util.Collection;\n" +
170
		"import java.util.Map;\n" +
171
		"class A {\n" +
172
		"	static class B{}\n" +
173
		"}\n" +
174
		"public class X {\n" +
175
		"	<E extends Object & Map.Entry<E, A.B>> void foo(E e) {}\n" +
176
		"}"
177
	});
178
	String expectedOutput =
179
		"  Inner classes:\n" + 
180
		"    [inner class info: #25 java/util/Map$Entry, outer class info: #27 java/util/Map\n" + 
181
		"     inner name: #29 Entry, accessflags: 1545 public abstract static],\n" + 
182
		"    [inner class info: #30 p/A$B, outer class info: #32 p/A\n" + 
183
		"     inner name: #34 B, accessflags: 8 static]\n";
184
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
185
}
186
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
187
public void test10() throws Exception {
188
	this.runConformTest(new String[] {
189
		"p/X.java",
190
		"package p;\n" +
191
		"import java.util.Collection;\n" +
192
		"import java.util.Map;\n" +
193
		"class A {\n" +
194
		"	static interface B<U, T>{}\n" +
195
		"}\n" +
196
		"class C {\n" +
197
		"	static class D<U, T>{}\n" +
198
		"}\n" +
199
		"public class X {\n" +
200
		"	<E extends Object & A.B<E, Map.Entry<E, C.D>>> void foo(E e) {}\n" +
201
		"}"
202
	});
203
	String expectedOutput =
204
		"  Inner classes:\n" + 
205
		"    [inner class info: #25 java/util/Map$Entry, outer class info: #27 java/util/Map\n" + 
206
		"     inner name: #29 Entry, accessflags: 1545 public abstract static],\n" + 
207
		"    [inner class info: #30 p/A$B, outer class info: #32 p/A\n" + 
208
		"     inner name: #34 B, accessflags: 1544 abstract static],\n" + 
209
		"    [inner class info: #35 p/C$D, outer class info: #37 p/C\n" + 
210
		"     inner name: #39 D, accessflags: 8 static]\n";
211
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "p" + File.separator + "X.class", "X", expectedOutput);
212
}
213
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
214
public void test11() throws Exception {
215
	this.runConformTest(new String[] {
216
		"X.java",
217
		"import java.util.*;\n" +
218
		"\n" +
219
		" public class X {\n" +
220
		" \n" +
221
		"	static abstract class SelfType<T extends SelfType<T>>{\n" +
222
		"	}\n" +
223
		" \n" +
224
		"	static class SuperType extends SelfType<SuperType>{\n" +
225
		"	}\n" +
226
		" \n" +
227
		"	static class SubType extends SuperType{}\n" +
228
		" \n" +
229
		"	static <T extends SelfType<T>> List<T> makeSingletonList(T t){\n" +
230
		"		return Collections.singletonList(t);\n" +
231
		"	}\n" +
232
		" \n" +
233
		"	static <T extends SelfType<T>,S extends T> List<T> makeSingletonList2(S s){\n" +
234
		"		return Collections.singletonList((T)s); // #0\n" +
235
		"	}\n" +
236
		"}"
237
	});
238
	String expectedOutput =
239
		"  Inner classes:\n" + 
240
		"    [inner class info: #35 X$SelfType, outer class info: #1 X\n" + 
241
		"     inner name: #37 SelfType, accessflags: 1032 abstract static],\n" + 
242
		"    [inner class info: #38 X$SubType, outer class info: #1 X\n" + 
243
		"     inner name: #40 SubType, accessflags: 8 static],\n" + 
244
		"    [inner class info: #41 X$SuperType, outer class info: #1 X\n" + 
245
		"     inner name: #43 SuperType, accessflags: 8 static]\n";
246
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
247
}
248
public static Class testClass() {
249
	return InnerEmulationTest_1_5.class;
250
}
251
}
(-)Eclipse Java Tests Runner/org/eclipse/jdt/core/tests/RunAllDisassemblerTests.java (+1 lines)
Lines 69-74 Link Here
69
		tests_1_5.add(ForeachStatementTest.class);
69
		tests_1_5.add(ForeachStatementTest.class);
70
		tests_1_5.add(GenericTypeTest.class);
70
		tests_1_5.add(GenericTypeTest.class);
71
		tests_1_5.add(MethodVerifyTest.class);
71
		tests_1_5.add(MethodVerifyTest.class);
72
		tests_1_5.add(InnerEmulationTest_1_5.class);
72
		all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_5, tests_1_5));
73
		all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_5, tests_1_5));
73
	}
74
	}
74
	if ((possibleComplianceLevels & AbstractCompilerTest.F_1_6) != 0) {
75
	if ((possibleComplianceLevels & AbstractCompilerTest.F_1_6) != 0) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java (-4 / +9 lines)
Lines 664-669 Link Here
664
						this.tagBits |= TagBits.HasDirectWildcard;
664
						this.tagBits |= TagBits.HasDirectWildcard;
665
						if (((WildcardBinding) someArgument).boundKind != Wildcard.UNBOUND) {
665
						if (((WildcardBinding) someArgument).boundKind != Wildcard.UNBOUND) {
666
							this.tagBits |= TagBits.IsBoundParameterizedType;
666
							this.tagBits |= TagBits.IsBoundParameterizedType;
667
							this.tagBits |= someArgument.tagBits & TagBits.ContainsNestedTypes;
667
						}
668
						}
668
						break;
669
						break;
669
					case Binding.INTERSECTION_TYPE :
670
					case Binding.INTERSECTION_TYPE :
Lines 673-682 Link Here
673
						this.tagBits |= TagBits.IsBoundParameterizedType;
674
						this.tagBits |= TagBits.IsBoundParameterizedType;
674
						break;
675
						break;
675
				}
676
				}
676
			    this.tagBits |= someArgument.tagBits & (TagBits.HasTypeVariable | TagBits.HasMissingType);
677
				this.tagBits |= someArgument.tagBits & (TagBits.HasTypeVariable | TagBits.HasMissingType);
677
			}
678
			}
678
		}
679
		}
679
		this.tagBits |= someType.tagBits & (TagBits.IsLocalType| TagBits.IsMemberType | TagBits.IsNestedType | TagBits.HasMissingType);
680
		this.tagBits |= someType.tagBits & (TagBits.IsLocalType| TagBits.IsMemberType | TagBits.IsNestedType | TagBits.HasMissingType | TagBits.ContainsNestedTypes);
680
		this.tagBits &= ~(TagBits.AreFieldsComplete|TagBits.AreMethodsComplete);
681
		this.tagBits &= ~(TagBits.AreFieldsComplete|TagBits.AreMethodsComplete);
681
	}
682
	}
682
683
Lines 845-854 Link Here
845
846
846
		this.tagBits &= ~TagBits.HasUnresolvedTypeVariables; // can be recursive so only want to call once
847
		this.tagBits &= ~TagBits.HasUnresolvedTypeVariables; // can be recursive so only want to call once
847
		ReferenceBinding resolvedType = (ReferenceBinding) BinaryTypeBinding.resolveType(this.type, this.environment, false /* no raw conversion */); // still part of parameterized type ref
848
		ReferenceBinding resolvedType = (ReferenceBinding) BinaryTypeBinding.resolveType(this.type, this.environment, false /* no raw conversion */); // still part of parameterized type ref
849
		this.tagBits |= resolvedType.tagBits & TagBits.ContainsNestedTypes;
848
		if (this.arguments != null) {
850
		if (this.arguments != null) {
849
			int argLength = this.arguments.length;
851
			int argLength = this.arguments.length;
850
			for (int i = 0; i < argLength; i++)
852
			for (int i = 0; i < argLength; i++) {
851
				this.arguments[i] = BinaryTypeBinding.resolveType(this.arguments[i], this.environment, true /* raw conversion */);
853
				TypeBinding resolveType = BinaryTypeBinding.resolveType(this.arguments[i], this.environment, true /* raw conversion */);
854
				this.arguments[i] = resolveType;
855
				this.tagBits |= resolvedType.tagBits & TagBits.ContainsNestedTypes;
856
			}
852
			// arity check
857
			// arity check
853
			TypeVariableBinding[] refTypeVariables = resolvedType.typeVariables();
858
			TypeVariableBinding[] refTypeVariables = resolvedType.typeVariables();
854
			if (refTypeVariables == Binding.NO_TYPE_VARIABLES) { // check generic
859
			if (refTypeVariables == Binding.NO_TYPE_VARIABLES) { // check generic
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (+2 lines)
Lines 621-626 Link Here
621
					} else {
621
					} else {
622
						typeVariable.superInterfaces = new ReferenceBinding[] {superRefType};
622
						typeVariable.superInterfaces = new ReferenceBinding[] {superRefType};
623
					}
623
					}
624
					typeVariable.tagBits |= superType.tagBits & TagBits.ContainsNestedTypes;
624
					typeVariable.firstBound = superRefType; // first bound used to compute erasure
625
					typeVariable.firstBound = superRefType; // first bound used to compute erasure
625
				}
626
				}
626
			}
627
			}
Lines 635-640 Link Here
635
						typeVariable.tagBits |= TagBits.HierarchyHasProblems;
636
						typeVariable.tagBits |= TagBits.HierarchyHasProblems;
636
						continue nextBound;
637
						continue nextBound;
637
					} else {
638
					} else {
639
						typeVariable.tagBits |= superType.tagBits & TagBits.ContainsNestedTypes;
638
						boolean didAlreadyComplain = !typeRef.resolvedType.isValidBinding();
640
						boolean didAlreadyComplain = !typeRef.resolvedType.isValidBinding();
639
						if (isFirstBoundTypeVariable && j == 0) {
641
						if (isFirstBoundTypeVariable && j == 0) {
640
							problemReporter().noAdditionalBoundAfterTypeVariable(typeRef);
642
							problemReporter().noAdditionalBoundAfterTypeVariable(typeRef);
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java (-3 / +8 lines)
Lines 398-411 Link Here
398
			return this;
398
			return this;
399
399
400
		TypeBinding oldSuperclass = this.superclass, oldFirstInterface = null;
400
		TypeBinding oldSuperclass = this.superclass, oldFirstInterface = null;
401
		if (this.superclass != null)
401
		if (this.superclass != null) {
402
			this.superclass = (ReferenceBinding) BinaryTypeBinding.resolveType(this.superclass, this.environment, true /* raw conversion */);
402
			ReferenceBinding resolveType = (ReferenceBinding) BinaryTypeBinding.resolveType(this.superclass, this.environment, true /* raw conversion */);
403
			this.tagBits |= resolveType.tagBits & TagBits.ContainsNestedTypes;
404
			this.superclass = resolveType;
405
		}
403
		ReferenceBinding[] interfaces = this.superInterfaces;
406
		ReferenceBinding[] interfaces = this.superInterfaces;
404
		int length;
407
		int length;
405
		if ((length = interfaces.length) != 0) {
408
		if ((length = interfaces.length) != 0) {
406
			oldFirstInterface = interfaces[0];
409
			oldFirstInterface = interfaces[0];
407
			for (int i = length; --i >= 0;) {
410
			for (int i = length; --i >= 0;) {
408
				interfaces[i] = (ReferenceBinding) BinaryTypeBinding.resolveType(interfaces[i], this.environment, true /* raw conversion */);
411
				ReferenceBinding resolveType = (ReferenceBinding) BinaryTypeBinding.resolveType(interfaces[i], this.environment, true /* raw conversion */);
412
				this.tagBits |= resolveType.tagBits & TagBits.ContainsNestedTypes;
413
				interfaces[i] = resolveType;
409
			}
414
			}
410
		}
415
		}
411
		// refresh the firstBound in case it changed
416
		// refresh the firstBound in case it changed
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java (-1 / +1 lines)
Lines 35-41 Link Here
35
	if (type instanceof UnresolvedReferenceBinding)
35
	if (type instanceof UnresolvedReferenceBinding)
36
		((UnresolvedReferenceBinding) type).addWrapper(this, environment);
36
		((UnresolvedReferenceBinding) type).addWrapper(this, environment);
37
	else
37
	else
38
    	this.tagBits |= type.tagBits & (TagBits.HasTypeVariable | TagBits.HasDirectWildcard | TagBits.HasMissingType);
38
		this.tagBits |= type.tagBits & (TagBits.HasTypeVariable | TagBits.HasDirectWildcard | TagBits.HasMissingType | TagBits.ContainsNestedTypes);
39
}
39
}
40
40
41
public TypeBinding closestMatch() {
41
public TypeBinding closestMatch() {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java (-23 / +87 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.lookup;
11
package org.eclipse.jdt.internal.compiler.lookup;
12
12
13
import java.util.HashSet;
13
import java.util.List;
14
import java.util.List;
15
import java.util.Set;
14
16
15
import org.eclipse.jdt.core.compiler.CharOperation;
17
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.internal.compiler.ClassFile;
18
import org.eclipse.jdt.internal.compiler.ClassFile;
Lines 962-968 Link Here
962
 */
964
 */
963
public final char[] signature(ClassFile classFile) {
965
public final char[] signature(ClassFile classFile) {
964
	if (this.signature != null) {
966
	if (this.signature != null) {
965
		if ((this.tagBits & TagBits.ContainsNestedTypesInSignature) != 0) {
967
		if ((this.tagBits & TagBits.ContainsNestedTypes) != 0) {
966
			// we need to record inner classes references
968
			// we need to record inner classes references
967
			boolean isConstructor = isConstructor();
969
			boolean isConstructor = isConstructor();
968
			TypeBinding[] targetParameters = this.parameters;
970
			TypeBinding[] targetParameters = this.parameters;
Lines 973-980 Link Here
973
				if (syntheticArgumentTypes != null) {
975
				if (syntheticArgumentTypes != null) {
974
					for (int i = 0, count = syntheticArgumentTypes.length; i < count; i++) {
976
					for (int i = 0, count = syntheticArgumentTypes.length; i < count; i++) {
975
						ReferenceBinding syntheticArgumentType = syntheticArgumentTypes[i];
977
						ReferenceBinding syntheticArgumentType = syntheticArgumentTypes[i];
976
						if (syntheticArgumentType.isNestedType()) {
978
						if ((syntheticArgumentType.tagBits & TagBits.ContainsNestedTypes) != 0) {
977
							classFile.recordInnerClasses(syntheticArgumentType);
979
							recordNestedType(classFile, syntheticArgumentType, null);
978
						}
980
						}
979
					}
981
					}
980
				}
982
				}
Lines 984-994 Link Here
984
			}
986
			}
985
987
986
			if (targetParameters != Binding.NO_PARAMETERS) {
988
			if (targetParameters != Binding.NO_PARAMETERS) {
987
				for (int i = 0; i < targetParameters.length; i++) {
989
				for (int i = 0, max = targetParameters.length; i < max; i++) {
988
					TypeBinding targetParameter = targetParameters[i];
990
					TypeBinding targetParameter = targetParameters[i];
989
					TypeBinding leafTargetParameterType = targetParameter.leafComponentType();
991
					TypeBinding leafTargetParameterType = targetParameter.leafComponentType();
990
					if (leafTargetParameterType.isNestedType()) {
992
					if ((leafTargetParameterType.tagBits & TagBits.ContainsNestedTypes) != 0) {
991
						classFile.recordInnerClasses(leafTargetParameterType);
993
						recordNestedType(classFile, leafTargetParameterType, null);
992
					}
994
					}
993
				}
995
				}
994
			}
996
			}
Lines 997-1011 Link Here
997
				for (int i = targetParameters.length, extraLength = this.parameters.length; i < extraLength; i++) {
999
				for (int i = targetParameters.length, extraLength = this.parameters.length; i < extraLength; i++) {
998
					TypeBinding parameter = this.parameters[i];
1000
					TypeBinding parameter = this.parameters[i];
999
					TypeBinding leafParameterType = parameter.leafComponentType();
1001
					TypeBinding leafParameterType = parameter.leafComponentType();
1000
					if (leafParameterType.isNestedType()) {
1002
					if ((leafParameterType.tagBits & TagBits.ContainsNestedTypes) != 0) {
1001
						classFile.recordInnerClasses(leafParameterType);
1003
						recordNestedType(classFile, leafParameterType, null);
1002
					}
1004
					}
1003
				}
1005
				}
1004
			}
1006
			}
1005
			if (this.returnType != null) {
1007
			if (this.returnType != null) {
1006
				TypeBinding ret = this.returnType.leafComponentType();
1008
				TypeBinding ret = this.returnType.leafComponentType();
1007
				if (ret.isNestedType()) {
1009
				if ((ret.tagBits & TagBits.ContainsNestedTypes) != 0) {
1008
					classFile.recordInnerClasses(ret);
1010
					recordNestedType(classFile, ret, null);
1009
				}
1011
				}
1010
			}
1012
			}
1011
		}
1013
		}
Lines 1028-1036 Link Here
1028
		if (syntheticArgumentTypes != null) {
1030
		if (syntheticArgumentTypes != null) {
1029
			for (int i = 0, count = syntheticArgumentTypes.length; i < count; i++) {
1031
			for (int i = 0, count = syntheticArgumentTypes.length; i < count; i++) {
1030
				ReferenceBinding syntheticArgumentType = syntheticArgumentTypes[i];
1032
				ReferenceBinding syntheticArgumentType = syntheticArgumentTypes[i];
1031
				if (syntheticArgumentType.isNestedType()) {
1033
				if ((syntheticArgumentType.tagBits & TagBits.ContainsNestedTypes) != 0) {
1032
					this.tagBits |= TagBits.ContainsNestedTypesInSignature;
1034
					recordNestedType(classFile, syntheticArgumentType, null);
1033
					classFile.recordInnerClasses(syntheticArgumentType);
1034
				}
1035
				}
1035
				buffer.append(syntheticArgumentType.signature());
1036
				buffer.append(syntheticArgumentType.signature());
1036
			}
1037
			}
Lines 1042-1053 Link Here
1042
	}
1043
	}
1043
1044
1044
	if (targetParameters != Binding.NO_PARAMETERS) {
1045
	if (targetParameters != Binding.NO_PARAMETERS) {
1045
		for (int i = 0; i < targetParameters.length; i++) {
1046
		for (int i = 0, max = targetParameters.length; i < max; i++) {
1046
			TypeBinding targetParameter = targetParameters[i];
1047
			TypeBinding targetParameter = targetParameters[i];
1047
			TypeBinding leafTargetParameterType = targetParameter.leafComponentType();
1048
			TypeBinding leafTargetParameterType = targetParameter.leafComponentType();
1048
			if (leafTargetParameterType.isNestedType()) {
1049
			if ((leafTargetParameterType.tagBits & TagBits.ContainsNestedTypes) != 0) {
1049
				this.tagBits |= TagBits.ContainsNestedTypesInSignature;
1050
				recordNestedType(classFile, leafTargetParameterType, null);
1050
				classFile.recordInnerClasses(leafTargetParameterType);
1051
			}
1051
			}
1052
			buffer.append(targetParameter.signature());
1052
			buffer.append(targetParameter.signature());
1053
		}
1053
		}
Lines 1062-1070 Link Here
1062
		for (int i = targetParameters.length, extraLength = this.parameters.length; i < extraLength; i++) {
1062
		for (int i = targetParameters.length, extraLength = this.parameters.length; i < extraLength; i++) {
1063
			TypeBinding parameter = this.parameters[i];
1063
			TypeBinding parameter = this.parameters[i];
1064
			TypeBinding leafParameterType = parameter.leafComponentType();
1064
			TypeBinding leafParameterType = parameter.leafComponentType();
1065
			if (leafParameterType.isNestedType()) {
1065
			if ((leafParameterType.tagBits & TagBits.ContainsNestedTypes) != 0) {
1066
				this.tagBits |= TagBits.ContainsNestedTypesInSignature;
1066
				recordNestedType(classFile, leafParameterType, null);
1067
				classFile.recordInnerClasses(leafParameterType);
1068
			}
1067
			}
1069
			buffer.append(parameter.signature());
1068
			buffer.append(parameter.signature());
1070
		}
1069
		}
Lines 1072-1080 Link Here
1072
	buffer.append(')');
1071
	buffer.append(')');
1073
	if (this.returnType != null) {
1072
	if (this.returnType != null) {
1074
		TypeBinding ret = this.returnType.leafComponentType();
1073
		TypeBinding ret = this.returnType.leafComponentType();
1075
		if (ret.isNestedType()) {
1074
		if ((ret.tagBits & TagBits.ContainsNestedTypes) != 0) {
1076
			this.tagBits |= TagBits.ContainsNestedTypesInSignature;
1075
			recordNestedType(classFile, ret, null);
1077
			classFile.recordInnerClasses(ret);
1078
		}
1076
		}
1079
		buffer.append(this.returnType.signature());
1077
		buffer.append(this.returnType.signature());
1080
	}
1078
	}
Lines 1084-1089 Link Here
1084
1082
1085
	return this.signature;
1083
	return this.signature;
1086
}
1084
}
1085
private void recordNestedType(ClassFile classFile, TypeBinding typeBinding, Set visitedTypeVariables) {
1086
	if (typeBinding.isParameterizedType()
1087
			&& ((typeBinding.tagBits & TagBits.ContainsNestedTypes) != 0)) {
1088
		ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) typeBinding;
1089
		ReferenceBinding genericType = parameterizedTypeBinding.genericType();
1090
		if ((genericType.tagBits & TagBits.ContainsNestedTypes) != 0) {
1091
			recordNestedType(classFile, genericType, visitedTypeVariables);
1092
		}
1093
		TypeBinding[] arguments = parameterizedTypeBinding.arguments;
1094
		if (arguments != null) {
1095
			for (int j = 0, max2 = arguments.length; j < max2; j++) {
1096
				TypeBinding argument = arguments[j];
1097
				if (argument.isWildcard()) {
1098
					WildcardBinding wildcardBinding = (WildcardBinding) argument;
1099
					TypeBinding bound = wildcardBinding.bound;
1100
					if (bound != null
1101
							&& ((bound.tagBits & TagBits.ContainsNestedTypes) != 0)) {
1102
						recordNestedType(classFile, bound, visitedTypeVariables);
1103
					}
1104
					ReferenceBinding superclass = wildcardBinding.superclass();
1105
					if (superclass != null
1106
							&& ((superclass.tagBits & TagBits.ContainsNestedTypes) != 0)) {
1107
						recordNestedType(classFile, superclass, visitedTypeVariables);
1108
					}
1109
					ReferenceBinding[] superInterfaces = wildcardBinding.superInterfaces();
1110
					if (superInterfaces != null) {
1111
						for (int k = 0, max3 =  superInterfaces.length; k < max3; k++) {
1112
							ReferenceBinding superInterface = superInterfaces[k];
1113
							if ((superInterface.tagBits & TagBits.ContainsNestedTypes) != 0) {
1114
								recordNestedType(classFile, superInterface, visitedTypeVariables);
1115
							}
1116
						}
1117
					}
1118
				} else if ((argument.tagBits & TagBits.ContainsNestedTypes) != 0) {
1119
					recordNestedType(classFile, argument, visitedTypeVariables);
1120
				}
1121
			}
1122
		}
1123
	} else if (typeBinding.isTypeVariable()
1124
			&& ((typeBinding.tagBits & TagBits.ContainsNestedTypes) != 0)) {
1125
		if (visitedTypeVariables == null) {
1126
			visitedTypeVariables = new HashSet(3);
1127
		} else if (visitedTypeVariables.contains(typeBinding)) {
1128
			// type is already visited
1129
			return;
1130
		}
1131
		visitedTypeVariables.add(typeBinding);
1132
		TypeVariableBinding typeVariableBinding = (TypeVariableBinding) typeBinding;
1133
		TypeBinding upperBound = typeVariableBinding.upperBound();
1134
		if (upperBound != null && ((upperBound.tagBits & TagBits.ContainsNestedTypes) != 0)) {
1135
			recordNestedType(classFile, upperBound, visitedTypeVariables);
1136
		}
1137
		TypeBinding[] upperBounds = typeVariableBinding.otherUpperBounds();
1138
		if (upperBounds != null) {
1139
			for (int k = 0, max3 = upperBounds.length; k < max3; k++) {
1140
				TypeBinding otherUpperBound = upperBounds[k];
1141
				if ((otherUpperBound.tagBits & TagBits.ContainsNestedTypes) != 0) {
1142
					recordNestedType(classFile, otherUpperBound, visitedTypeVariables);
1143
				}
1144
			}
1145
		}
1146
	} else if (typeBinding.isNestedType()) {
1147
		this.tagBits |= TagBits.ContainsNestedTypes;
1148
		classFile.recordInnerClasses(typeBinding);
1149
	}
1150
}
1087
public final int sourceEnd() {
1151
public final int sourceEnd() {
1088
	AbstractMethodDeclaration method = sourceMethod();
1152
	AbstractMethodDeclaration method = sourceMethod();
1089
	if (method == null) {
1153
	if (method == null) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java (-1 / +1 lines)
Lines 21-27 Link Here
21
21
22
public NestedTypeBinding(char[][] typeName, ClassScope scope, SourceTypeBinding enclosingType) {
22
public NestedTypeBinding(char[][] typeName, ClassScope scope, SourceTypeBinding enclosingType) {
23
	super(typeName, enclosingType.fPackage, scope);
23
	super(typeName, enclosingType.fPackage, scope);
24
	this.tagBits |= TagBits.IsNestedType;
24
	this.tagBits |= (TagBits.IsNestedType | TagBits.ContainsNestedTypes);
25
	this.enclosingType = enclosingType;
25
	this.enclosingType = enclosingType;
26
}
26
}
27
27
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java (-4 / +5 lines)
Lines 19-29 Link Here
19
	long IsBaseType = ASTNode.Bit2;
19
	long IsBaseType = ASTNode.Bit2;
20
	long IsNestedType = ASTNode.Bit3;
20
	long IsNestedType = ASTNode.Bit3;
21
	long IsMemberType = ASTNode.Bit4;
21
	long IsMemberType = ASTNode.Bit4;
22
	long MemberTypeMask = IsNestedType | IsMemberType;
22
	long ContainsNestedTypes = ASTNode.Bit12; // method/parameterized type binding
23
	long MemberTypeMask = IsNestedType | IsMemberType | ContainsNestedTypes;
23
	long IsLocalType = ASTNode.Bit5;
24
	long IsLocalType = ASTNode.Bit5;
24
	long LocalTypeMask = IsNestedType | IsLocalType;
25
	long LocalTypeMask = IsNestedType | IsLocalType | ContainsNestedTypes;
25
	long IsAnonymousType = ASTNode.Bit6;
26
	long IsAnonymousType = ASTNode.Bit6;
26
	long AnonymousTypeMask = LocalTypeMask | IsAnonymousType;
27
	long AnonymousTypeMask = LocalTypeMask | IsAnonymousType | ContainsNestedTypes;
27
	long IsBinaryBinding = ASTNode.Bit7;
28
	long IsBinaryBinding = ASTNode.Bit7;
28
29
29
	// set for all bindings either represeting a missing type (type), or directly referencing a missing type (field/method/variable)
30
	// set for all bindings either represeting a missing type (type), or directly referencing a missing type (field/method/variable)
Lines 35-43 Link Here
35
	// for the type cycle hierarchy check used by ClassScope
36
	// for the type cycle hierarchy check used by ClassScope
36
	long BeginHierarchyCheck = ASTNode.Bit9;  // type
37
	long BeginHierarchyCheck = ASTNode.Bit9;  // type
37
	long EndHierarchyCheck = ASTNode.Bit10; // type
38
	long EndHierarchyCheck = ASTNode.Bit10; // type
38
	long ContainsNestedTypesInSignature = ASTNode.Bit10; // method
39
	long HasParameterAnnotations = ASTNode.Bit11; // method
39
	long HasParameterAnnotations = ASTNode.Bit11; // method
40
40
41
41
	// test bit to see if default abstract methods were computed
42
	// test bit to see if default abstract methods were computed
42
	long KnowsDefaultAbstractMethods = ASTNode.Bit11; // type
43
	long KnowsDefaultAbstractMethods = ASTNode.Bit11; // type
43
44
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java (-12 / +30 lines)
Lines 39-45 Link Here
39
	 */
39
	 */
40
	public WildcardBinding(ReferenceBinding genericType, int rank, TypeBinding bound, TypeBinding[] otherBounds, int boundKind, LookupEnvironment environment) {
40
	public WildcardBinding(ReferenceBinding genericType, int rank, TypeBinding bound, TypeBinding[] otherBounds, int boundKind, LookupEnvironment environment) {
41
		this.rank = rank;
41
		this.rank = rank;
42
	    this.boundKind = boundKind;
42
		this.boundKind = boundKind;
43
		this.modifiers = ClassFileConstants.AccPublic | ExtraCompilerModifiers.AccGenericSignature; // treat wildcard as public
43
		this.modifiers = ClassFileConstants.AccPublic | ExtraCompilerModifiers.AccGenericSignature; // treat wildcard as public
44
		this.environment = environment;
44
		this.environment = environment;
45
		initialize(genericType, bound, otherBounds);
45
		initialize(genericType, bound, otherBounds);
Lines 53-59 Link Here
53
			((UnresolvedReferenceBinding) genericType).addWrapper(this, environment);
53
			((UnresolvedReferenceBinding) genericType).addWrapper(this, environment);
54
		if (bound instanceof UnresolvedReferenceBinding)
54
		if (bound instanceof UnresolvedReferenceBinding)
55
			((UnresolvedReferenceBinding) bound).addWrapper(this, environment);
55
			((UnresolvedReferenceBinding) bound).addWrapper(this, environment);
56
		this.tagBits |=  TagBits.HasUnresolvedTypeVariables; // cleared in resolve()
56
		this.tagBits |= TagBits.HasUnresolvedTypeVariables; // cleared in resolve()
57
	}
57
	}
58
58
59
	public int kind() {
59
	public int kind() {
Lines 425-431 Link Here
425
			this.fPackage = someGenericType.getPackage();
425
			this.fPackage = someGenericType.getPackage();
426
		}
426
		}
427
		if (someBound != null) {
427
		if (someBound != null) {
428
			this.tagBits |= someBound.tagBits & (TagBits.HasTypeVariable | TagBits.HasMissingType);
428
			this.tagBits |= someBound.tagBits & (TagBits.HasTypeVariable | TagBits.HasMissingType | TagBits.ContainsNestedTypes);
429
		}
430
		if (someOtherBounds != null) {
431
			for (int i = 0, max = someOtherBounds.length; i < max; i++) {
432
				TypeBinding someOtherBound = someOtherBounds[i];
433
				this.tagBits |= someOtherBound.tagBits & TagBits.ContainsNestedTypes;
434
			}
429
		}
435
		}
430
	}
436
	}
431
437
Lines 494-511 Link Here
494
500
495
		this.tagBits &= ~TagBits.HasUnresolvedTypeVariables;
501
		this.tagBits &= ~TagBits.HasUnresolvedTypeVariables;
496
		BinaryTypeBinding.resolveType(this.genericType, this.environment, false /* no raw conversion */);
502
		BinaryTypeBinding.resolveType(this.genericType, this.environment, false /* no raw conversion */);
497
	    switch(this.boundKind) {
503
		switch(this.boundKind) {
498
	        case Wildcard.EXTENDS :
504
			case Wildcard.EXTENDS :
499
				this.bound = BinaryTypeBinding.resolveType(this.bound, this.environment, true /* raw conversion */);
505
				TypeBinding resolveType = BinaryTypeBinding.resolveType(this.bound, this.environment, true /* raw conversion */);
500
	        	for (int i = 0, length = this.otherBounds == null ? 0 : this.otherBounds.length; i < length; i++) {
506
				this.bound = resolveType;
501
					this.otherBounds[i]= BinaryTypeBinding.resolveType(this.bound, this.environment, true /* raw conversion */);
507
				if (resolveType.isNestedType() || ((resolveType.tagBits & TagBits.ContainsNestedTypes) != 0)) {
502
	        	}
508
					this.tagBits |= TagBits.ContainsNestedTypes;
509
				}
510
				for (int i = 0, length = this.otherBounds == null ? 0 : this.otherBounds.length; i < length; i++) {
511
					resolveType = BinaryTypeBinding.resolveType(this.otherBounds[i], this.environment, true /* raw conversion */);
512
					this.otherBounds[i]= resolveType;
513
					if (resolveType.isNestedType() || ((resolveType.tagBits & TagBits.ContainsNestedTypes) != 0)) {
514
						this.tagBits |= TagBits.ContainsNestedTypes;
515
					}
516
				}
503
				break;
517
				break;
504
	        case Wildcard.SUPER :
518
			case Wildcard.SUPER :
505
				this.bound = BinaryTypeBinding.resolveType(this.bound, this.environment, true /* raw conversion */);
519
				resolveType = BinaryTypeBinding.resolveType(this.bound, this.environment, true /* raw conversion */);
520
				this.bound = resolveType;
521
				if (resolveType.isNestedType() || ((resolveType.tagBits & TagBits.ContainsNestedTypes) != 0)) {
522
					this.tagBits |= TagBits.ContainsNestedTypes;
523
				}
506
				break;
524
				break;
507
			case Wildcard.UNBOUND :
525
			case Wildcard.UNBOUND :
508
	    }
526
		}
509
		return this;
527
		return this;
510
	}
528
	}
511
529
(-)compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java (+7 lines)
Lines 516-521 Link Here
516
			enclosingClassFile.recordInnerClasses(this.binding);
516
			enclosingClassFile.recordInnerClasses(this.binding);
517
			classFile.recordInnerClasses(this.binding);
517
			classFile.recordInnerClasses(this.binding);
518
		}
518
		}
519
		TypeVariableBinding[] typeVariables = this.binding.typeVariables();
520
		for (int i = 0, max = typeVariables.length; i < max; i++) {
521
			TypeVariableBinding typeVariableBinding = typeVariables[i];
522
			if ((typeVariableBinding.tagBits & TagBits.ContainsNestedTypes) != 0) {
523
				Util.recordNestedType(classFile, typeVariableBinding, null);
524
			}
525
		}
519
526
520
		// generate all fiels
527
		// generate all fiels
521
		classFile.addFieldInfos();
528
		classFile.addFieldInfos();
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java (-16 / +16 lines)
Lines 163-194 Link Here
163
		}
163
		}
164
164
165
		// check generic and arity
165
		// check generic and arity
166
	    boolean isClassScope = scope.kind == Scope.CLASS_SCOPE;
166
		boolean isClassScope = scope.kind == Scope.CLASS_SCOPE;
167
	    TypeReference keep = null;
167
		TypeReference keep = null;
168
	    if (isClassScope) {
168
		if (isClassScope) {
169
	    	keep = ((ClassScope) scope).superTypeReference;
169
			keep = ((ClassScope) scope).superTypeReference;
170
	    	((ClassScope) scope).superTypeReference = null;
170
			((ClassScope) scope).superTypeReference = null;
171
	    }
171
		}
172
		int argLength = this.typeArguments.length;
172
		int argLength = this.typeArguments.length;
173
		TypeBinding[] argTypes = new TypeBinding[argLength];
173
		TypeBinding[] argTypes = new TypeBinding[argLength];
174
		boolean argHasError = false;
174
		boolean argHasError = false;
175
		ReferenceBinding currentOriginal = (ReferenceBinding)currentType.original();
175
		ReferenceBinding currentOriginal = (ReferenceBinding)currentType.original();
176
		for (int i = 0; i < argLength; i++) {
176
		for (int i = 0; i < argLength; i++) {
177
		    TypeReference typeArgument = this.typeArguments[i];
177
			TypeReference typeArgument = this.typeArguments[i];
178
		    TypeBinding argType = isClassScope
178
			TypeBinding argType = isClassScope
179
				? typeArgument.resolveTypeArgument((ClassScope) scope, currentOriginal, i)
179
			? typeArgument.resolveTypeArgument((ClassScope) scope, currentOriginal, i)
180
				: typeArgument.resolveTypeArgument((BlockScope) scope, currentOriginal, i);
180
					: typeArgument.resolveTypeArgument((BlockScope) scope, currentOriginal, i);
181
		     if (argType == null) {
181
			if (argType == null) {
182
		         argHasError = true;
182
				argHasError = true;
183
		     } else {
183
			} else {
184
			    argTypes[i] = argType;
184
				argTypes[i] = argType;
185
		     }
185
			}
186
		}
186
		}
187
		if (argHasError) {
187
		if (argHasError) {
188
			return null;
188
			return null;
189
		}
189
		}
190
		if (isClassScope) {
190
		if (isClassScope) {
191
	    	((ClassScope) scope).superTypeReference = keep;
191
			((ClassScope) scope).superTypeReference = keep;
192
			if (((ClassScope) scope).detectHierarchyCycle(currentOriginal, this))
192
			if (((ClassScope) scope).detectHierarchyCycle(currentOriginal, this))
193
				return null;
193
				return null;
194
		}
194
		}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java (-10 / +10 lines)
Lines 198-217 Link Here
198
			}
198
			}
199
199
200
			// check generic and arity
200
			// check generic and arity
201
		    TypeReference[] args = this.typeArguments[i];
201
			TypeReference[] args = this.typeArguments[i];
202
		    if (args != null) {
202
			if (args != null) {
203
			    TypeReference keep = null;
203
				TypeReference keep = null;
204
			    if (isClassScope) {
204
				if (isClassScope) {
205
			    	keep = ((ClassScope) scope).superTypeReference;
205
					keep = ((ClassScope) scope).superTypeReference;
206
			    	((ClassScope) scope).superTypeReference = null;
206
					((ClassScope) scope).superTypeReference = null;
207
			    }
207
				}
208
				int argLength = args.length;
208
				int argLength = args.length;
209
				TypeBinding[] argTypes = new TypeBinding[argLength];
209
				TypeBinding[] argTypes = new TypeBinding[argLength];
210
				boolean argHasError = false;
210
				boolean argHasError = false;
211
				ReferenceBinding currentOriginal = (ReferenceBinding)currentType.original();
211
				ReferenceBinding currentOriginal = (ReferenceBinding)currentType.original();
212
				for (int j = 0; j < argLength; j++) {
212
				for (int j = 0; j < argLength; j++) {
213
				    TypeReference arg = args[j];
213
					TypeReference arg = args[j];
214
				    TypeBinding argType = isClassScope
214
					TypeBinding argType = isClassScope
215
						? arg.resolveTypeArgument((ClassScope) scope, currentOriginal, j)
215
						? arg.resolveTypeArgument((ClassScope) scope, currentOriginal, j)
216
						: arg.resolveTypeArgument((BlockScope) scope, currentOriginal, j);
216
						: arg.resolveTypeArgument((BlockScope) scope, currentOriginal, j);
217
					if (argType == null) {
217
					if (argType == null) {
Lines 229-235 Link Here
229
						return null;
229
						return null;
230
				}
230
				}
231
231
232
			    TypeVariableBinding[] typeVariables = currentOriginal.typeVariables();
232
				TypeVariableBinding[] typeVariables = currentOriginal.typeVariables();
233
				if (typeVariables == Binding.NO_TYPE_VARIABLES) { // check generic
233
				if (typeVariables == Binding.NO_TYPE_VARIABLES) { // check generic
234
					if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // below 1.5, already reported as syntax error
234
					if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // below 1.5, already reported as syntax error
235
						scope.problemReporter().nonGenericTypeCannotBeParameterized(i, this, currentType, argTypes);
235
						scope.problemReporter().nonGenericTypeCannotBeParameterized(i, this, currentType, argTypes);
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-50 / +50 lines)
Lines 1217-1224 Link Here
1217
1217
1218
public void fieldAccess(byte opcode, FieldBinding fieldBinding, TypeBinding declaringClass) {
1218
public void fieldAccess(byte opcode, FieldBinding fieldBinding, TypeBinding declaringClass) {
1219
	if (declaringClass == null) declaringClass = fieldBinding.declaringClass;
1219
	if (declaringClass == null) declaringClass = fieldBinding.declaringClass;
1220
	if (declaringClass.leafComponentType().isNestedType()) {
1220
	if ((declaringClass.tagBits & TagBits.ContainsNestedTypes) != 0) {
1221
		this.classFile.recordInnerClasses(declaringClass);
1221
		Util.recordNestedType(this.classFile, declaringClass, null);
1222
	}
1222
	}
1223
	TypeBinding returnType = fieldBinding.type;
1223
	TypeBinding returnType = fieldBinding.type;
1224
	int returnTypeSize;
1224
	int returnTypeSize;
Lines 3835-3886 Link Here
3835
3835
3836
public void invoke(byte opcode, MethodBinding methodBinding, TypeBinding declaringClass) {
3836
public void invoke(byte opcode, MethodBinding methodBinding, TypeBinding declaringClass) {
3837
	if (declaringClass == null) declaringClass = methodBinding.declaringClass;
3837
	if (declaringClass == null) declaringClass = methodBinding.declaringClass;
3838
    if (declaringClass.isNestedType()) {
3838
	if ((declaringClass.tagBits & TagBits.ContainsNestedTypes) != 0) {
3839
        this.classFile.recordInnerClasses(declaringClass);
3839
		Util.recordNestedType(this.classFile, declaringClass, null);
3840
    }
3840
	}
3841
    // compute receiverAndArgsSize
3841
	// compute receiverAndArgsSize
3842
    int receiverAndArgsSize;
3842
	int receiverAndArgsSize;
3843
    switch(opcode) {
3843
	switch(opcode) {
3844
    	case Opcodes.OPC_invokestatic :
3844
		case Opcodes.OPC_invokestatic :
3845
    		receiverAndArgsSize = 0; // no receiver
3845
			receiverAndArgsSize = 0; // no receiver
3846
    		break;
3846
			break;
3847
    	case Opcodes.OPC_invokeinterface :
3847
		case Opcodes.OPC_invokeinterface :
3848
    	case Opcodes.OPC_invokevirtual :
3848
		case Opcodes.OPC_invokevirtual :
3849
    		receiverAndArgsSize = 1; // receiver
3849
			receiverAndArgsSize = 1; // receiver
3850
    		break;
3850
			break;
3851
    	case Opcodes.OPC_invokespecial :
3851
		case Opcodes.OPC_invokespecial :
3852
    		receiverAndArgsSize = 1; // receiver
3852
			receiverAndArgsSize = 1; // receiver
3853
    		if (methodBinding.isConstructor()) {
3853
			if (methodBinding.isConstructor()) {
3854
    			if (declaringClass.isNestedType()) {
3854
				if (declaringClass.isNestedType()) {
3855
        			ReferenceBinding nestedType = (ReferenceBinding) declaringClass;
3855
					ReferenceBinding nestedType = (ReferenceBinding) declaringClass;
3856
    				// enclosing instances
3856
					// enclosing instances
3857
        			receiverAndArgsSize += nestedType.getEnclosingInstancesSlotSize();
3857
					receiverAndArgsSize += nestedType.getEnclosingInstancesSlotSize();
3858
    				// outer local variables
3858
					// outer local variables
3859
    				SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
3859
					SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
3860
    				if (syntheticArguments != null) {
3860
					if (syntheticArguments != null) {
3861
    					for (int i = 0, max = syntheticArguments.length; i < max; i++) {
3861
						for (int i = 0, max = syntheticArguments.length; i < max; i++) {
3862
    						switch (syntheticArguments[i].id)  {
3862
							switch (syntheticArguments[i].id)  {
3863
    							case TypeIds.T_double :
3863
								case TypeIds.T_double :
3864
    							case TypeIds.T_long :
3864
								case TypeIds.T_long :
3865
	    							receiverAndArgsSize += 2;
3865
									receiverAndArgsSize += 2;
3866
									break;
3866
									break;
3867
    							default: 
3867
								default: 
3868
	    							receiverAndArgsSize++;
3868
									receiverAndArgsSize++;
3869
    								break;
3869
									break;
3870
    						}    						
3870
							}    						
3871
    					}
3871
						}
3872
    				}
3872
					}
3873
    			}
3873
				}
3874
    			if (declaringClass.isEnum()) {
3874
				if (declaringClass.isEnum()) {
3875
    				// adding String (name) and int (ordinal)
3875
					// adding String (name) and int (ordinal)
3876
    				receiverAndArgsSize += 2;
3876
					receiverAndArgsSize += 2;
3877
    			}
3877
				}
3878
    		}    		
3878
			}    		
3879
    		break;
3879
			break;
3880
    	default :
3880
		default :
3881
    		return; // should not occur
3881
			return; // should not occur
3882
    		
3882
3883
    }
3883
	}
3884
	for (int i = methodBinding.parameters.length - 1; i >= 0; i--) {
3884
	for (int i = methodBinding.parameters.length - 1; i >= 0; i--) {
3885
		switch (methodBinding.parameters[i].id) {
3885
		switch (methodBinding.parameters[i].id) {
3886
			case TypeIds.T_double :
3886
			case TypeIds.T_double :
Lines 3993-4001 Link Here
3993
3993
3994
public void invokeIterableIterator(TypeBinding iterableReceiverType) {
3994
public void invokeIterableIterator(TypeBinding iterableReceiverType) {
3995
	// invokevirtual/interface: <iterableReceiverType>.iterator()
3995
	// invokevirtual/interface: <iterableReceiverType>.iterator()
3996
    if (iterableReceiverType.isNestedType()) {
3996
	if ((iterableReceiverType.tagBits & TagBits.ContainsNestedTypes) != 0) {
3997
        this.classFile.recordInnerClasses(iterableReceiverType);
3997
		Util.recordNestedType(this.classFile, iterableReceiverType, null);
3998
    }	
3998
	}
3999
	invoke(
3999
	invoke(
4000
			iterableReceiverType.isInterface() ? Opcodes.OPC_invokeinterface : Opcodes.OPC_invokevirtual,
4000
			iterableReceiverType.isInterface() ? Opcodes.OPC_invokeinterface : Opcodes.OPC_invokevirtual,
4001
			1, // receiverAndArgsSize
4001
			1, // receiverAndArgsSize
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java (-14 / +16 lines)
Lines 13-22 Link Here
13
import org.eclipse.jdt.core.compiler.CharOperation;
13
import org.eclipse.jdt.core.compiler.CharOperation;
14
import org.eclipse.jdt.internal.compiler.ClassFile;
14
import org.eclipse.jdt.internal.compiler.ClassFile;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
16
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
17
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
17
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
18
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
18
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
19
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
19
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
20
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
21
import org.eclipse.jdt.internal.compiler.util.Util;
20
/**
22
/**
21
 * This type is used to store all the constant pool entries.
23
 * This type is used to store all the constant pool entries.
22
 */
24
 */
Lines 297-307 Link Here
297
    return index;
299
    return index;
298
}
300
}
299
public int literalIndex(TypeBinding binding) {
301
public int literalIndex(TypeBinding binding) {
300
    TypeBinding typeBinding = binding.leafComponentType();
302
	TypeBinding typeBinding = binding.leafComponentType();
301
    if (typeBinding.isNestedType()) {
303
	if ((typeBinding.tagBits & TagBits.ContainsNestedTypes) != 0) {
302
        this.classFile.recordInnerClasses(typeBinding);
304
		Util.recordNestedType(this.classFile, typeBinding, null);
303
    }
305
	}
304
    return literalIndex(binding.signature());
306
	return literalIndex(binding.signature());
305
}
307
}
306
/**
308
/**
307
 * This method returns the index into the constantPool corresponding to the type descriptor.
309
 * This method returns the index into the constantPool corresponding to the type descriptor.
Lines 647-657 Link Here
647
 * binding must not be an array type.
649
 * binding must not be an array type.
648
 */
650
 */
649
public int literalIndexForType(final TypeBinding binding) {
651
public int literalIndexForType(final TypeBinding binding) {
650
    TypeBinding typeBinding = binding.leafComponentType();
652
	TypeBinding typeBinding = binding.leafComponentType();
651
    if (typeBinding.isNestedType()) {
653
	if ((typeBinding.tagBits & TagBits.ContainsNestedTypes) != 0) {
652
        this.classFile.recordInnerClasses(typeBinding);
654
		Util.recordNestedType(this.classFile, typeBinding, null);
653
    }
655
	}
654
    return this.literalIndexForType(binding.constantPoolName());
656
	return this.literalIndexForType(binding.constantPoolName());
655
}
657
}
656
public int literalIndexForMethod(char[] declaringClass, char[] selector, char[] signature, boolean isInterface) {
658
public int literalIndexForMethod(char[] declaringClass, char[] selector, char[] signature, boolean isInterface) {
657
    int index;
659
    int index;
Lines 688-697 Link Here
688
    return index;
690
    return index;
689
}
691
}
690
public int literalIndexForMethod(TypeBinding declaringClass, char[] selector, char[] signature, boolean isInterface) {
692
public int literalIndexForMethod(TypeBinding declaringClass, char[] selector, char[] signature, boolean isInterface) {
691
    if (declaringClass.isNestedType()) {
693
	if ((declaringClass.tagBits & TagBits.ContainsNestedTypes) != 0) {
692
        this.classFile.recordInnerClasses(declaringClass);
694
		Util.recordNestedType(this.classFile, declaringClass, null);
693
    }
695
	}
694
    return this.literalIndexForMethod(declaringClass.constantPoolName(), selector, signature, isInterface);
696
	return this.literalIndexForMethod(declaringClass.constantPoolName(), selector, signature, isInterface);
695
}
697
}
696
public int literalIndexForNameAndType(char[] name, char[] signature) {
698
public int literalIndexForNameAndType(char[] name, char[] signature) {
697
    int index;
699
    int index;
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetTypeDeclaration.java (-1 / +10 lines)
Lines 14-20 Link Here
14
import org.eclipse.jdt.internal.compiler.CompilationResult;
14
import org.eclipse.jdt.internal.compiler.CompilationResult;
15
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
15
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
16
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
16
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
17
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
18
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
17
import org.eclipse.jdt.internal.compiler.problem.AbortType;
19
import org.eclipse.jdt.internal.compiler.problem.AbortType;
20
import org.eclipse.jdt.internal.compiler.util.Util;
18
21
19
public class CodeSnippetTypeDeclaration extends TypeDeclaration {
22
public class CodeSnippetTypeDeclaration extends TypeDeclaration {
20
23
Lines 46-52 Link Here
46
			enclosingClassFile.recordInnerClasses(this.binding);
49
			enclosingClassFile.recordInnerClasses(this.binding);
47
			classFile.recordInnerClasses(this.binding);
50
			classFile.recordInnerClasses(this.binding);
48
		}
51
		}
49
52
		TypeVariableBinding[] typeVariables = this.binding.typeVariables();
53
		for (int i = 0, max = typeVariables.length; i < max; i++) {
54
			TypeVariableBinding typeVariableBinding = typeVariables[i];
55
			if ((typeVariableBinding.tagBits & TagBits.ContainsNestedTypes) != 0) {
56
				Util.recordNestedType(classFile, typeVariableBinding, null);
57
			}
58
		}
50
		if (this.memberTypes != null) {
59
		if (this.memberTypes != null) {
51
			for (int i = 0, max = this.memberTypes.length; i < max; i++) {
60
			for (int i = 0, max = this.memberTypes.length; i < max; i++) {
52
				TypeDeclaration memberType = this.memberTypes[i];
61
				TypeDeclaration memberType = this.memberTypes[i];
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java (+10 lines)
Lines 24-29 Link Here
24
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
24
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
25
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
25
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
28
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
29
import org.eclipse.jdt.internal.compiler.util.Util;
27
30
28
public class CodeSnippetClassFile extends ClassFile {
31
public class CodeSnippetClassFile extends ClassFile {
29
/**
32
/**
Lines 144-149 Link Here
144
	if (typeBinding.isNestedType()) {
147
	if (typeBinding.isNestedType()) {
145
		classFile.recordInnerClasses(typeBinding);
148
		classFile.recordInnerClasses(typeBinding);
146
	}
149
	}
150
	TypeVariableBinding[] typeVariables = typeBinding.typeVariables();
151
	for (int i = 0, max = typeVariables.length; i < max; i++) {
152
		TypeVariableBinding typeVariableBinding = typeVariables[i];
153
		if ((typeVariableBinding.tagBits & TagBits.ContainsNestedTypes) != 0) {
154
			Util.recordNestedType(classFile, typeVariableBinding, null);
155
		}
156
	}
147
157
148
	// add its fields
158
	// add its fields
149
	FieldBinding[] fields = typeBinding.fields();
159
	FieldBinding[] fields = typeBinding.fields();
(-)compiler/org/eclipse/jdt/internal/compiler/util/Util.java (-1 / +74 lines)
Lines 23-28 Link Here
23
import java.io.PrintWriter;
23
import java.io.PrintWriter;
24
import java.io.StringWriter;
24
import java.io.StringWriter;
25
import java.io.UnsupportedEncodingException;
25
import java.io.UnsupportedEncodingException;
26
import java.util.HashSet;
27
import java.util.Set;
26
import java.util.StringTokenizer;
28
import java.util.StringTokenizer;
27
import java.util.zip.ZipEntry;
29
import java.util.zip.ZipEntry;
28
import java.util.zip.ZipFile;
30
import java.util.zip.ZipFile;
Lines 32-37 Link Here
32
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
34
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
33
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
35
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
34
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
36
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
37
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
38
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
39
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
40
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
41
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
42
import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
35
43
36
public class Util implements SuffixConstants {
44
public class Util implements SuffixConstants {
37
45
Lines 810-813 Link Here
810
			output.close();
818
			output.close();
811
		}
819
		}
812
	}
820
	}
813
}
821
	public static void recordNestedType(ClassFile classFile, TypeBinding typeBinding, Set visitedTypeVariables) {
822
		if (typeBinding.isParameterizedType()
823
				&& ((typeBinding.tagBits & TagBits.ContainsNestedTypes) != 0)) {
824
			ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) typeBinding;
825
			ReferenceBinding genericType = parameterizedTypeBinding.genericType();
826
			if ((genericType.tagBits & TagBits.ContainsNestedTypes) != 0) {
827
				recordNestedType(classFile, genericType, visitedTypeVariables);
828
			}
829
			TypeBinding[] arguments = parameterizedTypeBinding.arguments;
830
			if (arguments != null) {
831
				for (int j = 0, max2 = arguments.length; j < max2; j++) {
832
					TypeBinding argument = arguments[j];
833
					if (argument.isWildcard()) {
834
						WildcardBinding wildcardBinding = (WildcardBinding) argument;
835
						TypeBinding bound = wildcardBinding.bound;
836
						if (bound != null
837
								&& ((bound.tagBits & TagBits.ContainsNestedTypes) != 0)) {
838
							recordNestedType(classFile, bound, visitedTypeVariables);
839
						}
840
						ReferenceBinding superclass = wildcardBinding.superclass();
841
						if (superclass != null
842
								&& ((superclass.tagBits & TagBits.ContainsNestedTypes) != 0)) {
843
							recordNestedType(classFile, superclass, visitedTypeVariables);
844
						}
845
						ReferenceBinding[] superInterfaces = wildcardBinding.superInterfaces();
846
						if (superInterfaces != null) {
847
							for (int k = 0, max3 =  superInterfaces.length; k < max3; k++) {
848
								ReferenceBinding superInterface = superInterfaces[k];
849
								if ((superInterface.tagBits & TagBits.ContainsNestedTypes) != 0) {
850
									recordNestedType(classFile, superInterface, visitedTypeVariables);
851
								}
852
							}
853
						}
854
					} else if ((argument.tagBits & TagBits.ContainsNestedTypes) != 0) {
855
						recordNestedType(classFile, argument, visitedTypeVariables);
856
					}
857
				}
858
			}
859
		} else if (typeBinding.isTypeVariable()
860
				&& ((typeBinding.tagBits & TagBits.ContainsNestedTypes) != 0)) {
861
			if (visitedTypeVariables == null) {
862
				visitedTypeVariables = new HashSet(3);
863
			} else if (visitedTypeVariables.contains(typeBinding)) {
864
				// type is already visited
865
				return;
866
			}
867
			visitedTypeVariables.add(typeBinding);
868
			TypeVariableBinding typeVariableBinding = (TypeVariableBinding) typeBinding;
869
			TypeBinding upperBound = typeVariableBinding.upperBound();
870
			if (upperBound != null && ((upperBound.tagBits & TagBits.ContainsNestedTypes) != 0)) {
871
				recordNestedType(classFile, upperBound, visitedTypeVariables);
872
			}
873
			TypeBinding[] upperBounds = typeVariableBinding.otherUpperBounds();
874
			if (upperBounds != null) {
875
				for (int k = 0, max3 =  upperBounds.length; k < max3; k++) {
876
					TypeBinding otherUpperBound = upperBounds[k];
877
					if ((otherUpperBound.tagBits & TagBits.ContainsNestedTypes) != 0) {
878
						recordNestedType(classFile, otherUpperBound, visitedTypeVariables);
879
					}
880
				}
881
			}
882
		} else if (typeBinding.isNestedType()) {
883
			classFile.recordInnerClasses(typeBinding);
884
		}
885
	}
886
}
(-)compiler/org/eclipse/jdt/internal/compiler/ClassFile.java (-1 / +8 lines)
Lines 67-72 Link Here
67
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
67
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
68
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
68
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
69
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
69
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
70
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
70
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
71
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
71
import org.eclipse.jdt.internal.compiler.problem.ShouldNotImplement;
72
import org.eclipse.jdt.internal.compiler.problem.ShouldNotImplement;
72
import org.eclipse.jdt.internal.compiler.util.Messages;
73
import org.eclipse.jdt.internal.compiler.util.Messages;
Lines 151-157 Link Here
151
		if (typeBinding.isNestedType()) {
152
		if (typeBinding.isNestedType()) {
152
			classFile.recordInnerClasses(typeBinding);
153
			classFile.recordInnerClasses(typeBinding);
153
		}
154
		}
154
155
		TypeVariableBinding[] typeVariables = typeBinding.typeVariables();
156
		for (int i = 0, max = typeVariables.length; i < max; i++) {
157
			TypeVariableBinding typeVariableBinding = typeVariables[i];
158
			if ((typeVariableBinding.tagBits & TagBits.ContainsNestedTypes) != 0) {
159
				Util.recordNestedType(classFile, typeVariableBinding, null);
160
			}
161
		}
155
		// add its fields
162
		// add its fields
156
		FieldBinding[] fields = typeBinding.fields();
163
		FieldBinding[] fields = typeBinding.fields();
157
		if ((fields != null) && (fields != Binding.NO_FIELDS)) {
164
		if ((fields != null) && (fields != Binding.NO_FIELDS)) {

Return to bug 275381