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.

45 lines
1015 B

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package codetoanalyze.java.infer;
import java.util.Collections;
import java.util.List;
public class InvokeDynamic {
void invokeDynamicThenNpeBad(List<String> list) {
Object o = null;
Collections.sort(
list,
(String a, String b) -> {
return b.compareTo(a);
});
o.toString();
}
void npeInLambdaBad(List<String> list) {
Collections.sort(
list,
(String a, String b) -> {
Object o = null;
o.toString();
return b.compareTo(a);
});
}
// we won't get this one because we don't actually translate the invocation of the lambda
void FN_npeViaCaptureBad(List<String> list) {
String s = null;
Collections.sort(
list,
(String a, String b) -> {
return s.compareTo(a);
});
}
}