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

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java (+2 lines)
Lines 809-814 Link Here
809
		expectedProblemAttributes.put("SuperclassNotFound", DEPRECATED);
809
		expectedProblemAttributes.put("SuperclassNotFound", DEPRECATED);
810
		expectedProblemAttributes.put("SuperclassNotVisible", DEPRECATED);
810
		expectedProblemAttributes.put("SuperclassNotVisible", DEPRECATED);
811
		expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
811
		expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
812
		expectedProblemAttributes.put("SwitchOnEnumNotBelow15", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
812
		expectedProblemAttributes.put("SwitchOnStringsNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
813
		expectedProblemAttributes.put("SwitchOnStringsNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
813
		expectedProblemAttributes.put("Task", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
814
		expectedProblemAttributes.put("Task", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
814
		expectedProblemAttributes.put("ThisInStaticContext", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
815
		expectedProblemAttributes.put("ThisInStaticContext", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
Lines 1482-1487 Link Here
1482
		expectedProblemAttributes.put("SuperclassNotFound", SKIP);
1483
		expectedProblemAttributes.put("SuperclassNotFound", SKIP);
1483
		expectedProblemAttributes.put("SuperclassNotVisible", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_SUPERINTERFACE));
1484
		expectedProblemAttributes.put("SuperclassNotVisible", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_SUPERINTERFACE));
1484
		expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT));
1485
		expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT));
1486
		expectedProblemAttributes.put("SwitchOnEnumNotBelow15", SKIP);
1485
		expectedProblemAttributes.put("SwitchOnStringsNotBelow17", SKIP);
1487
		expectedProblemAttributes.put("SwitchOnStringsNotBelow17", SKIP);
1486
		expectedProblemAttributes.put("Task", SKIP);
1488
		expectedProblemAttributes.put("Task", SKIP);
1487
		expectedProblemAttributes.put("ThisInStaticContext", SKIP);
1489
		expectedProblemAttributes.put("ThisInStaticContext", SKIP);
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java (+2 lines)
Lines 1409-1414 Link Here
1409
	int UnclosedCloseableAtExit = Internal + 888;
1409
	int UnclosedCloseableAtExit = Internal + 888;
1410
	/** @since 3.8 */
1410
	/** @since 3.8 */
1411
	int ExplicitlyClosedAutoCloseable = Internal + 889;
1411
	int ExplicitlyClosedAutoCloseable = Internal + 889;
1412
	/** @since 3.8 */
1413
	int SwitchOnEnumNotBelow15 = TypeRelated + 890;	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=
1412
	/**
1414
	/**
1413
	 * External problems -- These are problems defined by other plugins
1415
	 * External problems -- These are problems defined by other plugins
1414
	 */
1416
	 */
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java (+3 lines)
Lines 463-468 Link Here
463
							break checkType;
463
							break checkType;
464
					} else if (expressionType.isEnum()) {
464
					} else if (expressionType.isEnum()) {
465
						isEnumSwitch = true;
465
						isEnumSwitch = true;
466
						if (upperScope.compilerOptions().complianceLevel < ClassFileConstants.JDK1_5) {
467
							upperScope.problemReporter().incorrectSwitchType(this.expression, expressionType); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=360164
468
						}
466
						break checkType;
469
						break checkType;
467
					} else if (upperScope.isBoxingCompatibleWith(expressionType, TypeBinding.INT)) {
470
					} else if (upperScope.isBoxingCompatibleWith(expressionType, TypeBinding.INT)) {
468
						this.expression.computeConversion(upperScope, TypeBinding.INT, expressionType);
471
						this.expression.computeConversion(upperScope, TypeBinding.INT, expressionType);
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java (-3 / +8 lines)
Lines 975-983 Link Here
975
}
975
}
976
public boolean hasTypeBit(int bit) {
976
public boolean hasTypeBit(int bit) {
977
	// ensure hierarchy is resolved, which will propagate bits down to us
977
	// ensure hierarchy is resolved, which will propagate bits down to us
978
	superclass();
978
	boolean wasToleratingMissingTypeProcessingAnnotations = this.environment.mayTolerateMissingType;
979
	superInterfaces();
979
	this.environment.mayTolerateMissingType = true;
980
	return (this.typeBits & bit) != 0;
980
	try {
981
		superclass();
982
		superInterfaces();
983
	} finally {
984
		this.environment.mayTolerateMissingType = wasToleratingMissingTypeProcessingAnnotations;
985
	}	return (this.typeBits & bit) != 0;
981
}
986
}
982
private void initializeTypeVariable(TypeVariableBinding variable, TypeVariableBinding[] existingVariables, SignatureWrapper wrapper, char[][][] missingTypeNames) {
987
private void initializeTypeVariable(TypeVariableBinding variable, TypeVariableBinding[] existingVariables, SignatureWrapper wrapper, char[][][] missingTypeNames) {
983
	// ParameterSignature = Identifier ':' TypeSignature
988
	// ParameterSignature = Identifier ':' TypeSignature
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java (+1 lines)
Lines 74-79 Link Here
74
	private ArrayList missingTypes;
74
	private ArrayList missingTypes;
75
	Set typesBeingConnected;
75
	Set typesBeingConnected;
76
	public boolean isProcessingAnnotations = false;
76
	public boolean isProcessingAnnotations = false;
77
	public boolean mayTolerateMissingType = false;
77
78
78
	final static int BUILD_FIELDS_AND_METHODS = 4;
79
	final static int BUILD_FIELDS_AND_METHODS = 4;
79
	final static int BUILD_TYPE_HIERARCHY = 1;
80
	final static int BUILD_TYPE_HIERARCHY = 1;
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java (-1 / +1 lines)
Lines 55-61 Link Here
55
		}
55
		}
56
		if (targetType == null || targetType == this) { // could not resolve any better, error was already reported against it
56
		if (targetType == null || targetType == this) { // could not resolve any better, error was already reported against it
57
			// report the missing class file first - only if not resolving a previously missing type
57
			// report the missing class file first - only if not resolving a previously missing type
58
			if ((this.tagBits & TagBits.HasMissingType) == 0) {
58
			if ((this.tagBits & TagBits.HasMissingType) == 0 && !environment.mayTolerateMissingType) {
59
				environment.problemReporter.isClassPathCorrect(
59
				environment.problemReporter.isClassPathCorrect(
60
					this.compoundName,
60
					this.compoundName,
61
					environment.unitBeingCompleted,
61
					environment.unitBeingCompleted,
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-6 / +15 lines)
Lines 2863-2874 Link Here
2863
					expression.sourceStart,
2863
					expression.sourceStart,
2864
					expression.sourceEnd);
2864
					expression.sourceEnd);
2865
		} else {
2865
		} else {
2866
			this.handle(
2866
			if (this.options.sourceLevel < ClassFileConstants.JDK1_5 && testType.isEnum()) {
2867
				IProblem.IncorrectSwitchType,
2867
				this.handle(
2868
				new String[] {new String(testType.readableName())},
2868
						IProblem.SwitchOnEnumNotBelow15,
2869
				new String[] {new String(testType.shortReadableName())},
2869
						new String[] {new String(testType.readableName())},
2870
				expression.sourceStart,
2870
						new String[] {new String(testType.shortReadableName())},
2871
				expression.sourceEnd);
2871
						expression.sourceStart,
2872
						expression.sourceEnd);
2873
			} else {
2874
				this.handle(
2875
						IProblem.IncorrectSwitchType,
2876
						new String[] {new String(testType.readableName())},
2877
						new String[] {new String(testType.shortReadableName())},
2878
						expression.sourceStart,
2879
						expression.sourceEnd);
2880
			}
2872
		}
2881
		}
2873
	} else {
2882
	} else {
2874
		this.handle(
2883
		this.handle(
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (+1 lines)
Lines 651-656 Link Here
651
887 = Resource leak: ''{0}'' is never closed
651
887 = Resource leak: ''{0}'' is never closed
652
888 = Resource leak: ''{0}'' is not closed at this location
652
888 = Resource leak: ''{0}'' is not closed at this location
653
889 = Resource ''{0}'' should be managed by try-with-resource
653
889 = Resource ''{0}'' should be managed by try-with-resource
654
890 = Cannot switch on a value of type enum for source level below 1.5
654
655
655
### ELABORATIONS
656
### ELABORATIONS
656
## Access restrictions
657
## Access restrictions

Return to bug 360164