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

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java (-1 / +33 lines)
Lines 486-492 Link Here
486
		"Type mismatch: required \'@NonNull Object\' but the provided value is null\n" + 
486
		"Type mismatch: required \'@NonNull Object\' but the provided value is null\n" + 
487
		"----------\n"  /* compiler output */);
487
		"----------\n"  /* compiler output */);
488
}
488
}
489
//null is passed to a non-null parameter in a qualified allocation expression, generic constructor, target class read from .class
489
// null is passed to a non-null parameter in a qualified allocation expression, generic constructor, target class read from .class
490
public void test_nonnull_parameter_012() {
490
public void test_nonnull_parameter_012() {
491
	Map customOptions = getCompilerOptions();
491
	Map customOptions = getCompilerOptions();
492
	customOptions.put(JavaCore.COMPILER_PB_NULL_SPECIFICATION_INSUFFICIENT_INFO, JavaCore.ERROR);
492
	customOptions.put(JavaCore.COMPILER_PB_NULL_SPECIFICATION_INSUFFICIENT_INFO, JavaCore.ERROR);
Lines 2390-2393 Link Here
2390
		},
2390
		},
2391
		"");
2391
		"");
2392
}
2392
}
2393
// test analysis disablement, binary type contains annotation
2394
public void test_disabled_1() {
2395
	Map customOptions = getCompilerOptions();
2396
	customOptions.put(JavaCore.COMPILER_PB_NULL_SPECIFICATION_INSUFFICIENT_INFO, JavaCore.ERROR);
2397
	runConformTestWithLibs(
2398
			new String[] {
2399
				"ContainingInner2.java",
2400
				"public class ContainingInner2 {\n" + 
2401
				"    public ContainingInner2 (@org.eclipse.jdt.annotation.NonNull Object o) {\n" + 
2402
				"    }\n" + 
2403
				"    public class Inner {\n" + 
2404
				"        public <T> Inner (@org.eclipse.jdt.annotation.NonNull T o) {\n" + 
2405
				"        }\n" + 
2406
				"    }\n" + 
2407
				"}\n",
2408
			},
2409
			null /*customOptions*/,
2410
			"");
2411
	customOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.DISABLED);
2412
	runConformTestWithLibs(
2413
		false, // flush directory
2414
		new String[] {
2415
			"X.java",
2416
			"public class X {\n" +
2417
			"	 void create() {\n" +
2418
			"          ContainingInner2 container = new ContainingInner2(null);\n" +
2419
			"	       ContainingInner2.Inner inner = container.new Inner(null);\n" +
2420
			"    }\n" +
2421
		  	"}\n"},
2422
		customOptions,
2423
		""  /* compiler output */);
2424
}
2393
}
2425
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java (-2 / +6 lines)
Lines 1152-1161 Link Here
1152
	return this.storedAnnotations;
1152
	return this.storedAnnotations;
1153
}
1153
}
1154
void scanMethodForNullAnnotation(IBinaryMethod method, MethodBinding methodBinding) {
1154
void scanMethodForNullAnnotation(IBinaryMethod method, MethodBinding methodBinding) {
1155
	if (!this.environment.globalOptions.isAnnotationBasedNullAnalysisEnabled)
1156
		return;
1155
	char[][] nullableAnnotationName = this.environment.getNullableAnnotationName();
1157
	char[][] nullableAnnotationName = this.environment.getNullableAnnotationName();
1156
	char[][] nonNullAnnotationName = this.environment.getNonNullAnnotationName();
1158
	char[][] nonNullAnnotationName = this.environment.getNonNullAnnotationName();
1157
	if (nullableAnnotationName == null || nonNullAnnotationName == null)
1159
	if (nullableAnnotationName == null || nonNullAnnotationName == null)
1158
		return; // not configured to use null annotations
1160
		return; // not well-configured to use null annotations
1159
1161
1160
	// return:
1162
	// return:
1161
	IBinaryAnnotation[] annotations = method.getAnnotations();
1163
	IBinaryAnnotation[] annotations = method.getAnnotations();
Lines 1204-1212 Link Here
1204
	}
1206
	}
1205
}
1207
}
1206
void scanTypeForNullAnnotation(IBinaryType binaryType) {
1208
void scanTypeForNullAnnotation(IBinaryType binaryType) {
1209
	if (!this.environment.globalOptions.isAnnotationBasedNullAnalysisEnabled)
1210
		return;
1207
	char[][] nonNullByDefaultAnnotationName = this.environment.getNonNullByDefaultAnnotationName();
1211
	char[][] nonNullByDefaultAnnotationName = this.environment.getNonNullByDefaultAnnotationName();
1208
	if (nonNullByDefaultAnnotationName == null)
1212
	if (nonNullByDefaultAnnotationName == null)
1209
		return; // not configured to use null annotations
1213
		return; // not well-configured to use null annotations
1210
1214
1211
	IBinaryAnnotation[] annotations = binaryType.getAnnotations();
1215
	IBinaryAnnotation[] annotations = binaryType.getAnnotations();
1212
	if (annotations != null) {
1216
	if (annotations != null) {

Return to bug 186342