-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtemp_class.java
executable file
·53 lines (47 loc) · 1.41 KB
/
temp_class.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
package temp_package;
import java.net.*;
import java.lang.reflect.*;
class demo_reflect{
demo_reflect(String class_name){
try{
Class c=Class.forName(class_name);
java.lang.reflect.Constructor constructors[]=c.getConstructors();
java.lang.reflect.Method methods[]=c.getMethods();
java.lang.reflect.Field fields[]=c.getFields();
System.out.println("Constructor:");
for(int i=0;i<constructors.length;i++){
System.out.println(i+":"+constructors[i]);
}
System.out.println("Methods:");
for(int i=0;i<methods.length;i++){
String string_add="";
int modifiers=methods[i].getModifiers();
if(java.lang.reflect.Modifier.isAbstract(modifiers)){
string_add+="ABSTRACT ";
}
if(java.lang.reflect.Modifier.isFinal(modifiers)){
string_add+="FINAL ";
}
if(java.lang.reflect.Modifier.isPublic(modifiers)){
string_add+="PUBLIC ";
}
if(java.lang.reflect.Modifier.isSynchronized(modifiers)){
string_add+="Synchronized";
}
System.out.println(i+":"+methods[i]+" "+string_add);
}
System.out.println("Fields:");
for(int i=0;i<fields.length;i++){
System.out.println(i+":"+fields[i]);
}
}
catch(Exception e){
System.out.println("Error reflection\n"+e.getMessage());
}
}
}
public class temp_class {
public static void main(String args[]){
new demo_reflect("java.applet.Applet");
}
}