Java: Accessing Constructors, Methods, & Fields Using Reflection
Java 15
| Intermediate
- 13 videos | 1h 38m 12s
- Includes Assessment
- Earns a Badge
Reflective access allows a whole range of operations on objects that may not be permitted when you construct and use objects in the regular manner. This is extremely useful while building frameworks that may need access to the internals of your object. Use this course to extract information and metadata about the constructors in a class and use them, accessed via reflection, to instantiate objects. Access and modify fields or the member variables in an object. Access and invoke the methods defined on a class. Invoke static methods on the class itself and instance methods on specific objects of a class. When you're done, you'll have the ability to use reflection to access and work with all class members, whether they are fields, constructors, or methods.
WHAT YOU WILL LEARN
-
discover the key concepts covered in this courseaccess the constructors in a class using reflectioncreate objects of a class with handles to constructorsaccess member variables of a class and its metadataaccess and update values of fieldsaccess and update protected and private fieldsaccess public, private, and protected methods
-
view method parameters, annotations, return types, and exceptionsview annotations on methods and recall the use of the retention policyobserve how not all annotations are available at runtime for reflective accessuse method heuristics to identify getters and setters in a classinvoke and call methods using handlessummarize the key concepts covered in this course
IN THIS COURSE
-
2m 57sIn this video, you’ll learn more about your instructor and this course. In this course, you’ll learn how to extract information and metadata about the constructors in a class. You’ll see how the .getConstructors method… FREE ACCESS
-
9m 33sHere, you’ll watch a demo. In this demo, you’ll learn to instantiate objects of a given class. First, you’ll examine the Java docs for the class you see mentioned onscreen. These refer to using the reflection API's in… FREE ACCESS
-
8m 54sHere, you’ll watch a demo. You’ll pick up where you left off at the end of the last demo. There, you used the newInstance method on a constructor object. You used that to create an object of a specific class. That code is… FREE ACCESS
-
10m 14sHere, you’ll watch a demo. You’ll learn more about fields. In the context of a reflection, the term field is used for member variables. Member variables whether private, public, or protected, static or non-static, are all… FREE ACCESS
-
8m 52sHere, you’ll watch a demo. Here, you’ll clear up the current contents of your main method and then add in a new import statement that you’ll need. This is java.lang.reflect.Modifier. It allows you to interpret the… FREE ACCESS
-
9m 13sHere, you’ll watch a demo. Here, you’ll run the code and examine the output you see onscreen. You can see from the output that initially, your employee object has no real values for any of its fields. Initially, the only… FREE ACCESS
-
8m 36sHere, you’ll watch a demo. You’ll work with methods, which are member functions. You’ll begin by importing a specific class. This is a java.lang.reflect.Method. This class contains much of the functionality in the Java… FREE ACCESS
-
7m 14sHere, you’ll watch a demo. You’ll turn your attention to a user-defined class, specifically the employee class, which you now see onscreen. This particular iteration of the employee class is slightly different than in… FREE ACCESS
-
7m 8sHere, you’ll watch a demo. In this demo, you’ll learn how reflection and annotations interact. You’ll begin by importing additional bits of functionality. Onscreen you’ll see you’ve imported… FREE ACCESS
-
8m 12sHere, you’ll watch a demo. In this demo, you’ll recognize annotation runtime policy implications. You’ll learn the printMethodProperties utility can be very helpful. It provides you with information about any method that… FREE ACCESS
-
10m 14sHere, you’ll watch a demo. In this demo, you’ll move on to another aspect of using reflection to invoke methods on a specific object. This is a logical next step and it's an important operation in real-world uses of… FREE ACCESS
-
4m 32sHere, you’ll watch a demo. In this demo, you’ll move on to changing the state of an object by invoking the setter methods on that object. First, you’ll add in some additional code. Onscreen, you’ll see you have yet… FREE ACCESS
-
2m 33sIn this video, you’ll summarize what you’ve learned in this course. You’ve learned how to extract information and metadata about the constructors in a class. You saw how the .get constructors method only returns the… FREE ACCESS
EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE
Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.
Digital badges are yours to keep, forever.