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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-3 / +5 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Matt McCutchen
11
 *     		Partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995.
10
 *******************************************************************************/
12
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.ast;
13
package org.eclipse.jdt.internal.compiler.ast;
12
14
Lines 268-274 Link Here
268
		
270
		
269
		if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) {
271
		if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) {
270
			AccessRestriction restriction = 
272
			AccessRestriction restriction = 
271
				scope.environment().getAccessRestriction(field.declaringClass);
273
				scope.environment().getAccessRestriction(field.declaringClass.erasure());
272
			if (restriction != null) {
274
			if (restriction != null) {
273
				scope.problemReporter().forbiddenReference(field, this,
275
				scope.problemReporter().forbiddenReference(field, this,
274
						restriction.getFieldAccessMessageTemplate(), restriction.getProblemId());
276
						restriction.getFieldAccessMessageTemplate(), restriction.getProblemId());
Lines 306-312 Link Here
306
			// note: explicit constructors calls warnings are kept despite the 'new C1()' case (two
308
			// note: explicit constructors calls warnings are kept despite the 'new C1()' case (two
307
			//       warnings, one on type, the other on constructor), because of the 'super()' case.
309
			//       warnings, one on type, the other on constructor), because of the 'super()' case.
308
			AccessRestriction restriction = 
310
			AccessRestriction restriction = 
309
				scope.environment().getAccessRestriction(method.declaringClass);
311
				scope.environment().getAccessRestriction(method.declaringClass.erasure());
310
			if (restriction != null) {
312
			if (restriction != null) {
311
				if (method.isConstructor()) {
313
				if (method.isConstructor()) {
312
					scope.problemReporter().forbiddenReference(method, this,
314
					scope.problemReporter().forbiddenReference(method, this,
Lines 365-371 Link Here
365
		}
367
		}
366
		
368
		
367
		if (refType.hasRestrictedAccess()) {
369
		if (refType.hasRestrictedAccess()) {
368
			AccessRestriction restriction = scope.environment().getAccessRestriction(type);
370
			AccessRestriction restriction = scope.environment().getAccessRestriction(type.erasure());
369
			if (restriction != null) {
371
			if (restriction != null) {
370
				scope.problemReporter().forbiddenReference(type, this, restriction.getMessageTemplate(), restriction.getProblemId());
372
				scope.problemReporter().forbiddenReference(type, this, restriction.getMessageTemplate(), restriction.getProblemId());
371
			}
373
			}
(-)buildnotes_jdt-core.html (-1 / +3 lines)
Lines 57-63 Link Here
57
</ul>
57
</ul>
58
58
59
<h3>Problem Reports Fixed</h3>
59
<h3>Problem Reports Fixed</h3>
60
<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=123721">123721</a>
60
<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=122995">122995</a>
61
[1.5][compiler] Access rules don't apply to generic types
62
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=123721">123721</a>
61
two types of 'remove' for TODO task tags
63
two types of 'remove' for TODO task tags
62
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=123396">123396</a>
64
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=123396">123396</a>
63
Regression: NameLookup creation longs around 1mn on project with heavy hiearchy (200 src folders * 200 packages)
65
Regression: NameLookup creation longs around 1mn on project with heavy hiearchy (200 src folders * 200 packages)
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+71 lines)
Lines 2121-2126 Link Here
2121
		true);
2121
		true);
2122
}
2122
}
2123
2123
2124
// Missing access restriction violation error on generic type.
2125
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995
2126
// Binary case.
2127
public void test039(){
2128
	this.runConformTest(
2129
		new String[] {
2130
			"src1/p/X.java",
2131
			"package p;\n" +
2132
			"public class X<T> {\n" +
2133
			"	T m;\n" +
2134
			"}",
2135
		},
2136
        "\"" + OUTPUT_DIR + "/src1/p/X.java\""
2137
        + " -1.5 -g -preserveAllLocals"
2138
        + " -proceedOnError -referenceInfo" 
2139
        + " -d \"" + OUTPUT_DIR + "/bin1/\"",
2140
        "",
2141
        "",
2142
        true);
2143
	this.runConformTest(
2144
		new String[] {
2145
			"src2/Y.java",
2146
			"package p;\n" +
2147
			"public class Y {\n" +
2148
			"	X x1;\n" +
2149
			"	X<String> x2 = new X<String>();\n" +
2150
			"}",
2151
		},
2152
        "\"" + OUTPUT_DIR +  File.separator + "src2/Y.java\""
2153
        + " -1.5 -g -preserveAllLocals"
2154
        + " -cp \"" + OUTPUT_DIR + File.separator + "bin1[~**/X]\""
2155
        + " -proceedOnError -referenceInfo"
2156
        + " -d \"" + OUTPUT_DIR + File.separator + "bin2/\"",
2157
        "",
2158
		"----------\n" + 
2159
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---" +
2160
		File.separator + "src2" +
2161
		File.separator + "Y.java\n" + 
2162
		" (at line 3)\n" + 
2163
		"	X x1;\n" + 
2164
		"	^\n" + 
2165
		"Discouraged access: X<T>\n" + 
2166
		"----------\n" + 
2167
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---" +
2168
		File.separator + "src2" +
2169
		File.separator + "Y.java\n" + 
2170
		" (at line 4)\n" + 
2171
		"	X<String> x2 = new X<String>();\n" + 
2172
		"	^\n" + 
2173
		"Discouraged access: X<String>\n" + 
2174
		"----------\n" + 
2175
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---" +
2176
		File.separator + "src2" +
2177
		File.separator + "Y.java\n" + 
2178
		" (at line 4)\n" + 
2179
		"	X<String> x2 = new X<String>();\n" + 
2180
		"	               ^^^^^^^^^^^^^^^\n" + 
2181
		"Discouraged access: X<String>()\n" + 
2182
		"----------\n" + 
2183
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---" +
2184
		File.separator + "src2" +
2185
		File.separator + "Y.java\n" + 
2186
		" (at line 4)\n" + 
2187
		"	X<String> x2 = new X<String>();\n" + 
2188
		"	                   ^\n" + 
2189
		"Discouraged access: X<String>\n" + 
2190
		"----------\n" + 
2191
		"4 problems (4 warnings)",
2192
        false);
2193
}
2194
2124
public static Class testClass() {
2195
public static Class testClass() {
2125
	return BatchCompilerTest.class;
2196
	return BatchCompilerTest.class;
2126
}
2197
}
(-)src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java (+486 lines)
Lines 539-542 Link Here
539
		deleteProjects(new String[] {"P1", "P2"});
539
		deleteProjects(new String[] {"P1", "P2"});
540
	}
540
	}
541
}
541
}
542
543
/*
544
 * Missing access restriction violation error on generic type.
545
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995
546
 */
547
public void test006() throws CoreException {
548
	ICompilationUnit x = null, y =  null;
549
	try {
550
		WorkingCopyOwner owner = new WorkingCopyOwner(){};
551
		IJavaProject p1 = createJavaProject(
552
			"P1", 
553
			new String[] {"src"}, 
554
			new String[] {"JCL_LIB"}, 
555
			"bin");
556
		p1.setOption("org.eclipse.jdt.core.compiler.compliance", "1.5");
557
		p1.setOption("org.eclipse.jdt.core.compiler.source", "1.5");
558
		p1.setOption("org.eclipse.jdt.core.compiler.targetPlatform", "1.5");
559
		this.problemRequestor = new ProblemRequestor();
560
		x = getWorkingCopy(
561
			"/P1/src/p/X.java",
562
			"package p;\n" +
563
			"public class X<T> {\n" +
564
			"	T m;\n" +
565
			"}",
566
			owner,
567
			this.problemRequestor);	
568
		assertProblems(
569
			"Unexpected problems", 
570
			"----------\n" + 
571
			"----------\n"
572
		);
573
		IJavaProject p2 = createJavaProject(
574
				"P2", 
575
				new String[] {"src"}, 
576
				new String[] {"JCL_LIB"}, 
577
				"bin");
578
		p2.setOption("org.eclipse.jdt.core.compiler.compliance", "1.5");
579
		p2.setOption("org.eclipse.jdt.core.compiler.source", "1.5");
580
		p2.setOption("org.eclipse.jdt.core.compiler.targetPlatform", "1.5");
581
		IClasspathEntry[] classpath = p2.getRawClasspath();
582
		int length = classpath.length;
583
		System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length+1], 0, length);
584
		classpath[length] = createSourceEntry("P2", "/P1", "-p/X");
585
		p2.setRawClasspath(classpath, null);
586
		String src =
587
			"package p;\n" +
588
			"public class Y {\n" +
589
			"	X x1;\n" +
590
			"	X<String> x2 = new X<String>();\n" +
591
			"}";
592
		this.problemRequestor = new ProblemRequestor(src);
593
		y = getWorkingCopy(			
594
			"/P2/src/p/Y.java", 
595
			src,
596
			owner,
597
			this.problemRequestor);
598
		assertProblems(
599
			"Unexpected problems value", 
600
			"----------\n" + 
601
			"1. ERROR in /P2/src/p/Y.java (at line 3)\n" + 
602
			"	X x1;\n" + 
603
			"	^\n" + 
604
			"Access restriction: The type X<T> is not accessible due to restriction on required project P1\n" + 
605
			"----------\n" + 
606
			"2. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
607
			"	X<String> x2 = new X<String>();\n" + 
608
			"	^\n" + 
609
			"Access restriction: The type X<String> is not accessible due to restriction on required project P1\n" + 
610
			"----------\n" + 
611
			"3. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
612
			"	X<String> x2 = new X<String>();\n" + 
613
			"	               ^^^^^^^^^^^^^^^\n" + 
614
			"Access restriction: The constructor X<String>() is not accessible due to restriction on required project P1\n" + 
615
			"----------\n" + 
616
			"4. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
617
			"	X<String> x2 = new X<String>();\n" + 
618
			"	                   ^\n" + 
619
			"Access restriction: The type X<String> is not accessible due to restriction on required project P1\n" + 
620
			"----------\n");
621
	} finally {
622
		if (x != null) {
623
			x.discardWorkingCopy();
624
		}
625
		if (y != null) {
626
			y.discardWorkingCopy();
627
		}
628
		deleteProjects(new String[] {"P1", "P2"});
629
	}
630
}
631
632
/*
633
 * Missing access restriction violation error on generic type.
634
 * More complex type parameter - stretch the erasure.
635
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995
636
 */
637
public void test007() throws CoreException {
638
	ICompilationUnit x = null, y =  null;
639
	try {
640
		WorkingCopyOwner owner = new WorkingCopyOwner(){};
641
		IJavaProject p1 = createJavaProject(
642
			"P1", 
643
			new String[] {"src"}, 
644
			new String[] {"JCL_LIB"}, 
645
			"bin");
646
		p1.setOption("org.eclipse.jdt.core.compiler.compliance", "1.5");
647
		p1.setOption("org.eclipse.jdt.core.compiler.source", "1.5");
648
		p1.setOption("org.eclipse.jdt.core.compiler.targetPlatform", "1.5");
649
		this.problemRequestor = new ProblemRequestor();
650
		x = getWorkingCopy(
651
			"/P1/src/p/X.java",
652
			"package p;\n" +
653
			"public class X<T extends String> {\n" +
654
			"  T m;\n" +
655
			"  public X (T t) {\n" +
656
			"    this.m = t;\n" +
657
			"  }\n" +
658
			"}",
659
			owner,
660
			this.problemRequestor);	
661
		assertProblems(
662
			"Unexpected problems", 
663
			"----------\n" + 
664
			"----------\n"
665
		);
666
		IJavaProject p2 = createJavaProject(
667
				"P2", 
668
				new String[] {"src"}, 
669
				new String[] {"JCL_LIB"}, 
670
				"bin");
671
		p2.setOption("org.eclipse.jdt.core.compiler.compliance", "1.5");
672
		p2.setOption("org.eclipse.jdt.core.compiler.source", "1.5");
673
		p2.setOption("org.eclipse.jdt.core.compiler.targetPlatform", "1.5");
674
		IClasspathEntry[] classpath = p2.getRawClasspath();
675
		int length = classpath.length;
676
		System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length+1], 0, length);
677
		classpath[length] = createSourceEntry("P2", "/P1", "-p/X");
678
		p2.setRawClasspath(classpath, null);
679
		String src =
680
			"package p;\n" +
681
			"public class Y {\n" +
682
			"	X x1;\n" +
683
			"	X<String> x2 = new X<String>(\"\");\n" +
684
			"}";
685
		this.problemRequestor = new ProblemRequestor(src);
686
		y = getWorkingCopy(			
687
			"/P2/src/p/Y.java", 
688
			src,
689
			owner,
690
			this.problemRequestor);
691
		assertProblems(
692
			"Unexpected problems value", 
693
			"----------\n" + 
694
			"1. ERROR in /P2/src/p/Y.java (at line 3)\n" + 
695
			"	X x1;\n" + 
696
			"	^\n" + 
697
			"Access restriction: The type X<T> is not accessible due to restriction on required project P1\n" + 
698
			"----------\n" + 
699
			"2. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
700
			"	X<String> x2 = new X<String>(\"\");\n" + 
701
			"	^\n" + 
702
			"Access restriction: The type X<String> is not accessible due to restriction on required project P1\n" + 
703
			"----------\n" + 
704
			"3. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
705
			"	X<String> x2 = new X<String>(\"\");\n" + 
706
			"	               ^^^^^^^^^^^^^^^^^\n" + 
707
			"Access restriction: The constructor X<String>(String) is not accessible due to restriction on required project P1\n" + 
708
			"----------\n" + 
709
			"4. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
710
			"	X<String> x2 = new X<String>(\"\");\n" + 
711
			"	                   ^\n" + 
712
			"Access restriction: The type X<String> is not accessible due to restriction on required project P1\n" + 
713
			"----------\n");
714
	} finally {
715
		if (x != null) {
716
			x.discardWorkingCopy();
717
		}
718
		if (y != null) {
719
			y.discardWorkingCopy();
720
		}
721
		deleteProjects(new String[] {"P1", "P2"});
722
	}
723
}
724
725
/*
726
 * Missing access restriction violation error on generic type.
727
 * Method case.
728
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995
729
 */
730
public void test008() throws CoreException {
731
	ICompilationUnit x1 = null, x2 = null, y =  null;
732
	try {
733
		WorkingCopyOwner owner = new WorkingCopyOwner(){};
734
		IJavaProject p1 = createJavaProject(
735
			"P1", 
736
			new String[] {"src"}, 
737
			new String[] {"JCL_LIB"}, 
738
			"bin");
739
		p1.setOption("org.eclipse.jdt.core.compiler.compliance", "1.5");
740
		p1.setOption("org.eclipse.jdt.core.compiler.source", "1.5");
741
		p1.setOption("org.eclipse.jdt.core.compiler.targetPlatform", "1.5");		
742
		this.problemRequestor = new ProblemRequestor();
743
		x1 = getWorkingCopy(
744
			"/P1/src/p/X1.java",
745
			"package p;\n" +
746
			"public class X1<T> {\n" +
747
			"	void foo() {\n" +
748
			"	}\n" +
749
			"}",
750
			owner,
751
			this.problemRequestor);	
752
		assertProblems(
753
			"Unexpected problems", 
754
			"----------\n" + 
755
			"----------\n"
756
		);
757
		x2 = getWorkingCopy(			
758
			"/P1/src/p/X2.java",
759
			"package p;\n" +
760
			"public class X2 extends X1 {\n" +
761
			"	void bar() {\n" +
762
			"	}\n" +
763
			"}",			owner,
764
			this.problemRequestor);
765
		assertProblems(
766
			"Unexpected problems", 
767
			"----------\n" + 
768
			"----------\n"
769
		);
770
		IJavaProject p2 = createJavaProject("P2", new String[] {"src"}, 
771
				new String[] {"JCL_LIB"}, "bin");
772
		p2.setOption("org.eclipse.jdt.core.compiler.compliance", "1.5");
773
		p2.setOption("org.eclipse.jdt.core.compiler.source", "1.5");
774
		p2.setOption("org.eclipse.jdt.core.compiler.targetPlatform", "1.5");		
775
		IClasspathEntry[] classpath = p2.getRawClasspath();
776
		int length = classpath.length;
777
		System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length+1], 0, length);
778
		classpath[length] = createSourceEntry("P2", "/P1", "-p/X1");
779
		p2.setRawClasspath(classpath, null);
780
		String src = 
781
			"package p;\n" +
782
			"public class Y extends X2 {\n" +
783
			"	void foobar() {\n" +
784
			"		foo(); // accesses X1.foo, should trigger an error\n" +
785
			"		bar(); // accesses X2.bar, OK\n" +
786
			"	}\n" +
787
			"}";
788
		this.problemRequestor = new ProblemRequestor(src);
789
		y = getWorkingCopy(			
790
			"/P2/src/p/Y.java", 
791
			src,
792
			owner,
793
			this.problemRequestor);
794
		assertProblems(
795
			"Unexpected problems value", 
796
			"----------\n" + 
797
			"1. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
798
			"	foo(); // accesses X1.foo, should trigger an error\n" + 
799
			"	^^^^^\n" + 
800
			"Access restriction: The method foo() from the type X1 is not accessible due to restriction on required project P1\n" + 
801
			"----------\n"
802
		);
803
	} finally {
804
		if (x1 != null)
805
			x1.discardWorkingCopy();
806
		if (x2 != null)
807
			x2.discardWorkingCopy();
808
		if (y != null)
809
			y.discardWorkingCopy();
810
		deleteProjects(new String[] {"P1", "P2"});
811
	}
812
}
813
814
/*
815
 * Missing access restriction violation error on generic type.
816
 * Field case.
817
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995
818
 */
819
public void test009() throws CoreException {
820
	ICompilationUnit x1 = null, x2 = null, y =  null;
821
	try {
822
		WorkingCopyOwner owner = new WorkingCopyOwner(){};
823
		IJavaProject p1 = createJavaProject(
824
			"P1", 
825
			new String[] {"src"}, 
826
			new String[] {"JCL_LIB"}, 
827
			"bin");
828
		p1.setOption("org.eclipse.jdt.core.compiler.compliance", "1.5");
829
		p1.setOption("org.eclipse.jdt.core.compiler.source", "1.5");
830
		p1.setOption("org.eclipse.jdt.core.compiler.targetPlatform", "1.5");		
831
		this.problemRequestor = new ProblemRequestor();
832
		x1 = getWorkingCopy(
833
			"/P1/src/p/X1.java",
834
			"package p;\n" +
835
			"public class X1<T> {\n" +
836
			"	int m1;\n" +
837
			"}",
838
			owner,
839
			this.problemRequestor);	
840
		assertProblems(
841
			"Unexpected problems", 
842
			"----------\n" + 
843
			"----------\n"
844
		);
845
		x2 = getWorkingCopy(			
846
			"/P1/src/p/X2.java",
847
			"package p;\n" +
848
			"public class X2 extends X1 {\n" +
849
			"	char m2;\n" +
850
			"}",
851
			owner,
852
			this.problemRequestor);
853
		assertProblems(
854
			"Unexpected problems", 
855
			"----------\n" + 
856
			"----------\n"
857
		);
858
		IJavaProject p2 = createJavaProject("P2", new String[] {"src"}, 
859
				new String[] {"JCL_LIB"}, "bin");
860
		p2.setOption("org.eclipse.jdt.core.compiler.compliance", "1.5");
861
		p2.setOption("org.eclipse.jdt.core.compiler.source", "1.5");
862
		p2.setOption("org.eclipse.jdt.core.compiler.targetPlatform", "1.5");		
863
		IClasspathEntry[] classpath = p2.getRawClasspath();
864
		int length = classpath.length;
865
		System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length+1], 0, length);
866
		classpath[length] = createSourceEntry("P2", "/P1", "-p/X1");
867
		p2.setRawClasspath(classpath, null);
868
		String src = 
869
			"package p;\n" +
870
			"public class Y extends X2 {\n" +
871
			"	void foobar() {\n" +
872
			"		int l1 = m1; // accesses X1.m1, should trigger an error\n" +
873
			"		char l2 = m2; // accesses X2.m2, OK\n" +
874
			"	}\n" +
875
			"}";
876
		this.problemRequestor = new ProblemRequestor(src);
877
		y = getWorkingCopy(			
878
			"/P2/src/p/Y.java", 
879
			src,
880
			owner,
881
			this.problemRequestor);
882
		assertProblems(
883
			"Unexpected problems value", 
884
			"----------\n" + 
885
			"1. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
886
			"	int l1 = m1; // accesses X1.m1, should trigger an error\n" + 
887
			"	         ^^\n" + 
888
			"Access restriction: The field m1 from the type X1 is not accessible due to restriction on required project P1\n" + 
889
			"----------\n"
890
		);
891
	} finally {
892
		if (x1 != null)
893
			x1.discardWorkingCopy();
894
		if (x2 != null)
895
			x2.discardWorkingCopy();
896
		if (y != null)
897
			y.discardWorkingCopy();
898
		deleteProjects(new String[] {"P1", "P2"});
899
	}
900
}
901
902
/*
903
 * Missing access restriction violation error on generic type.
904
 * Inner type case.
905
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995
906
 */
907
public void test010() throws CoreException {
908
	ICompilationUnit x1 = null, x2 = null, y =  null;
909
	try {
910
		WorkingCopyOwner owner = new WorkingCopyOwner(){};
911
		IJavaProject p1 = createJavaProject(
912
			"P1", 
913
			new String[] {"src"}, 
914
			new String[] {"JCL_LIB"}, 
915
			"bin");
916
		p1.setOption("org.eclipse.jdt.core.compiler.compliance", "1.5");
917
		p1.setOption("org.eclipse.jdt.core.compiler.source", "1.5");
918
		p1.setOption("org.eclipse.jdt.core.compiler.targetPlatform", "1.5");		
919
		this.problemRequestor = new ProblemRequestor();
920
		x1 = getWorkingCopy(
921
			"/P1/src/p/X1.java",
922
			"package p;\n" +
923
			"public class X1<T> {\n" +
924
			"	class C1 {\n" +
925
			"	   protected C1 (int dummy) {}\n" +
926
			"	   protected void foo() {}\n" +
927
			"	}\n" +
928
			"	interface I1 {}\n" +
929
			"}",
930
			owner,
931
			this.problemRequestor);	
932
		assertProblems(
933
			"Unexpected problems", 
934
			"----------\n" + 
935
			"----------\n"
936
		);
937
		x2 = getWorkingCopy(			
938
			"/P1/src/p/X2.java",
939
			"package p;\n" +
940
			"public class X2 extends X1 {\n" +
941
			"	class C2 {}\n" +
942
			"	interface I2 {}\n" +
943
			"}",
944
			owner,
945
			this.problemRequestor);
946
		assertProblems(
947
			"Unexpected problems", 
948
			"----------\n" + 
949
			"----------\n"
950
		);
951
		IJavaProject p2 = createJavaProject("P2", new String[] {"src"}, 
952
				new String[] {"JCL_LIB"}, "bin");
953
		p2.setOption("org.eclipse.jdt.core.compiler.compliance", "1.5");
954
		p2.setOption("org.eclipse.jdt.core.compiler.source", "1.5");
955
		p2.setOption("org.eclipse.jdt.core.compiler.targetPlatform", "1.5");		
956
		IClasspathEntry[] classpath = p2.getRawClasspath();
957
		int length = classpath.length;
958
		System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length+1], 0, length);
959
		classpath[length] = createSourceEntry("P2", "/P1", "-p/X1");
960
		p2.setRawClasspath(classpath, null);
961
		String src =
962
			"package p;\n" +
963
			"public class Y extends X2 {\n" +
964
			"	class C3a extends C1 {      // error\n" +
965
			"	   C3a() {\n" +
966
			"	      super(0);\n" +
967
			"	      foo();                // error\n" +
968
			"	   }\n" +
969
			"	}\n" +
970
			"	class C3c extends C2 implements I2 {}\n" +
971
			"	void foobar() {\n" +
972
			"		C1 m1 =                 // error\n" +
973
			"		        new C1(0);      // error\n" +
974
			"		C2 m2 = new C2();\n" +
975
			"	}\n" +
976
			"}";
977
		this.problemRequestor = new ProblemRequestor(src);
978
		y = getWorkingCopy(			
979
			"/P2/src/p/Y.java", 
980
			src,
981
			owner,
982
			this.problemRequestor);
983
		assertProblems(
984
			"Unexpected problems value", 
985
			"----------\n" + 
986
			"1. ERROR in /P2/src/p/Y.java (at line 3)\n" + 
987
			"	class C3a extends C1 {      // error\n" + 
988
			"	                  ^^\n" + 
989
			"Access restriction: The type X1.C1 is not accessible due to restriction on required project P1\n" + 
990
			"----------\n" + 
991
			"2. ERROR in /P2/src/p/Y.java (at line 5)\n" + 
992
			"	super(0);\n" + 
993
			"	^^^^^^^^\n" + 
994
			"Access restriction: The constructor X1.C1(int) is not accessible due to restriction on required project P1\n" + 
995
			"----------\n" + 
996
			"3. ERROR in /P2/src/p/Y.java (at line 6)\n" + 
997
			"	foo();                // error\n" + 
998
			"	^^^^^\n" + 
999
			"Access restriction: The method foo() from the type X1.C1 is not accessible due to restriction on required project P1\n" + 
1000
			"----------\n" + 
1001
			"4. ERROR in /P2/src/p/Y.java (at line 11)\n" + 
1002
			"	C1 m1 =                 // error\n" + 
1003
			"	^^\n" + 
1004
			"Access restriction: The type X1.C1 is not accessible due to restriction on required project P1\n" + 
1005
			"----------\n" + 
1006
			"5. ERROR in /P2/src/p/Y.java (at line 12)\n" + 
1007
			"	new C1(0);      // error\n" + 
1008
			"	^^^^^^^^^\n" + 
1009
			"Access restriction: The constructor X1.C1(int) is not accessible due to restriction on required project P1\n" + 
1010
			"----------\n" + 
1011
			"6. ERROR in /P2/src/p/Y.java (at line 12)\n" + 
1012
			"	new C1(0);      // error\n" + 
1013
			"	    ^^\n" + 
1014
			"Access restriction: The type X1.C1 is not accessible due to restriction on required project P1\n" + 
1015
			"----------\n"
1016
		);
1017
	} finally {
1018
		if (x1 != null)
1019
			x1.discardWorkingCopy();
1020
		if (x2 != null)
1021
			x2.discardWorkingCopy();
1022
		if (y != null)
1023
			y.discardWorkingCopy();
1024
		deleteProjects(new String[] {"P1", "P2"});
1025
	}
1026
}
1027
542
}
1028
}

Return to bug 122995