-
Notifications
You must be signed in to change notification settings - Fork 10
/
Interceptor.java
60 lines (55 loc) · 1.99 KB
/
Interceptor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Copyright 2014 brutusin.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.brutusin.instrumentation;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
/**
* This class constitutes the main extension point in the framework.
* Implementation class names are passed to the framework via the options
* argument in the agent.
*
* @author Ignacio del Valle Alles [email protected]
*/
public abstract class Interceptor extends Callback {
/**
* Initializes the instance. This is a life-cycle method called by the agent
* after instantiation.
*
* @param arg Second token (split by ";") in the agent options after the
* Interceptor class name.
* @throws Exception
*/
public abstract void init(String arg) throws Exception;
/**
* When to instrument a class based on its name.
*
* @param className the name of the class in the internal form of fully
* qualified class and interface names as defined in
* <i>The Java Virtual Machine Specification</i>. For example,
* <code>"java/util/List"</code>.
* @param byteCode the input byte buffer in class file format
* @return
*/
public abstract boolean interceptClass(String className, byte[] byteCode);
/**
* When to instrument a method of a class based on their ASM representation
*
* @param cn
* @param mn
* @return
*/
public abstract boolean interceptMethod(ClassNode cn, MethodNode mn);
}