From fe98f4bdb1c499bfe6ef05b9afdb26d1be3cb4fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 3 Apr 2018 16:16:34 +0200 Subject: [PATCH] exo3: Add the first part code. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- exo3/Main.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/exo3/Main.java b/exo3/Main.java index 41749bf..f15a4ec 100644 --- a/exo3/Main.java +++ b/exo3/Main.java @@ -1,3 +1,5 @@ +import java.lang.reflect.Field; +import java.lang.reflect.Method; class Main { @@ -39,6 +41,26 @@ class Main { * @param String[] args main() function arguments array */ public static void main(String[] args) { - main_orig(args); + String className = args[0]; + Class cl = null; + try { + cl = Class.forName(className); + } + catch (ClassNotFoundException e) { + System.out.println("Entered class name do not exist."); + System.exit(-1); + } + + Field[] fields = cl.getFields(); + Method[] methods = cl.getMethods(); + + for (int i = 0; i < fields.length; i++) { + System.out.println(fields[i]); + } + + for (int i = 0; i < methods.length; i++) { + System.out.println(methods[i]); + } + } } -- 2.34.1