Skip to content

Commit

Permalink
Switch to use compliance level rather than source level
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohnstn committed Sep 20, 2024
1 parent b17e0de commit 2aba8be
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -601,21 +601,21 @@ private boolean sinceValueUnreached(Binding binding, Scope scope) {
return false;
}
}
AnnotationBinding[] annotations= binding.getAnnotations();
AnnotationBinding[] annotations = binding.getAnnotations();
for (AnnotationBinding annotation : annotations) {
if (annotation != null && String.valueOf(annotation.getAnnotationType().readableName()).equals("java.lang.Deprecated")) { //$NON-NLS-1$
ElementValuePair[] pairs= annotation.getElementValuePairs();
ElementValuePair[] pairs = annotation.getElementValuePairs();
for (ElementValuePair pair : pairs) {
if (String.valueOf(pair.getName()).equals("since")) { //$NON-NLS-1$
if (pair.getValue() instanceof StringConstant strConstant) {
try {
String value= strConstant.stringValue();
int sinceValue= Integer.parseInt(value);
String value = strConstant.stringValue();
int sinceValue = Integer.parseInt(value);
// As long as the AST levels and ClassFileConstants.MAJOR_VERSION grow simultaneously,
// we can use the offset of +44 to compute the Major version from the given AST Level
long sinceLevel= ClassFileConstants.getComplianceLevelForJavaVersion(sinceValue + 44);
long sourceLevel= scope.compilerOptions().sourceLevel;
if (sourceLevel < sinceLevel) {
long sinceLevel = ClassFileConstants.getComplianceLevelForJavaVersion(sinceValue + 44);
long complianceLevel = scope.compilerOptions().complianceLevel;
if (complianceLevel < sinceLevel) {
return true;
}
} catch (NumberFormatException e) {
Expand Down

0 comments on commit 2aba8be

Please sign in to comment.