-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Continued working on a cleaner way to mask methods
* Removed Java 8 PhosphorOption since that value should now only be necessary at runtime
- Loading branch information
1 parent
405063e
commit 91696df
Showing
22 changed files
with
1,270 additions
and
1,854 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/agent/UnsafeAdapterPatchingCV.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package edu.columbia.cs.psl.phosphor.agent; | ||
|
||
import edu.columbia.cs.psl.phosphor.Configuration; | ||
import edu.columbia.cs.psl.phosphor.runtime.mask.JdkUnsafeAdapter; | ||
import edu.columbia.cs.psl.phosphor.runtime.mask.SunUnsafeAdapter; | ||
import org.objectweb.asm.ClassVisitor; | ||
import org.objectweb.asm.MethodVisitor; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.Type; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class UnsafeAdapterPatchingCV extends ClassVisitor { | ||
private String className; | ||
|
||
public UnsafeAdapterPatchingCV(ClassVisitor cv) { | ||
super(Configuration.ASM_VERSION, cv); | ||
} | ||
|
||
@Override | ||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { | ||
super.visit(version, access, name, signature, superName, interfaces); | ||
className = name; | ||
} | ||
|
||
@Override | ||
public MethodVisitor visitMethod( | ||
int access, String name, String descriptor, String signature, String[] exceptions) { | ||
MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions); | ||
return new MethodVisitor(api, mv) { | ||
@Override | ||
public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) { | ||
if (owner.equals(className) && opcode == Opcodes.INVOKESTATIC) { | ||
Type[] args = Type.getArgumentTypes(descriptor); | ||
owner = args[0].getInternalName(); | ||
descriptor = descriptor.replaceFirst(Pattern.quote(args[0].getDescriptor()), ""); | ||
super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, descriptor, false); | ||
} else { | ||
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
public static boolean isApplicable(String className) { | ||
return Type.getInternalName(SunUnsafeAdapter.class).equals(className) | ||
|| Type.getInternalName(JdkUnsafeAdapter.class).equals(className); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/agent/UnsafePatchingCV.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.