Navigation Menu

Skip to content

Commit

Permalink
fixed lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chame1eon committed Dec 11, 2019
1 parent 397ff85 commit 4695184
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
18 changes: 10 additions & 8 deletions jnitrace/src/main.ts
Expand Up @@ -9,10 +9,10 @@ import { DataTransport } from "./transport/data_transport";

const IS_IN_REPL = true;
const transport = new DataTransport();
let config : Config | null = null;
let config: Config | null = null;

JNILibraryWatcher.setCallback({
onLoaded(path : string) {
onLoaded(path: string): void {
if (!IS_IN_REPL && !Config.initialised()) {
const op = recv("config", (message): void => {
const builder = new ConfigBuilder();
Expand All @@ -35,7 +35,7 @@ JNILibraryWatcher.setCallback({
return;
}

config.libraries.forEach((element : string) => {
config.libraries.forEach((element: string): void => {
if (path.includes(element)) {
send({
type: "tracked_library",
Expand All @@ -46,17 +46,19 @@ JNILibraryWatcher.setCallback({
}
});

const callback : JNIInvocationCallback = {
onEnter(args : NativeArgumentValue[]) {
const callback: JNIInvocationCallback = {
onEnter(args: NativeArgumentValue[]): void {
this.args = args;
},
onLeave(retval : JNINativeReturnValue) {
const data = new MethodData(this.methodDef, this.args, retval.get(), this.javaMethod);
onLeave(retval: JNINativeReturnValue): void {
const data = new MethodData(
this.methodDef, this.args, retval.get(), this.javaMethod
);
transport.reportJNIEnvCall(
data, this.backtrace
);
}
}
};

JNIInterceptor.attach("DestroyJavaVM", callback);
JNIInterceptor.attach("AttachCurrentThread", callback);
Expand Down
13 changes: 6 additions & 7 deletions jnitrace/src/transport/data_transport.ts
Expand Up @@ -7,6 +7,8 @@ const TYPE_NAME_START = 0;
const TYPE_NAME_END = -1;
const SKIP_ENV_INDEX = 1;
const EMPTY_ARRAY_LEN = 0;
const JAVA_VM_INDEX = 0;
const JNI_ENV_INDEX = 0;


class NativeMethodJSONContainer {
Expand Down Expand Up @@ -137,11 +139,11 @@ class DataTransport {
this.exclude = [];
}

public setIncludeFilter(include: string[]) {
public setIncludeFilter(include: string[]): void {
this.include = include;
}

public setExcludeFilter(exclude: string[]) {
public setExcludeFilter(exclude: string[]): void {
this.exclude = exclude;
}

Expand All @@ -154,7 +156,7 @@ class DataTransport {
const outputRet: DataJSONContainer = new DataJSONContainer(
data.ret, null
);
const javaVM = data.getArgAsPtr(0);
const javaVM = data.getArgAsPtr(JAVA_VM_INDEX);

if (!config.vm || this.shouldIgnoreMethod(data)) {
return;
Expand All @@ -180,10 +182,9 @@ class DataTransport {
): void {
const RET_INDEX = 0;
const config = Config.getInstance();
const threadId = Process.getCurrentThreadId();
const outputArgs: DataJSONContainer[] = [];
const outputRet: DataJSONContainer[] = [];
const jniEnv = data.getArgAsPtr(0);
const jniEnv = data.getArgAsPtr(JNI_ENV_INDEX);

this.updateState(data);

Expand Down Expand Up @@ -338,7 +339,6 @@ class DataTransport {
}

private shouldIgnoreMethod(data: MethodData): boolean {
const config = Config.getInstance();
const name = data.method.name;

if (this.include.length > EMPTY_ARRAY_LEN) {
Expand Down Expand Up @@ -870,7 +870,6 @@ class DataTransport {
const ENV_ARG_INDEX = 1;
const VERSION_ARG_INDEX = 2;

const threadId = Process.getCurrentThreadId();
const env: NativeArgumentValue = data.args[ENV_ARG_INDEX];
let binData = null;

Expand Down

0 comments on commit 4695184

Please sign in to comment.