-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMethodInfo.java
More file actions
63 lines (54 loc) · 1.62 KB
/
MethodInfo.java
File metadata and controls
63 lines (54 loc) · 1.62 KB
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
61
62
63
package hasnaer.java.bytecode;
import hasnaer.java.bytecode.attribute.AttributeInfo;
import hasnaer.java.bytecode.attribute.Code;
import hasnaer.java.bytecode.attribute.Exceptions;
import hasnaer.java.bytecode.cp.ConstantPool;
/**
*
* @author hasnae rehioui
*/
public class MethodInfo extends ClassMemberInfo {
private String class_name;
public MethodInfo(int access_flags,
int name_index, int descriptor_index, ConstantPool constant_pool,
String class_name){
super(access_flags, name_index, descriptor_index, constant_pool);
this.class_name = class_name;
}
public Code getCodeAttribute(){
for(AttributeInfo attribute : this.getAttributes()){
if(attribute instanceof Code){
return (Code) attribute;
}
}
return null;
}
public Exceptions getExceptionsAttibute(){
for(AttributeInfo attribute : getAttributes()){
if(attribute instanceof Exceptions){
return (Exceptions) attribute;
}
}
return null;
}
@Override
public String getName(){
String m_name = super.getName();
if(m_name.equals("<init>")){
return class_name;
}
if(m_name.equals("<clinit>")){
return "";
}
return m_name;
}
public boolean isStaticInit(){
return super.getName().equals("<clinit>");
}
public boolean isConstructor(){
return (super.getName().equals("<init>"));
}
public boolean isAbstract(){
return AccessFlags.isAbstract(access_flags);
}
}