Skip to content

Commit

Permalink
Merge pull request #6168 from robolectric/piper_353074349
Browse files Browse the repository at this point in the history
Revert some recently added native method logic in ClassInstrumentor
  • Loading branch information
hoisie committed Jan 31, 2021
2 parents 228a8b7 + 2d884eb commit 2865d95
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.lang.invoke.MethodType;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.objectweb.asm.ClassReader;
Expand All @@ -17,7 +16,6 @@
import org.objectweb.asm.commons.Method;
import org.objectweb.asm.commons.Remapper;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
Expand All @@ -32,7 +30,6 @@
public abstract class ClassInstrumentor {
private static final String ROBO_INIT_METHOD_NAME = "$$robo$init";
static final Type OBJECT_TYPE = Type.getType(Object.class);
static final String NATIVE_METHOD_DESCRIPTOR = Type.getDescriptor(NativeMethod.class);
private static final ShadowImpl SHADOW_IMPL = new ShadowImpl();
final Decorator decorator;

Expand Down Expand Up @@ -370,15 +367,6 @@ protected void instrumentNormalMethod(MutableClass mutableClass, MethodNode meth
new MethodNode(
method.access, originalName, method.desc, method.signature, exceptionArray(method));
delegatorMethodNode.visibleAnnotations = method.visibleAnnotations;
// Add a @NativeMethod annotation to the original method to indicate that this method was
// previously native. This is useful for some ClassInstrumentor plugins that do some additional
// instrumentation on native methods.
if (isNativeMethod) {
if (delegatorMethodNode.visibleAnnotations == null) {
delegatorMethodNode.visibleAnnotations = new ArrayList<>();
}
delegatorMethodNode.visibleAnnotations.add(new AnnotationNode(NATIVE_METHOD_DESCRIPTOR));
}
delegatorMethodNode.access &= ~(Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_FINAL);

makeMethodPrivate(method);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected Class<?> maybeInstrumentClass(String className) throws ClassNotFoundEx
try {
final byte[] bytes;
ClassDetails classDetails = new ClassDetails(origClassBytes);
if (shouldInstrument(classDetails)) {
if (config.shouldInstrument(classDetails)) {
bytes = classInstrumentor.instrument(classDetails, config, classNodeProvider);
maybeDumpClassBytes(classDetails, bytes);
} else {
Expand Down Expand Up @@ -171,10 +171,6 @@ private void maybeDumpClassBytes(ClassDetails classDetails, byte[] classBytes) {
}
}

protected boolean shouldInstrument(ClassDetails classDetails) {
return config.shouldInstrument(classDetails);
}

protected byte[] postProcessUninstrumentedClass(ClassDetails classDetails) {
return classDetails.getClassBytes();
}
Expand Down

0 comments on commit 2865d95

Please sign in to comment.