Title: Theory / Unimportant / CS / Programming / Java / Reflection
Tags: seen_description automatedNewLineAfterCommaSpace computer_to_instruction empty_card_tonames empty_card_tonotations
On every note of this deck, unless a note says otherwise:
Language: java

Typ: Class
Meaning: Represents a class, as an object at runtime
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Language: java

Instruction: obj.getClass()
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Returns: The class of obj
Variables: obj an object

Instruction: cl.class
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Returns: The class object of class cl
Variables: Cl a class name

Instruction: Class.forName("foo")
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Returns: The class represented by the fully qualified name foo

Instruction: cl.getSuperclass()
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Returns: The class inherited by cl
Variables: cl a class

Instruction: cl.getClasses/Field/Method/Constructor()
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Returns: The public (classes, interfaces and enums)/fields/methods/constructor that are members of the cl
Variables: cl a class

Instruction: cl.getDeclaredClasses/Field/Method/Constructor()
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Returns: The (classes, interfaces and enums)/fields/methods/constructors that are declared in cl (not the inherited one)
Variables: cl a class

Instruction: elt.getDeclaringClasses()
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Returns: The class in which elt is declared
Variables: elt an element part of the code, Class, field, method, constructor

Typ: java.lang.reflect.Field
Meaning: A field of a class
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Language: java

Typ: java.lang.reflect.Method
Meaning: A method of a class
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Language: java

Typ: java.lang.reflect.Constructor
Meaning: A constructor of a class
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Language: java

Instruction: elt.getEnclosingClass()
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Returns: the immediately enclosing class of the class.
Variables: elt an element part of the code, Class, field, method, constructor

Typ: java.lang.reflect.Modifier
TypMeaning: Represents a modifier applied to some declaration
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
Language: java
Value: public, protected, private
Value2: abstract final
Value3: static
Value4: annotations
Value5: strictfp

Instruction: cl.getDeclaredClass/Field/Method/Constructor(
  name,
  parameter_types...
)
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classMembers.html
Returns: One of the more specific element declared in cl (  not inherited), with name name, and parameter of types parameter_types (  arguments present in relevant)

Instruction: cl.getClass/Field/Method/Constructor(
  name,
  parameter_types...
)
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classMembers.html
Returns: One of the more specific public element in cl (  potentially inherited), with name name, and parameter of types parameter_types (  arguments present in relevant)

Instruction: cl.newInstance();
Page: https://docs.oracle.com/javase/tutorial/reflect/class/classMembers.html
Context: Class object
Returns: similar as `new cl()`
Variables: cl a class
Assuming: No argument constructor

Instruction: field.getModifiers()
Page: https://docs.oracle.com/javase/tutorial/reflect/member/fieldModifiers.html
Returns: The binary flag representing the various modifiers of the field
Variables: field a field object

Instruction: field.isSynthetic()
Page: https://docs.oracle.com/javase/tutorial/reflect/member/fieldModifiers.html
Returns: Whether the field is synthetic
Variables: field a field object

Name: A synthetic field
Definition: A compiler generated field
Page: https://docs.oracle.com/javase/tutorial/reflect/member/fieldModifiers.html
Context: java

Instruction: field.isEnumConstant()
Page: https://docs.oracle.com/javase/tutorial/reflect/member/fieldModifiers.html
Returns: Whether the field is an enum constant
Variables: field
Name: A synthetic field

Instruction: field.set(
  obj,
  value
)
Page: https://docs.oracle.com/javase/tutorial/reflect/member/fieldModifiers.html
Effect: Set obj.field to value
Variables: field of class C
Assuming: obj an object of class C
value an object of same type as field

Instruction: field.setLong/Int/Bool...(
  obj,
  value
)
Page: https://docs.oracle.com/javase/tutorial/reflect/member/fieldValues.html
Effect: Set obj.field to value
Variables: field of class C
Assuming: value of type long/int/bool...

Name: AccessibleObject
Definition: the base class for Field, Method and Constructor objects
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AccessibleObject.html#setAccessible-boolean-

Name: Accessible flag
Definition: Flag stating whether the access control checks should be disabled
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AccessibleObject.html#setAccessible-boolean-
Context: AccessibleObject
Intuition: Reflection. E.g. serialization

Instruction: m.getGenericReturnType()
Page: https://docs.oracle.com/javase/tutorial/reflect/member/methodType.html
Returns: The return type of m (with generic parameters)
Variables: m a method

Instruction: m.getGenericParameterType()
Page: https://docs.oracle.com/javase/tutorial/reflect/member/methodType.html
Returns: The array of type of parameters of m (with their generic values)
Variables: m a method

Instruction: m.getGenericExceptionType()
Page: https://docs.oracle.com/javase/tutorial/reflect/member/methodType.html
Returns: The array of type of exception thrown by m (with their generic values)
Variables: m a method

Instruction: m.isVarArgs()
Page: https://docs.oracle.com/javase/tutorial/reflect/member/methodType.html
Returns: whether the last variable is var args
Variables: m a method

Typ: Type
Meaning: the common superinterface for all types in the Java programming language
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html
Language: java

Instruction: t.getTypeName
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html
Returns: a string describing this type, including information about any type parameters.
Variables: Type t

Instruction: array_type.getGenericComponentType()
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/GenericArrayType.html
Returns: a Type object representing the component type of this array.
Variables: GeneracyArrayType array_type

Typ: ParameterizedType
Meaning: a parameterized type such as Collection<String>
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/ParameterizedType.html
Language: java

Instruction: parameterized_type.getActualTypesArguments()
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/ParameterizedType.html
Returns: The array of types of arguments to parameterized_type
Variables: ParameterizedType parameterized_type

Instruction: parameterized_type.getOwnerType()
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/ParameterizedType.html
Returns: the type that this type is a member of.
Variables: ParameterizedType parameterized_type
Example: For example, if this type is O<T>.I<S>, return a representation of O<T>.

Instruction: parameterized_type.getRawType()
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/ParameterizedType.html
Returns: the Type object representing the class or interface that declared this type.
Variables: ParameterizedType parameterized_type

Typ: GenericDeclaration
Meaning: A common interface for all entities that declare type variables.
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/GenericDeclaration.html
Language: java

Instruction: generic_declaration.getTypeParameters
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/GenericDeclaration.html
Returns: array of TypeVariable objects that represent the type variables declared by the generic declaration represented by this GenericDeclaration object, in declaration order. Returns an array of length 0 if the underlying generic declaration declares no type variables.
Variables: GenericDeclaration generic_declaration

Typ: TypeVariable<D>
Meaning: Represents a type variable in a generic type. D represents the declaration where this type is used
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/TypeVariable.html
Language: java

Instruction: getAnnotatedBounds()
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/TypeVariable.html
Returns: The array of annotated type representing the upper bound(s) of this type variable.
Variables: TypeVariable<D>

Instruction: getAGenericDeclarations()
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/TypeVariable.html
Returns: the GenericDeclaration object representing the generic declaration declared this type variable.
Variables: TypeVariable<D>

Typ: GenericDeclaration
Meaning: A common interface for all entities that declare type variables.
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/TypeVariable.html
Language: java

Typ: WildcardType
Page: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/TypeVariable.html
Language: java
Implementation: Represents a type with a "?"

Instruction: m.invoke(
  object,
  arg1,
  ..., argn
)
Page: https://docs.oracle.com/javase/tutorial/reflect/member/methodInvocation.html
Effect: Call the method object.m (or statically if object is null)
Returns: Value of m on those args
Variables: m a method
Exception: Exception raised by m catched in InvocationTargetException

Typ: Constructor
Meaning: Represents a class constructor
Page: https://docs.oracle.com/javase/tutorial/reflect/member/ctorLocation.html
Language: java