SlideShare une entreprise Scribd logo
1  sur  31
HoChiMinh University of Science Java Programming Course Java Reflection API & Reference Object December 2010
Agenda
Introduction What does “Reflection” mean ? What’s Java Reflection API ? Java Reflection API Usage “Hello Reflection” Demo 3
Introduction… What does “Reflection” mean ? 	In computer science, reflection is the process by which a computer program can observe and modify its own structure and behavior at runtime[1].  4
Introduction… 5 What’s Java Reflection API? An Java program contains many objects. Java Reflection API includes classes, interfaces support developer can retrieve and manipulate its object at runtime.
Introduction … Java Reflection API ,[object Object]
java.lang.reflect.AnnotatedElement
java.lang.reflect.GenericDeclaration
java.lang.reflect.InvocationHandler
java.lang.reflect.Member
java.lang.reflect.Type6
Introduction … Java Reflection API … ,[object Object],java.lang.reflect.AccessibleObject ,[object Object]
java.lang.reflect.Field
java.lang.reflect.Methodjava.lang.reflect.Array java.lang.reflect.Modifier java.lang.reflect.Proxy 7
Introduction … Java Reflection API … ,[object Object],java.lang.reflect.InvocationTargetException		          	java.lang.reflect.MalformedParameterizedTypeException 		java.lang.reflect.UndeclaredThrowableException ,[object Object],java.lang.reflect.GenericSignatureFormatError 8
Introduction… Usage ,[object Object]
IDE’s Visual Assistant
Visual Debugger & Tester Tools
Object Relational Mapping
Application Server Deploy Configuration9
Agenda
java.lang.Class class Kind of Java types Class object How to get a Class object  How to get Class’ members object Instantiate a new object from its Class 11
java.lang.Class class … Kind of Java types Primitive type e.g : int, double, float, short, long, byte, char, void Reference type e.g : class, interface, array, enum, annotation 12
java.lang.Class class… Class object Instances of the class Class represent classes and interfaces in a running Java application. Has no public constructor. Are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader. 13
java.lang.Class class… How to get a Class object getClass() method .class syntax forName() static method  .TYPE syntax Other methods 14
java.lang.Class class… How to get Class’ members object 15 Get Constructors Constructor<T> getConstructor(Class<T>…  parameterTypes) Constructor<?> [] getConstructors() Constructor<T> getDeclaredConstructor(Class<T>… parameterTypes) Constructor<?> [] getDeclaredConstructors() GetFields Field getField(String fieldName) Field [] getFields() Field getDeclaredField(String fieldName) Field [] getDeclaredFields()
java.lang.Class class… How to get Class’ members object 16 Get Methods Method getMethod(String name, Class<T>…  parameterTypes) Method [] getMethods() Method getDeclaredMethod(String name, Class<T>…  parameterTypes) Method [] getDeclaredMethods(); GetModifiers int  getModifiers()
java.lang.Class class… How to get Class’ members object 17 Get Package Package getPackage() Other methods Ref : JDK Document
Agenda
Class member java.lang.reflect ,[object Object]
Field

Contenu connexe

Tendances

How to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingHow to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programming
Syed Faizan Hassan
 
Object-Oriented Programming with C#
Object-Oriented Programming with C#Object-Oriented Programming with C#
Object-Oriented Programming with C#
Svetlin Nakov
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
FALLEE31188
 
C# Starter L03-Utilities
C# Starter L03-UtilitiesC# Starter L03-Utilities
C# Starter L03-Utilities
Mohammad Shaker
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
backdoor
 
Defining classes-part-i-constructors-properties
Defining classes-part-i-constructors-propertiesDefining classes-part-i-constructors-properties
Defining classes-part-i-constructors-properties
CtOlaf
 
Access controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesAccess controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modes
Vinay Kumar
 

Tendances (20)

Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
 
Write First C++ class
Write First C++ classWrite First C++ class
Write First C++ class
 
Java OO Revisited
Java OO RevisitedJava OO Revisited
Java OO Revisited
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
 
Object oriented programming 2
Object oriented programming 2Object oriented programming 2
Object oriented programming 2
 
How to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingHow to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programming
 
C++ And Object in lecture3
C++  And Object in lecture3C++  And Object in lecture3
C++ And Object in lecture3
 
The Ring programming language version 1.8 book - Part 38 of 202
The Ring programming language version 1.8 book - Part 38 of 202The Ring programming language version 1.8 book - Part 38 of 202
The Ring programming language version 1.8 book - Part 38 of 202
 
Object-Oriented Programming with C#
Object-Oriented Programming with C#Object-Oriented Programming with C#
Object-Oriented Programming with C#
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
core java
core javacore java
core java
 
class c++
class c++class c++
class c++
 
Unidad o informatica en ingles
Unidad o informatica en inglesUnidad o informatica en ingles
Unidad o informatica en ingles
 
OOP with Java - continued
OOP with Java - continuedOOP with Java - continued
OOP with Java - continued
 
C# Starter L03-Utilities
C# Starter L03-UtilitiesC# Starter L03-Utilities
C# Starter L03-Utilities
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
 
Defining classes-part-i-constructors-properties
Defining classes-part-i-constructors-propertiesDefining classes-part-i-constructors-properties
Defining classes-part-i-constructors-properties
 
Class and object in c++
Class and object in c++Class and object in c++
Class and object in c++
 
Access controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesAccess controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modes
 

En vedette (10)

Nse
NseNse
Nse
 
Ejemplo 1
Ejemplo 1Ejemplo 1
Ejemplo 1
 
The Mirror
The MirrorThe Mirror
The Mirror
 
Java Reflection Concept and Working
Java Reflection Concept and WorkingJava Reflection Concept and Working
Java Reflection Concept and Working
 
Gurumudra
GurumudraGurumudra
Gurumudra
 
Sex edn,
Sex edn,Sex edn,
Sex edn,
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in java
 
Java reflection
Java reflectionJava reflection
Java reflection
 
Java Reflection Explained Simply
Java Reflection Explained SimplyJava Reflection Explained Simply
Java Reflection Explained Simply
 
Reflection and Refraction
Reflection and RefractionReflection and Refraction
Reflection and Refraction
 

Similaire à Cuối cùng cũng đã chuẩn bị slide xong cho seminar ngày mai. Mai seminar đầu tiên luôn

Reflection in java
Reflection in javaReflection in java
Reflection in java
upen.rockin
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
Satya Johnny
 

Similaire à Cuối cùng cũng đã chuẩn bị slide xong cho seminar ngày mai. Mai seminar đầu tiên luôn (20)

Java Reflection
Java ReflectionJava Reflection
Java Reflection
 
Reflection in java
Reflection in javaReflection in java
Reflection in java
 
C++ classes
C++ classesC++ classes
C++ classes
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
C++ classes
C++ classesC++ classes
C++ classes
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
19 reflection
19   reflection19   reflection
19 reflection
 
Chapter 8 Inheritance
Chapter 8 InheritanceChapter 8 Inheritance
Chapter 8 Inheritance
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptx
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Oops concept
Oops conceptOops concept
Oops concept
 
20 Object-oriented programming principles
20 Object-oriented programming principles20 Object-oriented programming principles
20 Object-oriented programming principles
 
Java Reflection
Java ReflectionJava Reflection
Java Reflection
 
Adv kvr -satya
Adv  kvr -satyaAdv  kvr -satya
Adv kvr -satya
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
 
OBJECT ORIENTED PROGRAMING IN C++
OBJECT ORIENTED PROGRAMING IN C++ OBJECT ORIENTED PROGRAMING IN C++
OBJECT ORIENTED PROGRAMING IN C++
 
11slide.ppt
11slide.ppt11slide.ppt
11slide.ppt
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Cuối cùng cũng đã chuẩn bị slide xong cho seminar ngày mai. Mai seminar đầu tiên luôn