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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java (+8 lines)
Lines 990-995 Link Here
990
		case Binding.WILDCARD_TYPE :
990
		case Binding.WILDCARD_TYPE :
991
		case Binding.INTERSECTION_TYPE :
991
		case Binding.INTERSECTION_TYPE :
992
			return ((WildcardBinding) otherType).boundCheck(this);
992
			return ((WildcardBinding) otherType).boundCheck(this);
993
		case Binding.PARAMETERIZED_TYPE:
994
		/* With the hybrid 1.4/1.5+ projects modes, while establishing type equivalence, we need to
995
	       be prepared for a type such as Map appearing in one of three forms: As (a) a ParameterizedTypeBinding 
996
	       e.g Map<String, String>, (b) as RawTypeBinding Map#RAW and finally (c) as a BinaryTypeBinding 
997
	       When the usage of a type lacks type parameters, whether we land up with the raw form or not depends
998
	       on whether the underlying type was "seen to be" a generic type in the particular build environment or
999
	       not. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=186565 && https://bugs.eclipse.org/bugs/show_bug.cgi?id=328827 
1000
		*/ 
993
		case Binding.RAW_TYPE :
1001
		case Binding.RAW_TYPE :
994
			return otherType.erasure() == this;
1002
			return otherType.erasure() == this;
995
	}
1003
	}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java (-14 / +22 lines)
Lines 15-21 Link Here
15
import org.eclipse.jdt.core.compiler.CharOperation;
15
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
16
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
17
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
17
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
18
20
/**
19
/**
21
 * A parameterized type encapsulates a type with type arguments,
20
 * A parameterized type encapsulates a type with type arguments,
Lines 868-886 Link Here
868
				this.arguments[i] = resolveType;
867
				this.arguments[i] = resolveType;
869
				this.tagBits |= resolvedType.tagBits & TagBits.ContainsNestedTypeReferences;
868
				this.tagBits |= resolvedType.tagBits & TagBits.ContainsNestedTypeReferences;
870
			}
869
			}
871
			// arity check
870
			/* https://bugs.eclipse.org/bugs/show_bug.cgi?id=186565, Removed generic check
872
			TypeVariableBinding[] refTypeVariables = resolvedType.typeVariables();
871
			   and arity check since we are dealing with binary types here and the fact that
873
			if (refTypeVariables == Binding.NO_TYPE_VARIABLES) { // check generic
872
			   the compiler produced class files for these types at all is proof positive that
874
				// Below 1.5, we should have already complained about the use of type parameters.
873
			   the generic check and the arity check passed in the build environment that produced
875
				boolean isCompliant15 = this.environment.globalOptions.originalSourceLevel >= ClassFileConstants.JDK1_5;
874
			   these class files. Otherwise we don't handle mixed 1.5 and 1.4 projects correctly.
876
				if (isCompliant15 && (resolvedType.tagBits & TagBits.HasMissingType) == 0) {
875
			   Just as with bounds check below, incremental build will propagate the change and
877
					this.environment.problemReporter.nonGenericTypeCannotBeParameterized(0, null, resolvedType, this.arguments);
876
			   detect problems in source.
878
				}
877
			 */
879
				return this;
878
			
880
			} else if (argLength != refTypeVariables.length) { // check arity
879
//			// arity check
881
				this.environment.problemReporter.incorrectArityForParameterizedType(null, resolvedType, this.arguments);
880
//			TypeVariableBinding[] refTypeVariables = resolvedType.typeVariables();
882
				return this; // cannot reach here as AbortCompilation is thrown
881
//			if (refTypeVariables == Binding.NO_TYPE_VARIABLES) { // check generic
883
			}
882
//				// Below 1.5, we should have already complained about the use of type parameters.
883
//				boolean isCompliant15 = this.environment.globalOptions.originalSourceLevel >= ClassFileConstants.JDK1_5;
884
//				if (isCompliant15 && (resolvedType.tagBits & TagBits.HasMissingType) == 0) {
885
//					this.environment.problemReporter.nonGenericTypeCannotBeParameterized(0, null, resolvedType, this.arguments);
886
//				}
887
//				return this;
888
//			} else if (argLength != refTypeVariables.length) { // check arity
889
//				this.environment.problemReporter.incorrectArityForParameterizedType(null, resolvedType, this.arguments);
890
//				return this; // cannot reach here as AbortCompilation is thrown
891
//			}
884
			// check argument type compatibility... REMOVED for now since incremental build will propagate change & detect in source
892
			// check argument type compatibility... REMOVED for now since incremental build will propagate change & detect in source
885
//			for (int i = 0; i < argLength; i++) {
893
//			for (int i = 0; i < argLength; i++) {
886
//			    TypeBinding resolvedArgument = this.arguments[i];
894
//			    TypeBinding resolvedArgument = this.arguments[i];
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+56 lines)
Lines 11963-11966 Link Here
11963
		new File(lib1Path).delete();
11963
		new File(lib1Path).delete();
11964
	}
11964
	}
11965
}
11965
}
11966
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=186565 Test interaction between 1.4 and 1.5 class files 
11967
public void test186565(){
11968
	String outputDirName = OUTPUT_DIR + File.separator + "d",
11969
	  metaInfDirName = outputDirName + File.separator + "META-INF",
11970
	  jarFileName = outputDirName + File.separator + "classB15.jar";
11971
	this.runConformTest(
11972
		new String[] {
11973
			"d/B.java",
11974
			"public class B<T> extends A<T> {\n" +
11975
			"}",
11976
			"d/A.java",
11977
			"public class A<T> {\n" +
11978
			"}",
11979
			},
11980
	    "\"" + outputDirName + "\""
11981
	    + " -1.5 -g -preserveAllLocals"
11982
	    + " -d \"" + outputDirName + "\"",
11983
		"",
11984
		"",
11985
		true /* flush output directory */);
11986
	File outputDirectory = new File(outputDirName);
11987
	File metaInfDirectory = new File(metaInfDirName);
11988
	metaInfDirectory.mkdirs();
11989
	try {
11990
		Util.createFile(metaInfDirName + File.separator + "MANIFEST.MF",
11991
			"Manifest-Version: 1.0\n" +
11992
			"Class-Path: ../d/classB15.jar\n");
11993
	} catch (IOException e) {
11994
		fail("could not create manifest file");
11995
	}
11996
	Util.delete(outputDirName + File.separator + "A.class");
11997
	Util.delete(outputDirName + File.separator + "A.java");
11998
	try {
11999
		Util.zip(outputDirectory, jarFileName);
12000
	} catch (IOException e) {
12001
		fail("could not create jar file");
12002
	}
12003
	Util.delete(outputDirName + File.separator + "B.class");
12004
	Util.delete(outputDirName + File.separator + "B.java");
12005
	this.runConformTest(
12006
		new String[] {
12007
			"d/A.java",
12008
			"public class A {\n" +
12009
			"}",
12010
			"d/C.java",
12011
			"public class C extends B<String> {\n" +
12012
			"}",
12013
			},
12014
	    "\"" + outputDirName + "\""
12015
	    + " -1.5 -g -preserveAllLocals"
12016
	    + " -cp \"" + jarFileName + "\""
12017
	    + " -d \"" + OUTPUT_DIR + "\"",
12018
		"",
12019
		"",
12020
		false /* do not flush output directory */);
12021
}
11966
}
12022
}
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-1 / +1 lines)
Lines 9313-9319 Link Here
9313
				false);
9313
				false);
9314
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
9314
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
9315
		CompilationUnit unit = (CompilationUnit) node;
9315
		CompilationUnit unit = (CompilationUnit) node;
9316
		assertProblemsSize(unit, 1, "The type A is not generic; it cannot be parameterized with arguments <?>");
9316
		assertProblemsSize(unit, 0);
9317
	}
9317
	}
9318
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908
9318
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908
9319
	public void test0274() throws JavaModelException {
9319
	public void test0274() throws JavaModelException {

Return to bug 186565