Learn Reflection with Java
4h 9mIntermediate2024-10-23
Authors

Pearson

Heinz Kabutz
Course details
Reflection is a powerful feature in Java that can be used to expand the capabilities of a program, or to examine a class, method, or object at runtime, even if you don’t know its name. In this course from Pearson, get started with the basics, then learn how reflection works with the more modern language features such as sealed classes and records, as well as how arrays can be manipulated and created via reflection. Along the way, explore the purpose of MethodHandles and VarHandles to find out when and how to use them both like a pro.
Learning objectives
Inspect a class and find methods, fields, and constructors at runtime.
Call methods and change fields, even if they are private.
Write more general code that can be reused in many different contexts.
Understand VarHandles and MethodHandles and know when to use them.
Inspect sealed classes and records via reflection.
Learning objectives
Inspect a class and find methods, fields, and constructors at runtime.
Call methods and change fields, even if they are private.
Write more general code that can be reused in many different contexts.
Understand VarHandles and MethodHandles and know when to use them.
Inspect sealed classes and records via reflection.
Skills covered
JavaProgramming FoundationsOracleProgramming LanguagesSoftware DevelopmentOne-Off
Concepts
0. Introduction
- 01 - Learn reflection with Java - Introduction
Lesson 1 - Introduction to Reflection
- 02 - Learning objectives
- 03 - Who am I
- 04 - Why learn reflection
- 05 - Class class
- 06 - Method
- 07 - Modifier and access flag
- 08 - Constructor
- 09 - Generics
- 10 - Nested classes
- 11 - Sealed classes
- 12 - Records
- 13 - Exercise
Lesson 2 - Deep Reflection
- 14 - Learning objectives
- 15 - Making private members accessible
- 16 - Performance considerations
Lesson 3 - Arrays
- 17 - Learning objectives
- 18 - Accessing elements
- 19 - Creating new
- 20 - Exercise
Lesson 4 - java.lang.invoke
- 21 - Learning objectives
- 22 - MethodHandles.lookup
- 23 - privateLookupIn()
- 24 - MethodHandle
- 25 - MethodType
- 26 - VarHandle
- 27 - Unreflecting
- 28 - Exercises
Summary
- 29 - Learn reflection with Java - Summary
Related courses
Related learn paths
- Advance Your Skills in the Hadoop/NoSQL Data Science Stack
- Managing your Career as a Developer
- Cultivate Work-Life Balance for Less Stress
- Building AI Agents: Advanced Techniques for Developers
- Building Agentic AI Systems for Developers
- Advance Your Rendering Skills
- C# Excellence: Architecting High-Performance Solutions
- Caring for Your Total Well-Being as a Manager