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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java (-2 / +268 lines)
Lines 39-46 Link Here
39
	// All specified tests which do not belong to the class are skipped...
39
	// All specified tests which do not belong to the class are skipped...
40
	static {
40
	static {
41
//		TESTS_NAMES = new String[] { "test127" };
41
//		TESTS_NAMES = new String[] { "test127" };
42
//		TESTS_NUMBERS = new int[] { 212, 213 };
42
//		TESTS_NUMBERS = new int[] { 219 };
43
//		TESTS_RANGE = new int[] { 169, 180 };
43
//		TESTS_RANGE = new int[] { 219, -1 };
44
	}
44
	}
45
45
46
	public static Test suite() {
46
	public static Test suite() {
Lines 7240-7243 Link Here
7240
		"The method message() is undefined for the type Annotation\n" + 
7240
		"The method message() is undefined for the type Annotation\n" + 
7241
		"----------\n");
7241
		"----------\n");
7242
}
7242
}
7243
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=167217
7244
public void test219() {
7245
	this.runNegativeTest(
7246
		new String[] {
7247
			"X.java",
7248
			"public class X {\n" + 
7249
			"        @MyB1(MyA2.XX)\n" + 
7250
			"        public void foo(){}\n" + 
7251
			"}",
7252
			"MyA1.java",
7253
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7254
			"import java.lang.annotation.Target;\n" + 
7255
			"\n" + 
7256
			"@Target( {\n" + 
7257
			"	TYPE\n" + 
7258
			"})\n" + 
7259
			"public @interface MyA1 {\n" + 
7260
			"}",
7261
			"MyA2.java",
7262
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7263
			"import java.lang.annotation.Target;\n" + 
7264
			"\n" + 
7265
			"@Target( {\n" + 
7266
			"	TYPE\n" + 
7267
			"})\n" + 
7268
			"public @interface MyA2 {\n" + 
7269
			"        public static final MyA1 XX = null;\n" + 
7270
			"}",
7271
			"MyB1.java",
7272
			"import static java.lang.annotation.ElementType.*;\n" + 
7273
			"import java.lang.annotation.Target;\n" + 
7274
			"\n" + 
7275
			"@Target( {\n" + 
7276
			"	TYPE, METHOD\n" + 
7277
			"})\n" + 
7278
			"public @interface MyB1 {\n" + 
7279
			"        MyA1 value();\n" + 
7280
			"}"
7281
		},
7282
		"----------\n" + 
7283
		"1. ERROR in X.java (at line 2)\n" + 
7284
		"	@MyB1(MyA2.XX)\n" + 
7285
		"	      ^^^^^^^\n" + 
7286
		"The value for annotation attribute MyB1.value must be some @MyA1 annotation \n" + 
7287
		"----------\n");
7288
}
7289
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=167217
7290
public void test220() {
7291
	this.runNegativeTest(
7292
		new String[] {
7293
			"X.java",
7294
			"public class X {\n" + 
7295
			"        @MyB1({MyA2.XX})\n" + 
7296
			"        public void foo(){}\n" + 
7297
			"}",
7298
			"MyA1.java",
7299
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7300
			"import java.lang.annotation.Target;\n" + 
7301
			"\n" + 
7302
			"@Target( {\n" + 
7303
			"	TYPE\n" + 
7304
			"})\n" + 
7305
			"public @interface MyA1 {\n" + 
7306
			"}",
7307
			"MyA2.java",
7308
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7309
			"import java.lang.annotation.Target;\n" + 
7310
			"\n" + 
7311
			"@Target( {\n" + 
7312
			"	TYPE\n" + 
7313
			"})\n" + 
7314
			"public @interface MyA2 {\n" + 
7315
			"        public static final MyA1 XX = null;\n" + 
7316
			"}",
7317
			"MyB1.java",
7318
			"import static java.lang.annotation.ElementType.*;\n" + 
7319
			"import java.lang.annotation.Target;\n" + 
7320
			"\n" + 
7321
			"@Target( {\n" + 
7322
			"	TYPE, METHOD\n" + 
7323
			"})\n" + 
7324
			"public @interface MyB1 {\n" + 
7325
			"        MyA1[] value();\n" + 
7326
			"}"
7327
		},
7328
		"----------\n" + 
7329
		"1. ERROR in X.java (at line 2)\n" + 
7330
		"	@MyB1({MyA2.XX})\n" + 
7331
		"	       ^^^^^^^\n" + 
7332
		"The value for annotation attribute MyB1.value must be some @MyA1 annotation \n" + 
7333
		"----------\n");
7334
}
7335
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=167217
7336
public void test221() {
7337
	this.runNegativeTest(
7338
		new String[] {
7339
			"X.java",
7340
			"public class X {\n" + 
7341
			"        @MyB1(null)\n" + 
7342
			"        public void foo(){}\n" + 
7343
			"}",
7344
			"MyA1.java",
7345
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7346
			"import java.lang.annotation.Target;\n" + 
7347
			"\n" + 
7348
			"@Target( {\n" + 
7349
			"	TYPE\n" + 
7350
			"})\n" + 
7351
			"public @interface MyA1 {\n" + 
7352
			"}",
7353
			"MyA2.java",
7354
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7355
			"import java.lang.annotation.Target;\n" + 
7356
			"\n" + 
7357
			"@Target( {\n" + 
7358
			"	TYPE\n" + 
7359
			"})\n" + 
7360
			"public @interface MyA2 {\n" + 
7361
			"        public static final MyA1 XX = null;\n" + 
7362
			"}",
7363
			"MyB1.java",
7364
			"import static java.lang.annotation.ElementType.*;\n" + 
7365
			"import java.lang.annotation.Target;\n" + 
7366
			"\n" + 
7367
			"@Target( {\n" + 
7368
			"	TYPE, METHOD\n" + 
7369
			"})\n" + 
7370
			"public @interface MyB1 {\n" + 
7371
			"        MyA1 value();\n" + 
7372
			"}"
7373
		},
7374
		"----------\n" + 
7375
		"1. ERROR in X.java (at line 2)\n" + 
7376
		"	@MyB1(null)\n" + 
7377
		"	      ^^^^\n" + 
7378
		"The value for annotation attribute MyB1.value must be some @MyA1 annotation \n" + 
7379
		"----------\n");
7380
}
7381
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=167217
7382
public void test222() {
7383
	this.runNegativeTest(
7384
		new String[] {
7385
			"X.java",
7386
			"public class X {\n" + 
7387
			"        @MyB1({null})\n" + 
7388
			"        public void foo(){}\n" + 
7389
			"}",
7390
			"MyA1.java",
7391
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7392
			"import java.lang.annotation.Target;\n" + 
7393
			"\n" + 
7394
			"@Target( {\n" + 
7395
			"	TYPE\n" + 
7396
			"})\n" + 
7397
			"public @interface MyA1 {\n" + 
7398
			"}",
7399
			"MyA2.java",
7400
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7401
			"import java.lang.annotation.Target;\n" + 
7402
			"\n" + 
7403
			"@Target( {\n" + 
7404
			"	TYPE\n" + 
7405
			"})\n" + 
7406
			"public @interface MyA2 {\n" + 
7407
			"        public static final MyA1 XX = null;\n" + 
7408
			"}",
7409
			"MyB1.java",
7410
			"import static java.lang.annotation.ElementType.*;\n" + 
7411
			"import java.lang.annotation.Target;\n" + 
7412
			"\n" + 
7413
			"@Target( {\n" + 
7414
			"	TYPE, METHOD\n" + 
7415
			"})\n" + 
7416
			"public @interface MyB1 {\n" + 
7417
			"        MyA1[] value();\n" + 
7418
			"}"
7419
		},
7420
		"----------\n" + 
7421
		"1. ERROR in X.java (at line 2)\n" + 
7422
		"	@MyB1({null})\n" + 
7423
		"	       ^^^^\n" + 
7424
		"The value for annotation attribute MyB1.value must be some @MyA1 annotation \n" + 
7425
		"----------\n");
7426
}
7427
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=167217
7428
public void test223() {
7429
	this.runConformTest(
7430
		new String[] {
7431
			"X.java",
7432
			"public class X {\n" + 
7433
			"        @MyB1(@MyA1())\n" + 
7434
			"        public void foo(){}\n" + 
7435
			"}",
7436
			"MyA1.java",
7437
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7438
			"import java.lang.annotation.Target;\n" + 
7439
			"\n" + 
7440
			"@Target( {\n" + 
7441
			"	TYPE\n" + 
7442
			"})\n" + 
7443
			"public @interface MyA1 {\n" + 
7444
			"}",
7445
			"MyA2.java",
7446
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7447
			"import java.lang.annotation.Target;\n" + 
7448
			"\n" + 
7449
			"@Target( {\n" + 
7450
			"	TYPE\n" + 
7451
			"})\n" + 
7452
			"public @interface MyA2 {\n" + 
7453
			"        public static final MyA1 XX = null;\n" + 
7454
			"}",
7455
			"MyB1.java",
7456
			"import static java.lang.annotation.ElementType.*;\n" + 
7457
			"import java.lang.annotation.Target;\n" + 
7458
			"\n" + 
7459
			"@Target( {\n" + 
7460
			"	TYPE, METHOD\n" + 
7461
			"})\n" + 
7462
			"public @interface MyB1 {\n" + 
7463
			"        MyA1 value();\n" + 
7464
			"}"
7465
		},
7466
		"");
7467
}
7468
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=167217
7469
public void test224() {
7470
	this.runConformTest(
7471
		new String[] {
7472
			"X.java",
7473
			"public class X {\n" + 
7474
			"        @MyB1({@MyA1(), @MyA1})\n" + 
7475
			"        public void foo(){}\n" + 
7476
			"}",
7477
			"MyA1.java",
7478
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7479
			"import java.lang.annotation.Target;\n" + 
7480
			"\n" + 
7481
			"@Target( {\n" + 
7482
			"	TYPE\n" + 
7483
			"})\n" + 
7484
			"public @interface MyA1 {\n" + 
7485
			"}",
7486
			"MyA2.java",
7487
			"import static java.lang.annotation.ElementType.TYPE;\n" + 
7488
			"import java.lang.annotation.Target;\n" + 
7489
			"\n" + 
7490
			"@Target( {\n" + 
7491
			"	TYPE\n" + 
7492
			"})\n" + 
7493
			"public @interface MyA2 {\n" + 
7494
			"        public static final MyA1 XX = null;\n" + 
7495
			"}",
7496
			"MyB1.java",
7497
			"import static java.lang.annotation.ElementType.*;\n" + 
7498
			"import java.lang.annotation.Target;\n" + 
7499
			"\n" + 
7500
			"@Target( {\n" + 
7501
			"	TYPE, METHOD\n" + 
7502
			"})\n" + 
7503
			"public @interface MyB1 {\n" + 
7504
			"        MyA1[] value();\n" + 
7505
			"}"
7506
		},
7507
		"");
7508
}
7243
}
7509
}

Return to bug 167217