You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
599 B
29 lines
599 B
10 years ago
|
// Copyright (c) 2015-Present Facebook. All rights reserved.
|
||
|
|
||
|
package codetoanalyze.java.tracing;
|
||
|
|
||
|
import com.facebook.infer.annotation.Verify;
|
||
|
|
||
|
public class ArrayIndexOutOfBoundsExceptionExample {
|
||
|
|
||
|
void callMethodFromArray(T[] array, int index) {
|
||
|
array[index].f();
|
||
|
}
|
||
|
|
||
|
@Verify
|
||
|
void callWithWrongIndex(T[] array, int index) {
|
||
|
if (array != null) {
|
||
|
if (index >= 0 && index <= array.length) {
|
||
|
callMethodFromArray(array, index); // No longer found!
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Verify
|
||
|
void callOutOfBound() {
|
||
|
T[] array = new T[42];
|
||
|
callMethodFromArray(array, -5);
|
||
|
}
|
||
|
|
||
|
}
|