View | Details | Raw Unified | Return to bug 235921
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java (+15 lines)
Lines 977-982 Link Here
977
	else buffer.append("interface "); //$NON-NLS-1$	
977
	else buffer.append("interface "); //$NON-NLS-1$	
978
	buffer.append((compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED TYPE"); //$NON-NLS-1$
978
	buffer.append((compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED TYPE"); //$NON-NLS-1$
979
979
980
	if (this.typeVariables == null) {
981
		buffer.append("<NULL TYPE VARIABLES>"); //$NON-NLS-1$
982
	} else if (this.typeVariables != Binding.NO_TYPE_VARIABLES) {
983
		buffer.append("<"); //$NON-NLS-1$
984
		for (int i = 0, length = this.typeVariables.length; i < length; i++) {
985
			if (i  > 0) buffer.append(", "); //$NON-NLS-1$
986
			if (this.typeVariables[i] == null) {
987
				buffer.append("NULL TYPE VARIABLE"); //$NON-NLS-1$
988
				continue;
989
			}
990
			char[] varChars = this.typeVariables[i].toString().toCharArray();
991
			buffer.append(varChars, 1, varChars.length - 2);
992
		}
993
		buffer.append(">"); //$NON-NLS-1$
994
	}
980
	buffer.append("\n\textends "); //$NON-NLS-1$
995
	buffer.append("\n\textends "); //$NON-NLS-1$
981
	buffer.append((superclass != null) ? superclass.debugName() : "NULL TYPE"); //$NON-NLS-1$
996
	buffer.append((superclass != null) ? superclass.debugName() : "NULL TYPE"); //$NON-NLS-1$
982
997
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (-4 / +8 lines)
Lines 1553-1563 Link Here
1553
	if (this.typeVariables == null) {
1553
	if (this.typeVariables == null) {
1554
		buffer.append("<NULL TYPE VARIABLES>"); //$NON-NLS-1$
1554
		buffer.append("<NULL TYPE VARIABLES>"); //$NON-NLS-1$
1555
	} else if (this.typeVariables != Binding.NO_TYPE_VARIABLES) {
1555
	} else if (this.typeVariables != Binding.NO_TYPE_VARIABLES) {
1556
		buffer.append("\n\t<"); //$NON-NLS-1$
1556
		buffer.append("<"); //$NON-NLS-1$
1557
		for (int i = 0, length = this.typeVariables.length; i < length; i++) {
1557
		for (int i = 0, length = this.typeVariables.length; i < length; i++) {
1558
			if (i  > 0)
1558
			if (i  > 0) buffer.append(", "); //$NON-NLS-1$
1559
				buffer.append(", "); //$NON-NLS-1$
1559
			if (this.typeVariables[i] == null) {
1560
			buffer.append((this.typeVariables[i] != null) ? this.typeVariables[i].toString() : "NULL TYPE VARIABLE"); //$NON-NLS-1$
1560
				buffer.append("NULL TYPE VARIABLE"); //$NON-NLS-1$
1561
				continue;
1562
			}
1563
			char[] varChars = this.typeVariables[i].toString().toCharArray();
1564
			buffer.append(varChars, 1, varChars.length - 2);
1561
		}
1565
		}
1562
		buffer.append(">"); //$NON-NLS-1$
1566
		buffer.append(">"); //$NON-NLS-1$
1563
	}
1567
	}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java (+4 lines)
Lines 89-94 Link Here
89
					return null;
89
					return null;
90
			ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
90
			ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
91
			if (qualifiedType != null) {
91
			if (qualifiedType != null) {
92
				ReferenceBinding enclosingType = currentType.enclosingType();
93
				if (enclosingType != null && enclosingType.erasure() != qualifiedType.erasure()) {
94
					qualifiedType = enclosingType; // inherited member type, leave it associated with its enclosing rather than subtype
95
				}
92
				boolean rawQualified;
96
				boolean rawQualified;
93
				if (currentType.isGenericType()) {
97
				if (currentType.isGenericType()) {
94
					qualifiedType = scope.environment().createRawType(currentType, qualifiedType);
98
					qualifiedType = scope.environment().createRawType(currentType, qualifiedType);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java (+5 lines)
Lines 127-132 Link Here
127
			}
127
			}
128
			if (isTypeUseDeprecated(this.resolvedType, scope))
128
			if (isTypeUseDeprecated(this.resolvedType, scope))
129
				scope.problemReporter().deprecatedType(this.resolvedType, this);
129
				scope.problemReporter().deprecatedType(this.resolvedType, this);
130
			ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
131
			ReferenceBinding currentEnclosing = currentType.enclosingType();
132
			if (currentEnclosing != null && currentEnclosing.erasure() != enclosingType.erasure()) {
133
				enclosingType = currentEnclosing; // inherited member type, leave it associated with its enclosing rather than subtype
134
			}			
130
		}
135
		}
131
136
132
		// check generic and arity
137
		// check generic and arity
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java (-8 / +12 lines)
Lines 173-186 Link Here
173
						? (ReferenceBinding) scope.environment().convertToRawType(qualifiedType)
173
						? (ReferenceBinding) scope.environment().convertToRawType(qualifiedType)
174
						: scope.environment().convertToParameterizedType(qualifiedType);
174
						: scope.environment().convertToParameterizedType(qualifiedType);
175
				}
175
				}
176
			}				
176
			} else {
177
			if (typeIsConsistent 
177
				if (typeIsConsistent 
178
					&& currentType.isStatic() 
178
						&& currentType.isStatic() 
179
					&& qualifiedType != null 
179
						&& ((qualifiedType.isParameterizedType() && ((ParameterizedTypeBinding)qualifiedType).arguments != null) || qualifiedType.isGenericType())) {
180
					&& ((qualifiedType.isParameterizedType() && ((ParameterizedTypeBinding)qualifiedType).arguments != null) || qualifiedType.isGenericType())) {
180
					scope.problemReporter().staticMemberOfParameterizedType(this, scope.environment().createParameterizedType(currentErasure, null, qualifiedType));
181
				scope.problemReporter().staticMemberOfParameterizedType(this, scope.environment().createParameterizedType(currentErasure, null, qualifiedType));
181
					typeIsConsistent = false;
182
				typeIsConsistent = false;
182
				}			
183
			}			
183
				ReferenceBinding enclosingType = currentType.enclosingType();
184
				if (enclosingType != null && enclosingType.erasure() != qualifiedType.erasure()) { // qualifier != declaring/enclosing
185
					qualifiedType = enclosingType; // inherited member type, leave it associated with its enclosing rather than subtype
186
				}
187
			}
184
			// check generic and arity
188
			// check generic and arity
185
		    TypeReference[] args = this.typeArguments[i];
189
		    TypeReference[] args = this.typeArguments[i];
186
		    if (args != null) {
190
		    if (args != null) {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (-5 / +270 lines)
Lines 1269-1279 Link Here
1269
			"	public class X <T extends M> extends Super {}\n" + 
1269
			"	public class X <T extends M> extends Super {}\n" + 
1270
			"	                          ^\n" + 
1270
			"	                          ^\n" + 
1271
			"M cannot be resolved to a type\n" + 
1271
			"M cannot be resolved to a type\n" + 
1272
			"----------\n" + 
1273
			"2. WARNING in X.java (at line 3)\n" + 
1274
			"	class Y <T extends Y.M> extends Super {}\n" + 
1275
			"	                   ^^^\n" + 
1276
			"Y.M is a raw type. References to generic type Super.M should be parameterized\n" + 
1277
			"----------\n");
1272
			"----------\n");
1278
	}
1273
	}
1279
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=98504
1274
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=98504
Lines 41441-41444 Link Here
41441
			"Type mismatch: cannot convert from Class<capture#2-of ? extends Object> to Exception\n" + 
41436
			"Type mismatch: cannot convert from Class<capture#2-of ? extends Object> to Exception\n" + 
41442
			"----------\n");
41437
			"----------\n");
41443
}
41438
}
41439
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=235837
41440
public void test1341() {
41441
	this.runNegativeTest(
41442
			new String[] {
41443
				"X.java", // =================
41444
				"import java.util.*;\n" + 
41445
				"public class X {\n" + 
41446
				"  void bar() {\n" + 
41447
				"    Integer i = 0;\n" + 
41448
				"    Double d = 0.0;\n" + 
41449
				"    foo((Collection<Number>) Arrays.asList(i, d));\n" + 
41450
				"  }\n" + 
41451
				"  void foo(Collection<Number> c) {}\n" + 
41452
				"}\n", // =================
41453
			},
41454
			"----------\n" + 
41455
			"1. ERROR in X.java (at line 6)\n" + 
41456
			"	foo((Collection<Number>) Arrays.asList(i, d));\n" + 
41457
			"	    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
41458
			"Cannot cast from List<Number&Comparable<?>> to Collection<Number>\n" + 
41459
			"----------\n" + 
41460
			"2. WARNING in X.java (at line 6)\n" + 
41461
			"	foo((Collection<Number>) Arrays.asList(i, d));\n" + 
41462
			"	                         ^^^^^^^^^^^^^^^^^^^\n" + 
41463
			"Type safety : A generic array of Number&Comparable<?> is created for a varargs parameter\n" + 
41464
			"----------\n");
41465
}
41466
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=235921 - variation
41467
public void test1342() throws Exception {
41468
	this.runConformTest(
41469
			new String[] {
41470
				"X.java", // =================
41471
				"import java.util.*;\n" + 
41472
				"interface Adapter<T> {\n" + 
41473
				"  interface Setter<V> {}\n" + 
41474
				"  public <V> Setter<V> makeSetter();\n" + 
41475
				"}\n" + 
41476
				"\n" + 
41477
				"public class X<T> implements Adapter<T> {\n" + 
41478
				"  public <V> X.Setter<V> makeSetter() {\n" + 
41479
				"    return new X.Setter<V>() {};\n" + 
41480
				"  }\n" + 
41481
				"  void foo() {\n" + 
41482
				"	  List<Adapter.Setter<T>> l = new ArrayList<X.Setter<T>>();\n" + 
41483
				"  }\n" + 
41484
				"}\n", // =================
41485
			},
41486
			"");
41487
	// check X$1
41488
	String expectedOutput =
41489
		"// Signature: Ljava/lang/Object;LAdapter$Setter<TV;>;\n" + 
41490
		"class X$1 implements Adapter$Setter {\n";
41491
	
41492
	File f = new File(OUTPUT_DIR + File.separator + "X$1.class");
41493
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
41494
	ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
41495
	String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
41496
	int index = result.indexOf(expectedOutput);
41497
	if (index == -1 || expectedOutput.length() == 0) {
41498
		System.out.println(Util.displayString(result, 3));
41499
	}
41500
	if (index == -1) {
41501
		assertEquals("Wrong contents", expectedOutput, result);
41502
	}
41503
	
41504
	// check X
41505
	expectedOutput =
41506
		"  // Signature: <V:Ljava/lang/Object;>()LAdapter$Setter<TV;>;\n" + 
41507
		"  // Stack: 3, Locals: 1\n" + 
41508
		"  public Adapter.Setter makeSetter();\n";
41509
	
41510
	f = new File(OUTPUT_DIR + File.separator + "X.class");
41511
	classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
41512
	disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
41513
	result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
41514
	index = result.indexOf(expectedOutput);
41515
	if (index == -1 || expectedOutput.length() == 0) {
41516
		System.out.println(Util.displayString(result, 3));
41517
	}
41518
	if (index == -1) {
41519
		assertEquals("Wrong contents", expectedOutput, result);
41520
	}	
41521
}
41522
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=235921 - variation
41523
public void test1343() throws Exception {
41524
	this.runConformTest(
41525
			new String[] {
41526
				"X.java", // =================
41527
				"import java.util.*;\n" + 
41528
				"class Adapter<T> {\n" + 
41529
				"  class Setter<V> {}\n" + 
41530
				"  public <V> Setter<V> makeSetter() { return null; }\n" + 
41531
				"}\n" + 
41532
				"\n" + 
41533
				"public class X<T> extends Adapter<T> {\n" + 
41534
				"  public <V> X<T>.Setter<V> makeSetter() {\n" + 
41535
				"    return new X<T>().new Setter<V>() {};\n" + 
41536
				"  }\n" + 
41537
				"  void foo() {\n" + 
41538
				"	  List<Adapter<T>.Setter<T>> l = new ArrayList<X<T>.Setter<T>>();\n" + 
41539
				"  }\n" + 
41540
				"}\n", // =================
41541
			},
41542
			"");
41543
}
41544
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=235921 - variation
41545
public void test1344() throws Exception {
41546
	this.runConformTest(
41547
			new String[] {
41548
				"X.java", // =================
41549
				"import java.util.*;\n" + 
41550
				"class Adapter<T> {\n" + 
41551
				"  class Setter<V> {}\n" + 
41552
				"  public <V> Setter<V> makeSetter() { return null; }\n" + 
41553
				"}\n" + 
41554
				"\n" + 
41555
				"public class X<T> extends Adapter {\n" + 
41556
				"  public <V> X.Setter makeSetter() {\n" + 
41557
				"    return new X().new Setter() {};\n" + 
41558
				"  }\n" + 
41559
				"  void foo() {\n" + 
41560
				"	  List<Adapter.Setter> l = new ArrayList<X.Setter>();\n" + 
41561
				"  }\n" + 
41562
				"}\n", // =================
41563
			},
41564
			"");
41565
}
41566
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=235921 - variation
41567
public void test1345() throws Exception {
41568
	this.runNegativeTest(
41569
			new String[] {
41570
				"X.java", // =================
41571
				"import java.util.*;\n" + 
41572
				"class Adapter<T> {\n" + 
41573
				"  class Setter<V> {}\n" + 
41574
				"  public <V> Setter<V> makeSetter() { return null; }\n" + 
41575
				"}\n" + 
41576
				"\n" + 
41577
				"public class X<T> extends Adapter {\n" + 
41578
				"  public <V> X.Setter makeSetter() {\n" + 
41579
				"    return (String) new X().new Setter() {};\n" + 
41580
				"  }\n" + 
41581
				"  void foo() {\n" + 
41582
				"          List<Adapter.Setter> l = new ArrayList<X.Setter>();\n" + 
41583
				"  }\n" + 
41584
				"}\n", // =================
41585
			},
41586
			"----------\n" + 
41587
			"1. WARNING in X.java (at line 7)\n" + 
41588
			"	public class X<T> extends Adapter {\n" + 
41589
			"	                          ^^^^^^^\n" + 
41590
			"Adapter is a raw type. References to generic type Adapter<T> should be parameterized\n" + 
41591
			"----------\n" + 
41592
			"2. WARNING in X.java (at line 8)\n" + 
41593
			"	public <V> X.Setter makeSetter() {\n" + 
41594
			"	           ^^^^^^^^\n" + 
41595
			"Adapter.Setter is a raw type. References to generic type Adapter<T>.Setter<V> should be parameterized\n" + 
41596
			"----------\n" + 
41597
			"3. WARNING in X.java (at line 8)\n" + 
41598
			"	public <V> X.Setter makeSetter() {\n" + 
41599
			"	                    ^^^^^^^^^^^^\n" + 
41600
			"The method makeSetter() of type X<T> should be tagged with @Override since it actually overrides a superclass method\n" + 
41601
			"----------\n" + 
41602
			"4. ERROR in X.java (at line 9)\n" + 
41603
			"	return (String) new X().new Setter() {};\n" + 
41604
			"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
41605
			"Cannot cast from new Adapter.Setter(){} to String\n" + 
41606
			"----------\n" + 
41607
			"5. ERROR in X.java (at line 9)\n" + 
41608
			"	return (String) new X().new Setter() {};\n" + 
41609
			"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
41610
			"Type mismatch: cannot convert from String to Adapter.Setter\n" + 
41611
			"----------\n" + 
41612
			"6. WARNING in X.java (at line 9)\n" + 
41613
			"	return (String) new X().new Setter() {};\n" + 
41614
			"	                    ^\n" + 
41615
			"X is a raw type. References to generic type X<T> should be parameterized\n" + 
41616
			"----------\n" + 
41617
			"7. WARNING in X.java (at line 9)\n" + 
41618
			"	return (String) new X().new Setter() {};\n" + 
41619
			"	                            ^^^^^^\n" + 
41620
			"Adapter.Setter is a raw type. References to generic type Adapter<T>.Setter<V> should be parameterized\n" + 
41621
			"----------\n" + 
41622
			"8. WARNING in X.java (at line 12)\n" + 
41623
			"	List<Adapter.Setter> l = new ArrayList<X.Setter>();\n" + 
41624
			"	     ^^^^^^^^^^^^^^\n" + 
41625
			"Adapter.Setter is a raw type. References to generic type Adapter<T>.Setter<V> should be parameterized\n" + 
41626
			"----------\n" + 
41627
			"9. WARNING in X.java (at line 12)\n" + 
41628
			"	List<Adapter.Setter> l = new ArrayList<X.Setter>();\n" + 
41629
			"	                                       ^^^^^^^^\n" + 
41630
			"Adapter.Setter is a raw type. References to generic type Adapter<T>.Setter<V> should be parameterized\n" + 
41631
			"----------\n");
41632
}
41633
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=235921 - variation
41634
public void test1346() throws Exception {
41635
	this.runNegativeTest(
41636
			new String[] {
41637
				"X.java", // =================
41638
				"import java.util.*;\n" + 
41639
				"class Adapter<T> {\n" + 
41640
				"  class Setter<V> {}\n" + 
41641
				"}\n" + 
41642
				"\n" + 
41643
				"public class X<T> extends Adapter {\n" + 
41644
				"  public <V> Adapter.Setter makeSetter() {\n" + 
41645
				"    return (X.Setter) \"a\";\n" + 
41646
				"  }\n" + 
41647
				"}\n", // =================
41648
			},
41649
			"----------\n" + 
41650
			"1. WARNING in X.java (at line 6)\n" + 
41651
			"	public class X<T> extends Adapter {\n" + 
41652
			"	                          ^^^^^^^\n" + 
41653
			"Adapter is a raw type. References to generic type Adapter<T> should be parameterized\n" + 
41654
			"----------\n" + 
41655
			"2. WARNING in X.java (at line 7)\n" + 
41656
			"	public <V> Adapter.Setter makeSetter() {\n" + 
41657
			"	           ^^^^^^^^^^^^^^\n" + 
41658
			"Adapter.Setter is a raw type. References to generic type Adapter<T>.Setter<V> should be parameterized\n" + 
41659
			"----------\n" + 
41660
			"3. ERROR in X.java (at line 8)\n" + 
41661
			"	return (X.Setter) \"a\";\n" + 
41662
			"	       ^^^^^^^^^^^^^^\n" + 
41663
			"Cannot cast from String to Adapter.Setter\n" + 
41664
			"----------\n");
41665
}
41666
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236220
41667
public void test1347() throws Exception {
41668
	this.runNegativeTest(
41669
			new String[] {
41670
				"DeprecatedType.java", // =================
41671
				"class Base {\n" + 
41672
				"	class Member<U> {\n" + 
41673
				"   }\n" + 
41674
				"}\n" + 
41675
				"\n" + 
41676
				"@Deprecated\n" + 
41677
				"public class DeprecatedType<T> extends Base {\n" + 
41678
				"}\n",
41679
				"X.java", // =================
41680
				"public class X {\n" + 
41681
				"  DeprecatedType.Member m1; // DeprecatedType and Member are raw + indirect access to Member\n" + 
41682
				"  DeprecatedType.Member<String> m2; // DeprecatedType is raw + indirect access to Member\n" + 
41683
				"  Zork z;\n" +
41684
				"}\n", // =================
41685
			},
41686
			"----------\n" + 
41687
			"1. WARNING in X.java (at line 2)\n" + 
41688
			"	DeprecatedType.Member m1; // DeprecatedType and Member are raw + indirect access to Member\n" + 
41689
			"	^^^^^^^^^^^^^^^^^^^^^\n" + 
41690
			"The type DeprecatedType<T> is deprecated\n" + 
41691
			"----------\n" + 
41692
			"2. WARNING in X.java (at line 2)\n" + 
41693
			"	DeprecatedType.Member m1; // DeprecatedType and Member are raw + indirect access to Member\n" + 
41694
			"	^^^^^^^^^^^^^^^^^^^^^\n" + 
41695
			"Base.Member is a raw type. References to generic type Base.Member<U> should be parameterized\n" + 
41696
			"----------\n" + 
41697
			"3. WARNING in X.java (at line 3)\n" + 
41698
			"	DeprecatedType.Member<String> m2; // DeprecatedType is raw + indirect access to Member\n" + 
41699
			"	^^^^^^^^^^^^^^\n" + 
41700
			"The type DeprecatedType is deprecated\n" + 
41701
			"----------\n" + 
41702
			"4. ERROR in X.java (at line 4)\n" + 
41703
			"	Zork z;\n" + 
41704
			"	^^^^\n" + 
41705
			"Zork cannot be resolved to a type\n" + 
41706
			"----------\n");
41707
}
41708
41444
}
41709
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java (-37 / +66 lines)
Lines 65-70 Link Here
65
	static boolean RunJavac = CompilerOptions.ENABLED.equals(RUN_SUN_JAVAC);
65
	static boolean RunJavac = CompilerOptions.ENABLED.equals(RUN_SUN_JAVAC);
66
	// WORK unify runJavac methods (do we really need a different one here?)
66
	// WORK unify runJavac methods (do we really need a different one here?)
67
67
68
	IPath dirPath = new Path(OUTPUT_DIR); // WORK check whether needed or not
69
68
	// Static initializer to specify tests subset using TESTS_* static variables
70
	// Static initializer to specify tests subset using TESTS_* static variables
69
	// All specified tests which does not belong to the class are skipped...
71
	// All specified tests which does not belong to the class are skipped...
70
//	static {
72
//	static {
Lines 75-87 Link Here
75
	public static Test suite() {
77
	public static Test suite() {
76
		return buildMinimalComplianceTestSuite(testClass(), F_1_5);
78
		return buildMinimalComplianceTestSuite(testClass(), F_1_5);
77
	}
79
	}
78
80
	
79
	public static Class testClass() {
81
	public static Class testClass() {
80
		return GenericTypeSignatureTest.class;
82
		return GenericTypeSignatureTest.class;
81
	}
83
	}
82
	
84
	
83
	IPath dirPath = new Path(OUTPUT_DIR); // WORK check whether needed or not
84
	
85
	public GenericTypeSignatureTest(String name) {
85
	public GenericTypeSignatureTest(String name) {
86
		super(name);
86
		super(name);
87
	}
87
	}
Lines 905-940 Link Here
905
		}
905
		}
906
	}
906
	}
907
	
907
	
908
	// WORK check whether needed or not
909
	/*
910
	 * Write given source test files in current output sub-directory.
911
	 * Use test name for this sub-directory name (ie. test001, test002, etc...)
912
	 */
913
	protected void writeFiles(String[] testFiles) {
914
		// Compute and create specific dir
915
		IPath dirFilePath = (IPath) this.dirPath.clone();
916
		File dir = dirFilePath.toFile();
917
		if (!dir.exists()) {
918
			dir.mkdirs();
919
		}
920
921
		// For each given test files
922
		for (int i=0, length=testFiles.length; i<length; i++) {
923
			dirFilePath = (IPath) this.dirPath.clone();
924
			String contents = testFiles[i+1];
925
			String fileName = testFiles[i++];
926
			IPath filePath = dirFilePath.append(fileName);
927
			if (fileName.lastIndexOf('/') >= 0) {
928
				dirFilePath = filePath.removeLastSegments(1);
929
				dir = dirFilePath.toFile();
930
				if (!dir.exists()) {
931
					dir.mkdirs();
932
				}
933
			}
934
			Util.writeToFile(contents, filePath.toString());
935
		}
936
	}
937
938
	public void test012() {
908
	public void test012() {
939
		final String[] testsSource = new String[] {
909
		final String[] testsSource = new String[] {
940
			"X.java",
910
			"X.java",
Lines 967-973 Link Here
967
			assertTrue(false);
937
			assertTrue(false);
968
		}
938
		}
969
	}
939
	}
970
	
940
971
	public void test013() {
941
	public void test013() {
972
		final String[] testsSource = new String[] {
942
		final String[] testsSource = new String[] {
973
			"X.java",
943
			"X.java",
Lines 1004-1009 Link Here
1004
			assertTrue(false);
974
			assertTrue(false);
1005
		}
975
		}
1006
	}
976
	}
977
	
1007
	// 59983 - incorrect signature for List<X>
978
	// 59983 - incorrect signature for List<X>
1008
	public void test014() {
979
	public void test014() {
1009
		final String[] testsSource = new String[] {
980
		final String[] testsSource = new String[] {
Lines 1057-1063 Link Here
1057
		} catch (IOException e) {
1028
		} catch (IOException e) {
1058
			assertTrue(false);
1029
			assertTrue(false);
1059
		}
1030
		}
1060
	}	
1031
	}
1061
	// 70975 - invalid signature for method with array of type variables
1032
	// 70975 - invalid signature for method with array of type variables
1062
	public void test016() {
1033
	public void test016() {
1063
		final String[] testsSource = new String[] {
1034
		final String[] testsSource = new String[] {
Lines 1230-1236 Link Here
1230
		} catch (IOException e) {
1201
		} catch (IOException e) {
1231
			assertTrue(false);
1202
			assertTrue(false);
1232
		}
1203
		}
1233
	}
1204
	}	
1234
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=160132 - variation
1205
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=160132 - variation
1235
	public void test020() {
1206
	public void test020() {
1236
		final String[] testsSource = new String[] {
1207
		final String[] testsSource = new String[] {
Lines 1261-1265 Link Here
1261
			assertTrue(false);
1232
			assertTrue(false);
1262
		}
1233
		}
1263
	}
1234
	}
1264
	
1235
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=235921
1236
	public void testONLY_021() throws Exception {
1237
		this.runConformTest(
1238
			new String[] {
1239
					"a/Adapter.java\n", //========================
1240
					"package a;\n" + 
1241
					"public interface Adapter<T> {\n" + 
1242
					"  interface Setter<V> {}\n" + 
1243
					"  public <V> Setter<V> makeSetter();\n" + 
1244
					"}\n",
1245
					"a/b/Adapter.java\n", //========================
1246
					"package a.b;\n" + 
1247
					"public class Adapter<T> implements a.Adapter<T> {\n" + 
1248
					"  public <V> Adapter.Setter<V> makeSetter() {\n" + 
1249
					"    return new Adapter.Setter<V>() {};\n" + 
1250
					"  }\n" + 
1251
					"}\n",
1252
				},
1253
			"");
1254
1255
		// check generic signature for a/b/Adapter.class
1256
		ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "a" + File.separator + "b" + File.separator + "Adapter.class");
1257
		char[] signature = classFileReader.getGenericSignature();
1258
		assertEquals("Wrong signature1", "<T:Ljava/lang/Object;>Ljava/lang/Object;La/Adapter<TT;>;", new String(signature));			
1259
1260
		// check generic signature for a/b/Adapter$1.class
1261
		classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "a" + File.separator + "b" + File.separator + "Adapter$1.class");
1262
		signature = classFileReader.getGenericSignature();
1263
		assertEquals("Wrong signature2", "Ljava/lang/Object;La/Adapter$Setter<TV;>;", new String(signature));			
1264
	}
1265
	// WORK check whether needed or not
1266
	/*
1267
	 * Write given source test files in current output sub-directory.
1268
	 * Use test name for this sub-directory name (ie. test001, test002, etc...)
1269
	 */
1270
	protected void writeFiles(String[] testFiles) {
1271
		// Compute and create specific dir
1272
		IPath dirFilePath = (IPath) this.dirPath.clone();
1273
		File dir = dirFilePath.toFile();
1274
		if (!dir.exists()) {
1275
			dir.mkdirs();
1276
		}
1277
1278
		// For each given test files
1279
		for (int i=0, length=testFiles.length; i<length; i++) {
1280
			dirFilePath = (IPath) this.dirPath.clone();
1281
			String contents = testFiles[i+1];
1282
			String fileName = testFiles[i++];
1283
			IPath filePath = dirFilePath.append(fileName);
1284
			if (fileName.lastIndexOf('/') >= 0) {
1285
				dirFilePath = filePath.removeLastSegments(1);
1286
				dir = dirFilePath.toFile();
1287
				if (!dir.exists()) {
1288
					dir.mkdirs();
1289
				}
1290
			}
1291
			Util.writeToFile(contents, filePath.toString());
1292
		}
1293
	}
1265
}
1294
}

Return to bug 235921