Lines 4498-4501
Link Here
|
4498 |
ast |
4498 |
ast |
4499 |
); |
4499 |
); |
4500 |
} |
4500 |
} |
|
|
4501 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259 |
4502 |
public void testGenericAPIUsageFromA14Project() throws CoreException { |
4503 |
IJavaProject project14 = null; |
4504 |
IJavaProject project15 = null; |
4505 |
try { |
4506 |
project15 = createJavaProject("Reconciler15API", new String[] {"src"}, new String[] {"JCL_LIB"}, "bin"); |
4507 |
createFolder("/Reconciler15API/src/p2"); |
4508 |
createFile( |
4509 |
"/Reconciler15API/src/p2/BundleContext.java", |
4510 |
"package p2;\n" + |
4511 |
"public class BundleContext {\n" + |
4512 |
" public <S> S getService(S s) {\n" + |
4513 |
" return null;\n" + |
4514 |
" }\n" + |
4515 |
"}" |
4516 |
); |
4517 |
project15.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); |
4518 |
project15.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); |
4519 |
project15.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); |
4520 |
|
4521 |
project14 = createJavaProject("Reconciler1415", new String[] {"src"}, new String[] {"JCL_LIB"}, "bin"); |
4522 |
project14.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4); |
4523 |
project14.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); |
4524 |
project14.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4); |
4525 |
|
4526 |
IClasspathEntry[] oldClasspath = project14.getRawClasspath(); |
4527 |
int oldLength = oldClasspath.length; |
4528 |
IClasspathEntry[] newClasspath = new IClasspathEntry[oldLength+1]; |
4529 |
System.arraycopy(oldClasspath, 0, newClasspath, 0, oldLength); |
4530 |
newClasspath[oldLength] = JavaCore.newProjectEntry(new Path("/Reconciler15API")); |
4531 |
project14.setRawClasspath(newClasspath, null); |
4532 |
|
4533 |
createFolder("/Reconciler1415/src/p1"); |
4534 |
String source = |
4535 |
"package p1;\n" + |
4536 |
"import p2.BundleContext;\n" + |
4537 |
"public class X {\n" + |
4538 |
" public static void main(BundleContext context, String string) {\n" + |
4539 |
" String s = (String) context.getService(string); \n" + |
4540 |
" }\n" + |
4541 |
"}"; |
4542 |
|
4543 |
createFile( |
4544 |
"/Reconciler1415/src/p1/X.java", |
4545 |
source |
4546 |
); |
4547 |
|
4548 |
this.workingCopies = new ICompilationUnit[1]; |
4549 |
char[] sourceChars = source.toCharArray(); |
4550 |
this.problemRequestor.initialize(sourceChars); |
4551 |
this.workingCopies[0] = getCompilationUnit("/Reconciler1415/src/p1/X.java").getWorkingCopy(this.wcOwner, null); |
4552 |
assertProblems( |
4553 |
"Unexpected problems", |
4554 |
"----------\n" + |
4555 |
"1. WARNING in /Reconciler1415/src/p1/X.java (at line 5)\n" + |
4556 |
" String s = (String) context.getService(string); \n" + |
4557 |
" ^\n" + |
4558 |
"The local variable s is never read\n" + |
4559 |
"----------\n" |
4560 |
); |
4561 |
} finally { |
4562 |
if (project14 != null) |
4563 |
deleteProject(project14); |
4564 |
if (project15 != null) |
4565 |
deleteProject(project15); |
4566 |
} |
4567 |
} |
4568 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259 (same as above, but with a JSR14 target) |
4569 |
public void testGenericAPIUsageFromA14Project2() throws CoreException { |
4570 |
IJavaProject project14 = null; |
4571 |
IJavaProject project15 = null; |
4572 |
try { |
4573 |
project15 = createJavaProject("Reconciler15API", new String[] {"src"}, new String[] {"JCL_LIB"}, "bin"); |
4574 |
createFolder("/Reconciler15API/src/p2"); |
4575 |
createFile( |
4576 |
"/Reconciler15API/src/p2/BundleContext.java", |
4577 |
"package p2;\n" + |
4578 |
"public class BundleContext {\n" + |
4579 |
" public <S> S getService(S s) {\n" + |
4580 |
" return null;\n" + |
4581 |
" }\n" + |
4582 |
"}" |
4583 |
); |
4584 |
project15.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); |
4585 |
project15.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); |
4586 |
project15.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4); |
4587 |
|
4588 |
project14 = createJavaProject("Reconciler1415", new String[] {"src"}, new String[] {"JCL_LIB"}, "bin"); |
4589 |
project14.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4); |
4590 |
project14.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); |
4591 |
project14.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4); |
4592 |
|
4593 |
IClasspathEntry[] oldClasspath = project14.getRawClasspath(); |
4594 |
int oldLength = oldClasspath.length; |
4595 |
IClasspathEntry[] newClasspath = new IClasspathEntry[oldLength+1]; |
4596 |
System.arraycopy(oldClasspath, 0, newClasspath, 0, oldLength); |
4597 |
newClasspath[oldLength] = JavaCore.newProjectEntry(new Path("/Reconciler15API")); |
4598 |
project14.setRawClasspath(newClasspath, null); |
4599 |
|
4600 |
createFolder("/Reconciler1415/src/p1"); |
4601 |
String source = |
4602 |
"package p1;\n" + |
4603 |
"import p2.BundleContext;\n" + |
4604 |
"public class X {\n" + |
4605 |
" public static void main(BundleContext context, String string) {\n" + |
4606 |
" String s = (String) context.getService(string); \n" + |
4607 |
" }\n" + |
4608 |
"}"; |
4609 |
|
4610 |
createFile( |
4611 |
"/Reconciler1415/src/p1/X.java", |
4612 |
source |
4613 |
); |
4614 |
|
4615 |
this.workingCopies = new ICompilationUnit[1]; |
4616 |
char[] sourceChars = source.toCharArray(); |
4617 |
this.problemRequestor.initialize(sourceChars); |
4618 |
this.workingCopies[0] = getCompilationUnit("/Reconciler1415/src/p1/X.java").getWorkingCopy(this.wcOwner, null); |
4619 |
assertProblems( |
4620 |
"Unexpected problems", |
4621 |
"----------\n" + |
4622 |
"1. WARNING in /Reconciler1415/src/p1/X.java (at line 5)\n" + |
4623 |
" String s = (String) context.getService(string); \n" + |
4624 |
" ^\n" + |
4625 |
"The local variable s is never read\n" + |
4626 |
"----------\n" |
4627 |
); |
4628 |
} finally { |
4629 |
if (project14 != null) |
4630 |
deleteProject(project14); |
4631 |
if (project15 != null) |
4632 |
deleteProject(project15); |
4633 |
} |
4634 |
} |
4501 |
} |
4635 |
} |