You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Signedness Checker is unable to know the signedness of a cast (without an explicit annotation) Object assigned to the integral types byte, short, int, and long:
import org.checkerframework.checker.signedness.qual.Signed;
public class ObjectCasts {
void castObjectToBoxedVariants() {
byte b1 = 1;
short s1 = 1;
int i1 = 1;
long l1 = 1;
Object[] obj = new Object[] {b1, s1, i1, l1};
byteParameter((Byte) obj[0]);
shortParameter((Short) obj[1]);
integralParameter((Integer) obj[2]);
longParameter((Long) obj[3]);
}
void byteParameter(byte b) {}
void shortParameter(short s) {}
void integralParameter(int i) {}
void longParameter(long l) {}
}
The main changes are to add a `@SignedPositiveFromUnsigned` annotation and to add logic related to the widening that Java automatically does at arithmetic operations.
Fixestypetools#3668; fixestypetools#3669
DmitriyShepelev
changed the title
Signedness Checker unable to know signedness of casted Object assigned to integral type
Signedness Checker unable to know signedness of cast Object assigned to integral type
Sep 29, 2020
The Signedness Checker is unable to know the signedness of a cast (without an explicit annotation)
Object
assigned to the integral typesbyte
,short
,int
, andlong
:Command:
javacheck -version -verbose -AprintAllQualifiers -processor SignednessChecker ObjectCasts.java
Output:
ObjectCastsOutput.txt
javacheck
alias:alias javacheck='$CHECKERFRAMEWORK/checker/bin/javac'
What can be changed in the Signedness Checker to eliminate this type of error?
The text was updated successfully, but these errors were encountered: