Loading topic
Class object.2 min readClass object with .class, getClass(), or Class.forName(), as covered in the previous chapter. It also assumes you know basic Java classes and checked exceptions. Here you will list what a class contains and read its modifiers.2 min readClass object and list its members, as covered in the earlier chapters. It also assumes you are comfortable with checked exceptions.2 min readClass object and list a type's members with getDeclaredFields(). Here you will read and change field values on a live object.1 min readClass object and look up members with getMethod, as covered in the earlier chapters. You should also be comfortable with checked exceptions and try/catch.2 min readClass object and read its fields and methods with getDeclaredField and getDeclaredMethod. It covers what happens when reflection touches a private member, and how the Java 9+ module system changes the answer.2 min read@interface and apply it to a class or field. A meta-annotation is an annotation placed on an annotation declaration. It controls how long the annotation lives, where it may be used, and how it behaves with inheritance and repetition.2 min read@Retention and @Target. It also assumes you can list a class's fields and methods with reflection.2 min readsetAccessible(true), and declare an annotation with @Retention and @Target. The goal is a small version of what frameworks such as Bean Validation do.2 min readClass object and read a Field from it. It covers what generic information survives at runtime and how to read it.2 min readMethod.invoke works from the earlier chapters on method invocation.2 min readMethod and call it with invoke, and that you know how setAccessible affects access checks. A method handle is a second way to call code by name at runtime, and it behaves differently from Method.invoke.2 min readMethod or Field, call setAccessible(true), unwrap InvocationTargetException, and read the MethodHandle example from the previous chapter. Here you will learn what reflection costs, where it can hurt you, and when to choose something else.2 min read@Retention, and @Target. It also assumes you can compile and run Java from the command line.2 min read