Java: Working with Annotations, Generics, & Arrays Using Reflection

Java    |    Expert
  • 10 videos | 1h 26m 30s
  • Includes Assessment
  • Earns a Badge
Rating 4.1 of 8 users Rating 4.1 of 8 users (8)
Annotations on Java code allow you to associate additional metadata with classes, member variables, constructors, and methods. These annotations can be used to perform additional checks or add functionality to your Java code. Use this course to practice using annotations with reflection. Work with both built-in and custom annotations and see how you can access the annotations applied on classes, fields, and methods. Learn why not all annotations can be accessed via reflection. Create your own custom annotation and experiment with various retention policies. Next, examine accessing generics and arrays with reflection. When you're finished, you'll be able to harness the power of reflection to add new functionality to your code and work with generics and arrays.

WHAT YOU WILL LEARN

  • Discover the key concepts covered in this course
    Examine what built-in annotations are accessible using reflection
    Create a custom annotation and examine retention policies
    Implement a use-case for reflection - accessing annotations to perform checks
    Implement a use-case for reflection - using reflection to check the objects of classes for validity
  • Identify what generic information about type parameters is available using reflection
    Explore the disadvantages of using reflection with generics
    View and edit data stored in arrays
    Use reflective access to determine array types and component types
    Summarize the key concepts covered in this course

IN THIS COURSE

  • 2m 41s
    This course will provide you with an in-depth exploration of the use of annotations and how they work with reflection. You’ll learn built-in and custom annotations and see how annotations on an object or a method can be picked up using reflection. You’ll learn that not all annotations can be picked up by reflection. You’ll learn more about the retention policy of an annotation. You’ll then learn about generics. FREE ACCESS
  • 9m 41s
    Here, you’ll watch a demo on how to access annotations on fields and methods. Annotations in Java can be thought of as code elements used to annotate or decorate other bits of code like classes, parameters, return types, or type parameters. This demo will focus on the relationship between reflection and annotations. FREE ACCESS
  • Locked
    3.  Configuring Custom Annotations for Reflective Access
    12m 13s
    Here, you’ll watch a demo on configuring custom annotations for reflective access. You’ll learn some types of annotations are not preserved for reflective access. This is due to a property called the retention policy. In this demo, you’ll see how the retention policy works. To do so, you’ll create your own annotation objects. These are known as custom annotations. FREE ACCESS
  • Locked
    4.  Scenario: Accessing Annotations to Perform Checks
    11m 50s
    In this demo, you’ll learn how to access annotations to perform checks. You’ll learn how to define a custom annotation. Then, you’ll use this annotation to impose a constraint on a field in your class. You’ll then use reflection in order to check whether this constraint has been satisfied or not. This will demonstrate how a combination of annotations and reflection can be used to monitor and regulate the state of your program. FREE ACCESS
  • Locked
    5.  Scenario: Checking Objects for Validity
    11m 27s
    Here, you’ll watch a demo. You’ll learn how to check objects for vitality. You’ll write and run code in this demo. Running this code will allow you to use reflection along with annotations. FREE ACCESS
  • Locked
    6.  Using Reflection with Generics Classes and Methods
    9m 34s
    Here, you’ll watch a demo. You’ll learn to use reflection with generic classes and methods. You’ll see how reflection works in the context of type parameters and parametrized classes. You’ll use a file called Container.java, which is a class that’s parameterized. FREE ACCESS
  • Locked
    7.  Exploring Limitations of Reflection and Generics
    11m 4s
    Here, you’ll watch a demo. You’ll explore the limitations of reflections and generics. You’ve seen the limitations of the Java reflection APIs when it comes to detecting type parameters used with local variables in your Java code. There are many different methods in the Java API such as .toGenericString, .getSuperclass, .getGenericSuperclass. But none of these are consistent when detecting the type parameter of a generic class object. You’ll take a different approach here. FREE ACCESS
  • Locked
    8.  Working with Arrays Using Reflection
    7m 43s
    Here, you’ll watch a demo. You’ll learn to use reflection when working with arrays. You’ll learn how arrays can be used, instantiated, and queried using reflection. You’ll create some arrays of reference types. FREE ACCESS
  • Locked
    9.  Exploring Array Types and Component Types
    8m 11s
    Here, you’ll watch a demo. You’ll explore array types and component types. You’ll turn your attention to multi-dimensional arrays. You’ll work with code that creates multi-dimensional int arrays. FREE ACCESS
  • Locked
    10.  Course Summary
    2m 9s
    This course provided you with an in-depth exploration of the use of annotations with reflection. You learned about built-in and custom annotations and saw how to access the annotations on an object or method. You also learned the retention policy of annotation and that only annotations with a retention policy of runtime can be accessed via reflection. You created custom annotation and experimented with various retention policies. 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.

YOU MIGHT ALSO LIKE

Rating 4.6 of 25 users Rating 4.6 of 25 users (25)
Rating 4.6 of 38 users Rating 4.6 of 38 users (38)
Rating 4.7 of 84 users Rating 4.7 of 84 users (84)

PEOPLE WHO VIEWED THIS ALSO VIEWED THESE

Rating 4.8 of 4 users Rating 4.8 of 4 users (4)
Rating 4.4 of 38 users Rating 4.4 of 38 users (38)
Rating 3.7 of 12 users Rating 3.7 of 12 users (12)