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.

32 lines
843 B

/*
* Copyright (c) 2016-present, Facebook, Inc.
*
* 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.crashcontext;
import java.lang.reflect.Method;
public class NativeMethodExample {
public static void foo() {
String s = null;
s.toString();
}
public static void main(String[] args) {
try {
// Calling method.invoke is a reliable way of getting a native method
// in the stack (from the implementation of reflection) between this
// method and the target of the reflective invocation.
Method method = NativeMethodExample.class.getDeclaredMethod("foo");
Object o = method.invoke(new Object[] {} );
} catch (ReflectiveOperationException e) {
throw new Error(e);
}
}
}