The current problem is that no field has the name "address.description" (it's not even a valid name for a field).

You have to get the address field first, access its class, and get the nested field from there. To do so, use getType():

Agreement agreement = new Agreement();
Class c = agreement.getClass();          // Agreement class
Field f = c.getDeclaredField("address"); // address field
Class<?> fieldClass = f.getType();       // class of address field (Address)
Field nested = fieldClass.getDeclaredField("description"); // description field

You can also chain the calls without local variables:

Field nested = c.getDeclaredField("address").getType().getDeclaredField("description");
Answer from Joffrey on Stack Overflow
🌐
Stack Overflow
stackoverflow.com › questions › 59614726 › access-nested-field-using-java-reflection
Access Nested Field using Java Reflection - Stack Overflow
Field[] myFields = providedObject.getClass().getDeclaredFields(); for (Field myField : myFields) { // do something here?? to access the sub-fields of the class // if I print out myField.getName(), I get the element of class A, but I also want to access the anotherElement of class B (without hard-coding the name 'anotherElement', I want a full traversal of all nested fields) } At the 'do something here' step, I want to access the sub-fields of myField, but I don't see anything in the Field api that directly lets me do this.
🌐
Baeldung
baeldung.com › home › java › core java › retrieve fields from a java class using reflection
Retrieve Fields from a Java Class Using Reflection | Baeldung
January 4, 2026 - Of course, we could use the getDeclaredFields() method on both Person and Employee classes and merge their results into a single array. But what if we don’t want to specify the superclass explicitly?
🌐
GitHub
gist.github.com › 11279105
FieldUtils mutates and accesses fields using reflection. · GitHub
FieldUtils mutates and accesses fields using reflection. - FieldUtils.java
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › reflect › Field.html
Field (Java Platform SE 8 )
3 weeks ago - Gets the value of a static or instance boolean field. ... IllegalAccessException - if this Field object is enforcing Java language access control and the underlying field is inaccessible.
🌐
LogicBig
logicbig.com › how-to › reflection › setting-nested-field-value.html
Java - Different ways to Set Nested Field Value By Reflection
package com.logicbig.example; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.util.Arrays; public class JavaBeanInfoExample { public static void main(String[] args) throws Exception { Person p = new Person();//must have getters/setters Address address = new Address(); address.setLine1(new AddressLine()); address.setCity(new City()); p.setAddress(address); //commenting this will also work System.out.println("before: " + p); setFieldValue(p, "address.line1.houseNumber", "4508"); setFieldValue(p, "address.line1.street", "Westfall Dr");
🌐
GitHub
gist.github.com › isopropylcyanide › 833e435cb261827e2d5af772ce8264a4
Nested Property Object Mapper. Using reflection, takes an object and returns a map<string, string> where key is all the properties (nested inclusive) and value is the object value · GitHub
June 20, 2018 - Nested Property Object Mapper. Using reflection, takes an object and returns a map where key is all the properties (nested inclusive) and value is the object value - ObjectMapperUtil.java
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › tutorial › reflect › member › fieldValues.html
Getting and Setting Field Values (The Java™ Tutorials > The Reflection API > Members)
$ java Book BEFORE: chapters = 0 AFTER: chapters = 12 BEFORE: characters = [Alice, White Rabbit] AFTER: characters = [Queen, King] BEFORE: twin = DEE AFTER: twin = DUM · Note: Setting a field's value via reflection has a certain amount of performance overhead because various operations must occur such as validating access permissions.
🌐
TutorialsPoint
tutorialspoint.com › javareflect › javareflect_field_get.htm
java.lang.reflect.Field.get() Method Example
package com.tutorialspoint; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Field; public class FieldDemo { public static void main(String[] args) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { SampleClass sampleObject = new SampleClass(); sampleObject.setSampleField("data"); Field field = SampleClass.class.getField("sampleField"); System.out.println(field.get(sampleObject)); } } @CustomAnnotation(name = "SampleClass", value = "Sample Class Annotation") class SampleClass { @CustomAn
🌐
Stack Overflow
stackoverflow.com › questions › 37800513 › java-reflection-get-value-of-a-field-within-nested-classes
Java Reflection - Get value of a field within nested classes - Stack Overflow
May 29, 2017 - Is there a way to fetch the value by field name "customerId" irrespective of where the instance variable is? ... public static Map<Field, Integer> getFieldWithName(Object o, Map<Field, Integer> list) throws IllegalAccessException { Class<?> c = o.getClass(); for(Field field : c.getDeclaredFields()) { if(field.getName().equals("customerId") && field.getType().equals(int.class)) { list.put(field, field.getInt(o)); } else { if(!field.isAccessible()) { field.setAccessible(true); } getFieldWithName(field.get(o), list); } } return list; }
🌐
Netjstech
netjstech.com › 2017 › 07 › reflection-in-java-field.html
Reflection in Java - Getting Field Information | Tech Tutorials
December 23, 2021 - How to get information about the fields of a class using reflection API in Java. Get field's type, field’s modifier and setting and getting values of a field using reflection.
🌐
Linkedinppc
linkedinppc.com › p2hd8ai › java-reflection-get-nested-field-value.html
java reflection get nested field value
March 21, 2022 - Reflection (JavaFX 8) java.lang.Object. public class Person { protected String lastName; private String firstName; } We want to get both lastName and firstName fields using reflection. Using the extension methods, we are allowed to access the property without testing all the "nodes" as showed below: C#. Recursively Modify Object Values Reflection Java. I need to get value of one the of the nested class along with main class.
🌐
YouTube
youtube.com › watch
Unlocking Java Reflection: Easily Retrieve Field Values Using Field Paths - YouTube
Discover how to leverage Java reflection for straightforward field value retrieval using field paths. Explore libraries and custom solutions to optimize your...
Published   May 27, 2025
Views   0
🌐
Baeldung
baeldung.com › home › java › core java › get all record fields and its values via reflection
Get All Record Fields and Its Values via Reflection | Baeldung
January 16, 2024 - However, the problem can be solved without using the new RecordComponent class. Java reflection API provides the Class.getDeclaredFields() method to get all declared fields in the class.