Lines 4632-4635
Link Here
|
4632 |
deleteProject(project15); |
4632 |
deleteProject(project15); |
4633 |
} |
4633 |
} |
4634 |
} |
4634 |
} |
|
|
4635 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=323633 |
4636 |
public void testGenericAPIUsageFromA14Project3() throws CoreException { |
4637 |
IJavaProject project14 = null; |
4638 |
IJavaProject project15 = null; |
4639 |
try { |
4640 |
project15 = createJavaProject("Reconciler15API", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin"); |
4641 |
createFolder("/Reconciler15API/src/p2"); |
4642 |
createFile( |
4643 |
"/Reconciler15API/src/p2/X.java", |
4644 |
"package p2;\n" + |
4645 |
"import java.util.Collection;\n" + |
4646 |
"import java.util.Iterator;\n" + |
4647 |
"public class X<E> implements Collection<E>{\n" + |
4648 |
" public static X getX() {\n" + |
4649 |
" return new X();\n" + |
4650 |
" }\n" + |
4651 |
" public int size() {\n" + |
4652 |
" return 0;\n" + |
4653 |
" }\n" + |
4654 |
" public boolean isEmpty() {\n" + |
4655 |
" return false;\n" + |
4656 |
" }\n" + |
4657 |
" public boolean contains(Object o) {\n" + |
4658 |
" return false;\n" + |
4659 |
" }\n" + |
4660 |
" public Iterator<E> iterator() {\n" + |
4661 |
" return null;\n" + |
4662 |
" }\n" + |
4663 |
" public Object[] toArray() {\n" + |
4664 |
" return null;\n" + |
4665 |
" }\n" + |
4666 |
" public <T> T[] toArray(T[] a) {\n" + |
4667 |
" return null;\n" + |
4668 |
" }\n" + |
4669 |
" public boolean add(E e) {\n" + |
4670 |
" return false;\n" + |
4671 |
" }\n" + |
4672 |
" public boolean remove(Object o) {\n" + |
4673 |
" return false;\n" + |
4674 |
" }\n" + |
4675 |
" public boolean containsAll(Collection<?> c) {\n" + |
4676 |
" return false;\n" + |
4677 |
" }\n" + |
4678 |
" public boolean addAll(Collection<? extends E> c) {\n" + |
4679 |
" return false;\n" + |
4680 |
" }\n" + |
4681 |
" public boolean removeAll(Collection<?> c) {\n" + |
4682 |
" return false;\n" + |
4683 |
" }\n" + |
4684 |
" public boolean retainAll(Collection<?> c) {\n" + |
4685 |
" return false;\n" + |
4686 |
" }\n" + |
4687 |
" public void clear() {\n" + |
4688 |
" }\n" + |
4689 |
"}\n" |
4690 |
); |
4691 |
project15.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); |
4692 |
project15.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); |
4693 |
project15.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); |
4694 |
|
4695 |
project14 = createJavaProject("Reconciler1415", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin"); |
4696 |
project14.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4); |
4697 |
project14.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); |
4698 |
project14.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4); |
4699 |
|
4700 |
IClasspathEntry[] oldClasspath = project14.getRawClasspath(); |
4701 |
int oldLength = oldClasspath.length; |
4702 |
IClasspathEntry[] newClasspath = new IClasspathEntry[oldLength+1]; |
4703 |
System.arraycopy(oldClasspath, 0, newClasspath, 0, oldLength); |
4704 |
newClasspath[oldLength] = JavaCore.newProjectEntry(new Path("/Reconciler15API")); |
4705 |
project14.setRawClasspath(newClasspath, null); |
4706 |
|
4707 |
createFolder("/Reconciler1415/src/p1"); |
4708 |
String source = |
4709 |
"package p1;\n" + |
4710 |
"import java.util.Collection;\n" + |
4711 |
"public class X {\n" + |
4712 |
" public static void main(String string) {\n" + |
4713 |
" Collection c = p2.X.getX(); \n" + |
4714 |
" }\n" + |
4715 |
"}"; |
4716 |
|
4717 |
createFile( |
4718 |
"/Reconciler1415/src/p1/X.java", |
4719 |
source |
4720 |
); |
4721 |
|
4722 |
this.workingCopies = new ICompilationUnit[1]; |
4723 |
char[] sourceChars = source.toCharArray(); |
4724 |
this.problemRequestor.initialize(sourceChars); |
4725 |
this.workingCopies[0] = getCompilationUnit("/Reconciler1415/src/p1/X.java").getWorkingCopy(this.wcOwner, null); |
4726 |
assertProblems( |
4727 |
"Unexpected problems", |
4728 |
"----------\n" + |
4729 |
"1. WARNING in /Reconciler1415/src/p1/X.java (at line 5)\n" + |
4730 |
" Collection c = p2.X.getX(); \n" + |
4731 |
" ^\n" + |
4732 |
"The local variable c is never read\n" + |
4733 |
"----------\n" |
4734 |
); |
4735 |
} finally { |
4736 |
if (project14 != null) |
4737 |
deleteProject(project14); |
4738 |
if (project15 != null) |
4739 |
deleteProject(project15); |
4740 |
} |
4741 |
} |
4742 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=323633 (variation: 15 uses 14) |
4743 |
public void testGenericAPIUsageFromA14Project4() throws CoreException { |
4744 |
IJavaProject project14 = null; |
4745 |
IJavaProject project15 = null; |
4746 |
try { |
4747 |
project14 = createJavaProject("Reconciler1415", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin"); |
4748 |
createFolder("/Reconciler1415/src/p1"); |
4749 |
String source = |
4750 |
"package p1;\n" + |
4751 |
"import java.lang.Comparable;\n" + |
4752 |
"public class X implements Comparable {\n" + |
4753 |
" public static X getX() {\n" + |
4754 |
" return new X();\n" + |
4755 |
" }\n" + |
4756 |
"}"; |
4757 |
|
4758 |
createFile( |
4759 |
"/Reconciler1415/src/p1/X.java", |
4760 |
source |
4761 |
); |
4762 |
|
4763 |
project14.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4); |
4764 |
project14.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); |
4765 |
project14.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4); |
4766 |
|
4767 |
project15 = createJavaProject("Reconciler15API", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin"); |
4768 |
createFolder("/Reconciler15API/src/p2"); |
4769 |
String otherSource = "package p2;\n" + |
4770 |
"public class X { \n" + |
4771 |
" private p1.X x = p1.X.getX();\n" + |
4772 |
" Comparable<String> y = null;\n" + |
4773 |
"}\n"; |
4774 |
|
4775 |
createFile( |
4776 |
"/Reconciler15API/src/p2/X.java", |
4777 |
otherSource |
4778 |
); |
4779 |
project15.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); |
4780 |
project15.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); |
4781 |
project15.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); |
4782 |
|
4783 |
IClasspathEntry[] oldClasspath = project15.getRawClasspath(); |
4784 |
int oldLength = oldClasspath.length; |
4785 |
IClasspathEntry[] newClasspath = new IClasspathEntry[oldLength+1]; |
4786 |
System.arraycopy(oldClasspath, 0, newClasspath, 0, oldLength); |
4787 |
newClasspath[oldLength] = JavaCore.newProjectEntry(new Path("/Reconciler1415")); |
4788 |
project15.setRawClasspath(newClasspath, null); |
4789 |
|
4790 |
this.workingCopies = new ICompilationUnit[1]; |
4791 |
char[] sourceChars = otherSource.toCharArray(); |
4792 |
this.problemRequestor.initialize(sourceChars); |
4793 |
this.workingCopies[0] = getCompilationUnit("/Reconciler15API/src/p2/X.java").getWorkingCopy(this.wcOwner, null); |
4794 |
assertProblems( |
4795 |
"Unexpected problems", |
4796 |
"----------\n" + |
4797 |
"1. WARNING in /Reconciler15API/src/p2/X.java (at line 3)\n" + |
4798 |
" private p1.X x = p1.X.getX();\n" + |
4799 |
" ^\n" + |
4800 |
"The field X.x is never read locally\n" + |
4801 |
"----------\n" |
4802 |
); |
4803 |
} finally { |
4804 |
if (project14 != null) |
4805 |
deleteProject(project14); |
4806 |
if (project15 != null) |
4807 |
deleteProject(project15); |
4808 |
} |
4809 |
} |
4635 |
} |
4810 |
} |