-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathMainReflection.java
More file actions
23 lines (20 loc) · 823 Bytes
/
MainReflection.java
File metadata and controls
23 lines (20 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.urise.webapp;
import com.urise.webapp.model.Resume;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class MainReflection {
public static void main(String[] args) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
Resume r = new Resume();
Class <? extends Resume> resumeClass = r.getClass();
Field field = resumeClass.getDeclaredFields()[0];
field.setAccessible(true);
System.out.println(field.getName());
System.out.println(field.get(r));
field.set(r, "new_uuid");
System.out.println(r);
Method method = resumeClass.getMethod("toString");
Object result = method.invoke(r);
System.out.println(result);
}
}