1 import java
.lang
.reflect
.Field
;
2 import java
.lang
.reflect
.Method
;
3 import java
.lang
.reflect
.Constructor
;
4 import java
.lang
.reflect
.InvocationTargetException
;
5 import java
.util
.Scanner
;
6 import java
.io
.IOException
;
10 private static void main_orig(String
[] args
) {
11 Entiers integer
= new Entiers(5);
31 integer
.supprimer(12);
34 System
.out
.println("Current size " + integer
.getCurrentSize());
39 System
.out
.println("Current size " + integer
.getCurrentSize());
43 private static void main_A(String
[] args
) {
44 if (args
.length
== 0) {
45 System
.out
.println("Please run with java Main <class name to inspect>");
48 String className
= args
[0];
52 cl
= Class
.forName(className
);
54 catch (ClassNotFoundException e
) {
55 System
.out
.println("Entered class name do not exist.");
59 Field
[] fields
= cl
.getFields();
60 Method
[] methods
= cl
.getMethods();
62 for (int i
= 0; i
< fields
.length
; i
++) {
63 System
.out
.println(fields
[i
]);
66 for (int i
= 0; i
< methods
.length
; i
++) {
67 System
.out
.println(methods
[i
]);
73 * @param String[] args main() function arguments array
75 public static void main(String
[] args
) {
76 String name
= Entiers
.class.getName();
80 cl
= Class
.forName(name
);
83 catch (ClassNotFoundException e
) {
84 System
.out
.println("Class name do not exist.");
88 Scanner uInput
= null;
90 uInput
= new Scanner(System
.in
);
91 System
.out
.println("Saisir le nom de la methode à invoquer:");
92 String method
= uInput
.next();
93 //TODO: one can build the input list from the method arguments list and types
94 System
.out
.println("Saisir l'argument entier paramètre de la méthode:");
95 int integer
= uInput
.nextInt();
96 Method m
= cl
.getMethod(method
, new Class
[]{Integer
.class});
100 System
.out
.println("Erreur:");
105 Method mDisplay
= cl
.getMethod("afficher");
108 catch (NoSuchMethodException e
) {
111 catch (IllegalAccessException e
) {
114 catch (InvocationTargetException e
) {