Skip to content

Commit

Permalink
Tweak logic to handle case where annotations aren't ready
Browse files Browse the repository at this point in the history
- fix Deprecated9Test failures
  • Loading branch information
jjohnstn committed Sep 5, 2024
1 parent 4ed143f commit c47b37c
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,14 @@ public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope,
}

private boolean sinceValueUnreached(Binding binding, Scope scope) {
if (binding instanceof TypeBinding typeBinding) {
if (!typeBinding.isReadyForAnnotations()) {
return false;
}
}
AnnotationBinding[] annotations= binding.getAnnotations();
for (AnnotationBinding annotation : annotations) {
if (String.valueOf(annotation.getAnnotationType().readableName()).equals("java.lang.Deprecated")) { //$NON-NLS-1$
if (annotation != null && String.valueOf(annotation.getAnnotationType().readableName()).equals("java.lang.Deprecated")) { //$NON-NLS-1$
ElementValuePair[] pairs= annotation.getElementValuePairs();
for (ElementValuePair pair : pairs) {
if (String.valueOf(pair.getName()).equals("since")) { //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,15 @@ public void testBug533063_2() throws Exception {
"----------\n";
runner.runWarningTest();
}
public void testBug534304() throws Exception {
public void testBug534304_1() throws Exception {
Map<String, String> options= getCompilerOptions();
String compliance= options.get(CompilerOptions.OPTION_Compliance);
if (compliance.equals(CompilerOptions.VERSION_9) ||
compliance.equals(CompilerOptions.VERSION_10) ||
compliance.equals(CompilerOptions.VERSION_11) ||
compliance.equals(CompilerOptions.VERSION_12)) {
return;
}
runNegativeTest(
new String[] {
"p1/C1.java",
Expand Down Expand Up @@ -955,6 +963,48 @@ public void testBug534304() throws Exception {
"CMissing cannot be resolved to a type\n" +
"----------\n");
}
public void testBug534304_2() throws Exception {
Map<String, String> options= getCompilerOptions();
String compliance= options.get(CompilerOptions.OPTION_Compliance);
if (compliance.equals(CompilerOptions.VERSION_9) ||
compliance.equals(CompilerOptions.VERSION_10) ||
compliance.equals(CompilerOptions.VERSION_11) ||
compliance.equals(CompilerOptions.VERSION_12)) {
runNegativeTest(
new String[] {
"p1/C1.java",
"package p1;\n" +
"\n" +
"import pdep.Dep1;\n" +
"\n" +
"public class C1 {\n" +
" Dep1 f;\n" +
"}\n",
"pdep/Dep1.java",
"package pdep;\n" +
"\n" +
"import pmissing.CMissing;\n" +
"\n" +
"@Deprecated(since=\"13\")\n" +
"@CMissing\n" +
"public class Dep1 {\n" +
"\n" +
"}\n"
},
"----------\n" +
"----------\n" +
"1. ERROR in pdep\\Dep1.java (at line 3)\n" +
" import pmissing.CMissing;\n" +
" ^^^^^^^^\n" +
"The import pmissing cannot be resolved\n" +
"----------\n" +
"2. ERROR in pdep\\Dep1.java (at line 6)\n" +
" @CMissing\n" +
" ^^^^^^^^\n" +
"CMissing cannot be resolved to a type\n" +
"----------\n");
}
}
public void testBug542795() throws Exception {
Runner runner = new Runner();
runner.customOptions = new HashMap<>();
Expand Down

0 comments on commit c47b37c

Please sign in to comment.