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

Collapse All | Expand All

(-)batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java (+7 lines)
Lines 115-120 Link Here
115
	if (binaryExists) {
115
	if (binaryExists) {
116
		try {
116
		try {
117
			ClassFileReader reader = ClassFileReader.read(this.path + qualifiedBinaryFileName);
117
			ClassFileReader reader = ClassFileReader.read(this.path + qualifiedBinaryFileName);
118
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115, package names are to be treated case sensitive.
119
			String typeSearched = qualifiedPackageName.length() > 0 ? 
120
					qualifiedPackageName.replace(File.separatorChar, '/') + "/" + fileName //$NON-NLS-1$
121
					: fileName;
122
			if (!CharOperation.equals(reader.getName(), typeSearched.toCharArray())) {
123
				reader = null;
124
			}
118
			if (reader != null)
125
			if (reader != null)
119
				return new NameEnvironmentAnswer(
126
				return new NameEnvironmentAnswer(
120
						reader,
127
						reader,
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+355 lines)
Lines 3109-3114 Link Here
3109
		this.runConformTest(
3109
		this.runConformTest(
3110
			new String[] {
3110
			new String[] {
3111
				"p/Y.java",
3111
				"p/Y.java",
3112
				"package p;\n" +
3112
				"public class Y { public static final String S = \"\"; }",
3113
				"public class Y { public static final String S = \"\"; }",
3113
			},
3114
			},
3114
	        "\"" + OUTPUT_DIR +  File.separator + "p" + File.separator + "Y.java\""
3115
	        "\"" + OUTPUT_DIR +  File.separator + "p" + File.separator + "Y.java\""
Lines 11410-11413 Link Here
11410
		"",
11411
		"",
11411
		true);
11412
		true);
11412
}
11413
}
11414
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
11415
public void test0307(){
11416
	final String javaClassspath = System.getProperty("java.class.path");
11417
	final String javaUserDir = System.getProperty("user.dir");
11418
	try {
11419
		System.setProperty("user.dir", OUTPUT_DIR);
11420
		this.runConformTest(
11421
			new String[] {
11422
				"p/Y.java",
11423
				"package p;\n" +
11424
				"public class Y { public class I {}; }",
11425
			},
11426
	        "\"" + OUTPUT_DIR +  File.separator + "p" + File.separator + "Y.java\""
11427
	        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11428
	        "",
11429
	        "",
11430
	        true);
11431
		System.setProperty("java.class.path", "");
11432
		this.runConformTest(
11433
				new String[] {
11434
					"X.java",
11435
					"import p.Y.I;\n" +
11436
					"public class X {\n" +
11437
					"   I i;\n" +
11438
					"	public static void main(String[] args) {\n" +
11439
					"		System.out.print(\"\");\n" +
11440
					"	}\n" +
11441
					"}",
11442
				},
11443
		        "\"" + OUTPUT_DIR +  File.separator + "X.java\""
11444
		        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11445
		        "",// this is not the runtime output
11446
		        "no classpath defined, using default directory instead\n",
11447
		        false);
11448
		final String userDir = System.getProperty("user.dir");
11449
		File f = new File(userDir, "X.java");
11450
		if (!Util.delete(f)) {
11451
			System.out.println("Could not delete X");
11452
		}
11453
		f = new File(userDir, "p" + File.separator + "Y.java");
11454
		if (!Util.delete(f)) {
11455
			System.out.println("Could not delete Y");
11456
		}
11457
11458
	} finally {
11459
		System.setProperty("java.class.path", javaClassspath);
11460
		System.setProperty("user.dir", javaUserDir);
11461
	}
11462
}
11463
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
11464
public void test0307a(){
11465
	final String javaClassspath = System.getProperty("java.class.path");
11466
	final String javaUserDir = System.getProperty("user.dir");
11467
	try {
11468
		System.setProperty("user.dir", OUTPUT_DIR);
11469
		this.runConformTest(
11470
			new String[] {
11471
				"P/Y.java",
11472
				"package P;\n" +
11473
				"public class Y { public class I {}; }",
11474
			},
11475
	        "\"" + OUTPUT_DIR +  File.separator + "P" + File.separator + "Y.java\""
11476
	        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11477
	        "",
11478
	        "",
11479
	        true);
11480
		System.setProperty("java.class.path", "");
11481
		this.runNegativeTest(
11482
				new String[] {
11483
					"X.java",
11484
					"import p.Y.I;\n" +
11485
					"public class X {\n" +
11486
					"   I i;\n" +
11487
					"	public static void main(String[] args) {\n" +
11488
					"		System.out.print(\"\");\n" +
11489
					"	}\n" +
11490
					"}",
11491
				},
11492
		        "\"" + OUTPUT_DIR +  File.separator + "X.java\""
11493
		        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11494
		        "",// this is not the runtime output
11495
		        "no classpath defined, using default directory instead\n" + 
11496
		        "----------\n" + 
11497
		        "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 1)\n" + 
11498
		        "	import p.Y.I;\n" + 
11499
		        "	       ^^^\n" + 
11500
		        "The import p.Y cannot be resolved\n" + 
11501
		        "----------\n" + 
11502
		        "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11503
		        "	I i;\n" + 
11504
		        "	^\n" + 
11505
		        "I cannot be resolved to a type\n" + 
11506
		        "----------\n" + 
11507
		        "2 problems (2 errors)",
11508
		        false);
11509
		final String userDir = System.getProperty("user.dir");
11510
		File f = new File(userDir, "X.java");
11511
		if (!Util.delete(f)) {
11512
			System.out.println("Could not delete X");
11513
		}
11514
		f = new File(userDir, "p" + File.separator + "Y.java");
11515
		if (!Util.delete(f)) {
11516
			System.out.println("Could not delete Y");
11517
		}
11518
11519
	} finally {
11520
		System.setProperty("java.class.path", javaClassspath);
11521
		System.setProperty("user.dir", javaUserDir);
11522
	}
11523
}
11524
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
11525
public void test0307b(){
11526
	final String javaClassspath = System.getProperty("java.class.path");
11527
	final String javaUserDir = System.getProperty("user.dir");
11528
	try {
11529
		System.setProperty("user.dir", OUTPUT_DIR);
11530
		this.runConformTest(
11531
			new String[] {
11532
				"p/y.java",
11533
				"package p;\n" +
11534
				"public class y { public class I {}; }",
11535
			},
11536
	        "\"" + OUTPUT_DIR +  File.separator + "p" + File.separator + "y.java\""
11537
	        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11538
	        "",
11539
	        "",
11540
	        true);
11541
		System.setProperty("java.class.path", "");
11542
		this.runNegativeTest(
11543
				new String[] {
11544
					"X.java",
11545
					"import p.Y.I;\n" +
11546
					"public class X {\n" +
11547
					"   I i;\n" +
11548
					"	public static void main(String[] args) {\n" +
11549
					"		System.out.print(\"\");\n" +
11550
					"	}\n" +
11551
					"}",
11552
				},
11553
		        "\"" + OUTPUT_DIR +  File.separator + "X.java\""
11554
		        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11555
		        "",// this is not the runtime output
11556
		        "no classpath defined, using default directory instead\n" + 
11557
		        "----------\n" + 
11558
		        "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 1)\n" + 
11559
		        "	import p.Y.I;\n" + 
11560
		        "	       ^^^\n" + 
11561
		        "The import p.Y cannot be resolved\n" + 
11562
		        "----------\n" + 
11563
		        "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11564
		        "	I i;\n" + 
11565
		        "	^\n" + 
11566
		        "I cannot be resolved to a type\n" + 
11567
		        "----------\n" + 
11568
		        "2 problems (2 errors)",
11569
		        false);
11570
		final String userDir = System.getProperty("user.dir");
11571
		File f = new File(userDir, "X.java");
11572
		if (!Util.delete(f)) {
11573
			System.out.println("Could not delete X");
11574
		}
11575
		f = new File(userDir, "p" + File.separator + "Y.java");
11576
		if (!Util.delete(f)) {
11577
			System.out.println("Could not delete Y");
11578
		}
11579
11580
	} finally {
11581
		System.setProperty("java.class.path", javaClassspath);
11582
		System.setProperty("user.dir", javaUserDir);
11583
	}
11584
}
11585
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
11586
public void test0307c(){
11587
	final String javaClassspath = System.getProperty("java.class.path");
11588
	final String javaUserDir = System.getProperty("user.dir");
11589
	try {
11590
		System.setProperty("user.dir", OUTPUT_DIR);
11591
		this.runConformTest(
11592
			new String[] {
11593
				"p/Y.java",
11594
				"package p;\n" +
11595
				"public class Y { public class i {}; }",
11596
			},
11597
	        "\"" + OUTPUT_DIR +  File.separator + "p" + File.separator + "Y.java\""
11598
	        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11599
	        "",
11600
	        "",
11601
	        true);
11602
		System.setProperty("java.class.path", "");
11603
		this.runNegativeTest(
11604
				new String[] {
11605
					"X.java",
11606
					"import p.Y.I;\n" +
11607
					"public class X {\n" +
11608
					"   I i;\n" +
11609
					"	public static void main(String[] args) {\n" +
11610
					"		System.out.print(\"\");\n" +
11611
					"	}\n" +
11612
					"}",
11613
				},
11614
		        "\"" + OUTPUT_DIR +  File.separator + "X.java\""
11615
		        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11616
		        "",// this is not the runtime output
11617
		        "no classpath defined, using default directory instead\n" + 
11618
		        "----------\n" + 
11619
		        "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 1)\n" + 
11620
		        "	import p.Y.I;\n" + 
11621
		        "	       ^^^^^\n" + 
11622
		        "The import p.Y.I cannot be resolved\n" + 
11623
		        "----------\n" + 
11624
		        "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11625
		        "	I i;\n" + 
11626
		        "	^\n" + 
11627
		        "I cannot be resolved to a type\n" + 
11628
		        "----------\n" + 
11629
		        "2 problems (2 errors)",
11630
		        false);
11631
		final String userDir = System.getProperty("user.dir");
11632
		File f = new File(userDir, "X.java");
11633
		if (!Util.delete(f)) {
11634
			System.out.println("Could not delete X");
11635
		}
11636
		f = new File(userDir, "p" + File.separator + "Y.java");
11637
		if (!Util.delete(f)) {
11638
			System.out.println("Could not delete Y");
11639
		}
11640
11641
	} finally {
11642
		System.setProperty("java.class.path", javaClassspath);
11643
		System.setProperty("user.dir", javaUserDir);
11644
	}
11645
}
11646
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
11647
public void test0307d(){
11648
	final String javaClassspath = System.getProperty("java.class.path");
11649
	final String javaUserDir = System.getProperty("user.dir");
11650
	try {
11651
		System.setProperty("user.dir", OUTPUT_DIR);
11652
		this.runConformTest(
11653
			new String[] {
11654
				"p/Y.java",
11655
				"package P;\n" +
11656
				"public class Y { public class I {}; }",
11657
			},
11658
	        "\"" + OUTPUT_DIR +  File.separator + "p" + File.separator + "Y.java\""
11659
	        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11660
	        "",
11661
	        "",
11662
	        true);
11663
		System.setProperty("java.class.path", "");
11664
		this.runNegativeTest(
11665
				new String[] {
11666
					"X.java",
11667
					"import p.Y.I;\n" +
11668
					"public class X {\n" +
11669
					"   I i;\n" +
11670
					"	public static void main(String[] args) {\n" +
11671
					"		System.out.print(\"\");\n" +
11672
					"	}\n" +
11673
					"}",
11674
				},
11675
		        "\"" + OUTPUT_DIR +  File.separator + "X.java\""
11676
		        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11677
		        "",// this is not the runtime output
11678
		        "no classpath defined, using default directory instead\n" + 
11679
		        "----------\n" + 
11680
		        "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 1)\n" + 
11681
		        "	import p.Y.I;\n" + 
11682
		        "	       ^^^\n" + 
11683
		        "The import p.Y cannot be resolved\n" + 
11684
		        "----------\n" + 
11685
		        "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11686
		        "	I i;\n" + 
11687
		        "	^\n" + 
11688
		        "I cannot be resolved to a type\n" + 
11689
		        "----------\n" + 
11690
		        "2 problems (2 errors)",
11691
		        false);
11692
		final String userDir = System.getProperty("user.dir");
11693
		File f = new File(userDir, "X.java");
11694
		if (!Util.delete(f)) {
11695
			System.out.println("Could not delete X");
11696
		}
11697
		f = new File(userDir, "p" + File.separator + "Y.java");
11698
		if (!Util.delete(f)) {
11699
			System.out.println("Could not delete Y");
11700
		}
11701
11702
	} finally {
11703
		System.setProperty("java.class.path", javaClassspath);
11704
		System.setProperty("user.dir", javaUserDir);
11705
	}
11706
}
11707
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
11708
public void test0307e(){
11709
	final String javaClassspath = System.getProperty("java.class.path");
11710
	final String javaUserDir = System.getProperty("user.dir");
11711
	try {
11712
		System.setProperty("user.dir", OUTPUT_DIR);
11713
		this.runConformTest(
11714
			new String[] {
11715
				"p/Y.java",
11716
				"package P;\n" +
11717
				"public class Y { public class I {}; }",
11718
			},
11719
	        "\"" + OUTPUT_DIR +  File.separator + "P" + File.separator + "Y.java\""
11720
	        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11721
	        "",
11722
	        "",
11723
	        true);
11724
		System.setProperty("java.class.path", "");
11725
		this.runNegativeTest(
11726
				new String[] {
11727
					"X.java",
11728
					"import p.Y.I;\n" +
11729
					"public class X {\n" +
11730
					"   I i;\n" +
11731
					"	public static void main(String[] args) {\n" +
11732
					"		System.out.print(\"\");\n" +
11733
					"	}\n" +
11734
					"}",
11735
				},
11736
		        "\"" + OUTPUT_DIR +  File.separator + "X.java\""
11737
		        + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
11738
		        "",// this is not the runtime output
11739
		        "no classpath defined, using default directory instead\n" + 
11740
		        "----------\n" + 
11741
		        "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 1)\n" + 
11742
		        "	import p.Y.I;\n" + 
11743
		        "	       ^^^\n" + 
11744
		        "The import p.Y cannot be resolved\n" + 
11745
		        "----------\n" + 
11746
		        "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11747
		        "	I i;\n" + 
11748
		        "	^\n" + 
11749
		        "I cannot be resolved to a type\n" + 
11750
		        "----------\n" + 
11751
		        "2 problems (2 errors)",
11752
		        false);
11753
		final String userDir = System.getProperty("user.dir");
11754
		File f = new File(userDir, "X.java");
11755
		if (!Util.delete(f)) {
11756
			System.out.println("Could not delete X");
11757
		}
11758
		f = new File(userDir, "p" + File.separator + "Y.java");
11759
		if (!Util.delete(f)) {
11760
			System.out.println("Could not delete Y");
11761
		}
11762
11763
	} finally {
11764
		System.setProperty("java.class.path", javaClassspath);
11765
		System.setProperty("user.dir", javaUserDir);
11766
	}
11767
}
11413
}
11768
}

Return to bug 321115