FP: Local variable is assigned to a value which is never used
ben-manes opened this issue · comments
Ben Manes commented
This code assigns a new value to the local variable field and this value is never
used subsequently. Probably something else was meant or the assignment could be removed.
This one is odd because the field is used in the happy path.
Field field = null;
try {
// try OpenJDK field name
field = Unsafe.class.getDeclaredField(openJdk);
} catch (NoSuchFieldException e) {
try {
// try Android field name...
} catch (NoSuchFieldException e2) {
// try to create a new instance...
}
field.setAccessible(true);
return (Unsafe) field.get(null);
}
Tagir Valeev commented
Are you sure that field.setAccessible
and return
are inside the catch
block?
Ben Manes commented
Typo. I think it was because its initialized to null, which as stated wasn't required.