Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some build errors #790

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.tencent.matrix.trace;

import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.commons.JSRInlinerAdapter;

public class JSRAdapter extends JSRInlinerAdapter {
JSRAdapter(int api, MethodVisitor mv, int access, String name, String desc, String signature, String[] exceptions) {
super(api, mv, access, name, desc, signature, exceptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public int compare(TraceMethod o1, TraceMethod o2) {
}

private class TraceClassAdapter extends ClassVisitor {
private int version;
private String className;
private boolean isABSClass = false;
private boolean hasWindowFocusMethod = false;
Expand All @@ -278,6 +279,7 @@ private class TraceClassAdapter extends ClassVisitor {
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
this.version = version;
this.className = name;
if ((access & Opcodes.ACC_ABSTRACT) > 0 || (access & Opcodes.ACC_INTERFACE) > 0) {
this.isABSClass = true;
Expand All @@ -294,7 +296,11 @@ public MethodVisitor visitMethod(int access, String name, String desc,
if (!hasWindowFocusMethod) {
hasWindowFocusMethod = isWindowFocusChangeMethod(name, desc);
}
return new CollectMethodNode(className, access, name, desc, signature, exceptions);
MethodVisitor collectMethodNode = new CollectMethodNode(className, access, name, desc, signature, exceptions);
if (this.version <= Opcodes.V1_6) {
collectMethodNode = new JSRAdapter(api, collectMethodNode, access, name, desc, signature, exceptions);
}
return collectMethodNode;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ private class TraceClassAdapter extends ClassVisitor {
private boolean hasWindowFocusMethod = false;
private boolean isActivityOrSubClass;
private boolean isNeedTrace;
private int version;

TraceClassAdapter(int i, ClassVisitor classVisitor) {
super(i, classVisitor);
Expand All @@ -309,6 +310,7 @@ private class TraceClassAdapter extends ClassVisitor {
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
this.version = version;
this.className = name;
this.superName = superName;
this.isActivityOrSubClass = isActivityOrSubClass(className, collectedClassExtendMap);
Expand All @@ -329,8 +331,12 @@ public MethodVisitor visitMethod(int access, String name, String desc,
return super.visitMethod(access, name, desc, signature, exceptions);
} else {
MethodVisitor methodVisitor = cv.visitMethod(access, name, desc, signature, exceptions);
return new TraceMethodAdapter(api, methodVisitor, access, name, desc, this.className,
methodVisitor = new TraceMethodAdapter(api, methodVisitor, access, name, desc, this.className,
hasWindowFocusMethod, isActivityOrSubClass, isNeedTrace);
if (this.version <= Opcodes.V1_6) {
methodVisitor = new JSRAdapter(api, methodVisitor, access, name, desc, signature, exceptions);
}
return methodVisitor;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class TraceBuildConstants {
public final static String MATRIX_TRACE_APPLICATION_CLASS = "android/app/Application";
public final static String MATRIX_TRACE_METHOD_BEAT_CLASS = "com/tencent/matrix/trace/core/AppMethodBeat";
public final static String MATRIX_TRACE_ON_WINDOW_FOCUS_METHOD_ARGS = "(Z)V";
public static final String[] UN_TRACE_CLASS = {"R.class", "R$", "Manifest", "BuildConfig"};
public static final String[] UN_TRACE_CLASS = {"R.class", "R$", "Manifest", "BuildConfig", "META-INF", "module-info"};
public final static String DEFAULT_BLOCK_TRACE =
"[package]\n"
+ "-keeppackage android/\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class MatrixTrace(
}
val traceClassLoader = TraceClassLoader.getClassLoader(project, allInputs)
methodTracer.trace(dirInputOutMap, jarInputOutMap, traceClassLoader, skipCheckClass)

traceClassLoader.close()
Log.i(TAG, "[doTransform] Step(3)[Trace]... cost:%sms", System.currentTimeMillis() - start)

}
Expand Down