SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
(very)

short introduction into
scala reflection
by david pichsenmeister
Agenda
● What is Reflection?
● Scala reflection Universe
● Mirrors (information providers)
● Symbols
● Some Examples
What is reflection?
Reflection is the ability to inspect, and possibly
even modify itself at runtime. [1]
1. Runtime reflection
2. Compile-time reflection
3. Reification
introduced in Scala 2.10
[1]http://docs.scala-lang.org/overviews/reflection/overview.html
(the) Universe
entry point to Scala’s reflection
provides an interface to main types:
Types
Symbols (definitions)
Trees (abstract syntax trees)
Names (terms and type names)
Annotations
Constants
Positions (source position of tree nodes)
FlagSet (sets of flags that apply to symbol and definition
trees)
(the) Universe
imports
Mirrors
information provided by reflection accessible
through mirrors
different flavors of mirrors
Classloader Mirrors
Invoker Mirrors
obtaining special Invoker Mirrors from
Classloader Mirror
Types of Mirrors & their usecases
ReflectiveMirror
loading symbols by name
entry point to invoker mirrors
InstanceMirror
creating Invoker Mirrors
MethodMirrors
invoking instance methods
Types of Mirrors & their usecases
ClassMirror
creating invoker mirrors for constructors
ModuleMirror
getting singleton instances of objects
FieldMirror
getting/settings instance fields
Symbols
bindings between a name and the entity it
refers to
TypeSymbol
type, class, trait declarations
e.g. ClassSymbol
TermSymbol
val, var, def, object declarations
e.g. MethodSymbol, ModuleSymbol
Examples
val mirror: RuntimeMirror = universe.runtimeMirror(getClass.getClassLoader)
> res0: reflect.runtime.universe.Mirror = JavaMirror with scala.tools.n…
class Reflect(x: Int)
val clz: ClassSymbol = typeOf[Reflect].typeSymbol.asClass
> res1: reflect.runtime.universe.ClassSymbol = class Reflect
def getTypeTag[T: universe.TypeTag](obj: T) = universe.typeTag[T]
val r = new Reflect(4)
val clz: ClassSymbol = getTypeTag( r).tpe.typeSymbol.asClass
> res2: reflect.runtime.universe.ClassSymbol = class Reflect
val cm: ClassMirror = mirror.reflectClass( clz)
> res3: reflect.runtime.universe.ClassMirror = class mirror for Reflect
(bound to null)

object C{ def x = 2}
val mod: ModuleSymbol = typeOf[C.type].termSymbol.asModule
> res4: reflect.runtime.universe.ModuleSymbol = object C
val mm: ModuleMirror = mirror.reflectModule( mod)
> res5: reflect.runtime.universe.ModuleMirror = module mirror for C (bound
to null)
Examples
invoking a constructor
Examples
invoking a class instance

invoking an object instance
Examples
reflecting a method

alternative:
THANKS!

Mais conteúdo relacionado

Mais procurados

Strategi dalam proses manajemen strategik
Strategi dalam proses manajemen strategikStrategi dalam proses manajemen strategik
Strategi dalam proses manajemen strategikIzul chumzq
 
Konsep Manajemen Operasional
Konsep Manajemen OperasionalKonsep Manajemen Operasional
Konsep Manajemen OperasionalSari Amelia
 
Aplikasi teori permintaan dalam bisnis
Aplikasi teori permintaan dalam bisnisAplikasi teori permintaan dalam bisnis
Aplikasi teori permintaan dalam bisnisWahono Diphayana
 
Analisis Dana, Arus Kas, dan Perencanaan keuangan
Analisis Dana, Arus Kas, dan Perencanaan keuangan Analisis Dana, Arus Kas, dan Perencanaan keuangan
Analisis Dana, Arus Kas, dan Perencanaan keuangan AdillaShafaNafisaMar
 
Mengembangkan Strategi dan Program Penetapan Harga
Mengembangkan Strategi dan Program Penetapan HargaMengembangkan Strategi dan Program Penetapan Harga
Mengembangkan Strategi dan Program Penetapan HargaShifa Khairunnisa
 
Bab 6 Sumber sumber penawaran modal
Bab 6 Sumber sumber penawaran modal Bab 6 Sumber sumber penawaran modal
Bab 6 Sumber sumber penawaran modal desikurnianengsih
 
Strategi dan Rencana Pemasaran
Strategi dan Rencana PemasaranStrategi dan Rencana Pemasaran
Strategi dan Rencana PemasaranRicky A Peaceful
 
WSO2 API Manager y ESB la plataforma perfecta para evolucionar los servicios
WSO2 API Manager y ESB la plataforma perfecta para evolucionar los serviciosWSO2 API Manager y ESB la plataforma perfecta para evolucionar los servicios
WSO2 API Manager y ESB la plataforma perfecta para evolucionar los serviciosWSO2
 
Forecasting Peramalan BAB 3 Manajemen Operasi
Forecasting Peramalan BAB 3 Manajemen Operasi Forecasting Peramalan BAB 3 Manajemen Operasi
Forecasting Peramalan BAB 3 Manajemen Operasi Yusnia Rahmah Afianti
 
STUDY CASE: MUJIGAE KOREAN RESTO
STUDY CASE: MUJIGAE KOREAN RESTOSTUDY CASE: MUJIGAE KOREAN RESTO
STUDY CASE: MUJIGAE KOREAN RESTOLia Amelia
 
Pengendalian SIA Berbasis Komputer
Pengendalian SIA Berbasis KomputerPengendalian SIA Berbasis Komputer
Pengendalian SIA Berbasis Komputerdedidarwis
 
KONSEP-KONSEP DASAR AKUNTANSI MANAJEMEN
KONSEP-KONSEP DASAR AKUNTANSI MANAJEMEN KONSEP-KONSEP DASAR AKUNTANSI MANAJEMEN
KONSEP-KONSEP DASAR AKUNTANSI MANAJEMEN YOHANIS SAHABAT
 
Ilustrasi Perhitungan IHSG
Ilustrasi Perhitungan IHSGIlustrasi Perhitungan IHSG
Ilustrasi Perhitungan IHSGTrisnadi Wijaya
 
Strategi dan Rencana Pemasaran
Strategi dan Rencana PemasaranStrategi dan Rencana Pemasaran
Strategi dan Rencana PemasaranMuhammad Fajar
 
Strategi Dalam Pelaksanaan
Strategi Dalam PelaksanaanStrategi Dalam Pelaksanaan
Strategi Dalam PelaksanaanAnis Fithriyani
 

Mais procurados (20)

Implementing Einstein OCR
Implementing Einstein OCRImplementing Einstein OCR
Implementing Einstein OCR
 
Strategi dalam proses manajemen strategik
Strategi dalam proses manajemen strategikStrategi dalam proses manajemen strategik
Strategi dalam proses manajemen strategik
 
Konsep Manajemen Operasional
Konsep Manajemen OperasionalKonsep Manajemen Operasional
Konsep Manajemen Operasional
 
Aplikasi teori permintaan dalam bisnis
Aplikasi teori permintaan dalam bisnisAplikasi teori permintaan dalam bisnis
Aplikasi teori permintaan dalam bisnis
 
Analisis Dana, Arus Kas, dan Perencanaan keuangan
Analisis Dana, Arus Kas, dan Perencanaan keuangan Analisis Dana, Arus Kas, dan Perencanaan keuangan
Analisis Dana, Arus Kas, dan Perencanaan keuangan
 
Mengembangkan Strategi dan Program Penetapan Harga
Mengembangkan Strategi dan Program Penetapan HargaMengembangkan Strategi dan Program Penetapan Harga
Mengembangkan Strategi dan Program Penetapan Harga
 
Bab 6 Sumber sumber penawaran modal
Bab 6 Sumber sumber penawaran modal Bab 6 Sumber sumber penawaran modal
Bab 6 Sumber sumber penawaran modal
 
Strategi dan Rencana Pemasaran
Strategi dan Rencana PemasaranStrategi dan Rencana Pemasaran
Strategi dan Rencana Pemasaran
 
WSO2 API Manager y ESB la plataforma perfecta para evolucionar los servicios
WSO2 API Manager y ESB la plataforma perfecta para evolucionar los serviciosWSO2 API Manager y ESB la plataforma perfecta para evolucionar los servicios
WSO2 API Manager y ESB la plataforma perfecta para evolucionar los servicios
 
Forecasting Peramalan BAB 3 Manajemen Operasi
Forecasting Peramalan BAB 3 Manajemen Operasi Forecasting Peramalan BAB 3 Manajemen Operasi
Forecasting Peramalan BAB 3 Manajemen Operasi
 
STUDY CASE: MUJIGAE KOREAN RESTO
STUDY CASE: MUJIGAE KOREAN RESTOSTUDY CASE: MUJIGAE KOREAN RESTO
STUDY CASE: MUJIGAE KOREAN RESTO
 
Pengendalian SIA Berbasis Komputer
Pengendalian SIA Berbasis KomputerPengendalian SIA Berbasis Komputer
Pengendalian SIA Berbasis Komputer
 
KONSEP-KONSEP DASAR AKUNTANSI MANAJEMEN
KONSEP-KONSEP DASAR AKUNTANSI MANAJEMEN KONSEP-KONSEP DASAR AKUNTANSI MANAJEMEN
KONSEP-KONSEP DASAR AKUNTANSI MANAJEMEN
 
Depresiasi Aset Tetap-SR
Depresiasi Aset Tetap-SRDepresiasi Aset Tetap-SR
Depresiasi Aset Tetap-SR
 
Perhitungan abc
Perhitungan abcPerhitungan abc
Perhitungan abc
 
risk and return
risk and returnrisk and return
risk and return
 
Akt manajemen bab 5
Akt manajemen bab 5Akt manajemen bab 5
Akt manajemen bab 5
 
Ilustrasi Perhitungan IHSG
Ilustrasi Perhitungan IHSGIlustrasi Perhitungan IHSG
Ilustrasi Perhitungan IHSG
 
Strategi dan Rencana Pemasaran
Strategi dan Rencana PemasaranStrategi dan Rencana Pemasaran
Strategi dan Rencana Pemasaran
 
Strategi Dalam Pelaksanaan
Strategi Dalam PelaksanaanStrategi Dalam Pelaksanaan
Strategi Dalam Pelaksanaan
 

Destaque

Scala Reflection & Runtime MetaProgramming
Scala Reflection & Runtime MetaProgrammingScala Reflection & Runtime MetaProgramming
Scala Reflection & Runtime MetaProgrammingMeir Maor
 
Scaladoc for reflection
Scaladoc for reflectionScaladoc for reflection
Scaladoc for reflectionVlad Ureche
 
Development and deployment of polyglot systems
Development and deployment of polyglot systemsDevelopment and deployment of polyglot systems
Development and deployment of polyglot systemsDavid Pichsenmeister
 
The Hitchhikers Guide To Html5 Offline Strategies (+firefoxOS)
The Hitchhikers Guide To Html5 Offline Strategies (+firefoxOS)The Hitchhikers Guide To Html5 Offline Strategies (+firefoxOS)
The Hitchhikers Guide To Html5 Offline Strategies (+firefoxOS)David Pichsenmeister
 
ReactiveMongo - non blocking and asynchronous I/O operations
ReactiveMongo - non blocking and asynchronous I/O operationsReactiveMongo - non blocking and asynchronous I/O operations
ReactiveMongo - non blocking and asynchronous I/O operationsDavid Pichsenmeister
 
Will Chatbots kill apps? - Vienna Valley #7
Will Chatbots kill apps? - Vienna Valley #7Will Chatbots kill apps? - Vienna Valley #7
Will Chatbots kill apps? - Vienna Valley #7David Pichsenmeister
 
play! scala file resource handling and image resizing
play! scala file resource handling and image resizingplay! scala file resource handling and image resizing
play! scala file resource handling and image resizingDavid Pichsenmeister
 
warp engine - an open source realtime push engine
warp engine - an open source realtime push enginewarp engine - an open source realtime push engine
warp engine - an open source realtime push engineDavid Pichsenmeister
 
Scala 2.10.0 (english version)
Scala 2.10.0 (english version)Scala 2.10.0 (english version)
Scala 2.10.0 (english version)Daniel Sobral
 
Metaprogramming in Scala 2.10, Eugene Burmako,
Metaprogramming  in Scala 2.10, Eugene Burmako, Metaprogramming  in Scala 2.10, Eugene Burmako,
Metaprogramming in Scala 2.10, Eugene Burmako, Vasil Remeniuk
 
The Connected Classroom, III Jornadas Internacionales de Lenguas Extranjeras,...
The Connected Classroom, III Jornadas Internacionales de Lenguas Extranjeras,...The Connected Classroom, III Jornadas Internacionales de Lenguas Extranjeras,...
The Connected Classroom, III Jornadas Internacionales de Lenguas Extranjeras,...mariacolussa
 
Taller 3 melissa andrea benavides caballero
Taller 3  melissa andrea benavides caballeroTaller 3  melissa andrea benavides caballero
Taller 3 melissa andrea benavides caballeromelissa1andrea
 

Destaque (20)

Scala Reflection & Runtime MetaProgramming
Scala Reflection & Runtime MetaProgrammingScala Reflection & Runtime MetaProgramming
Scala Reflection & Runtime MetaProgramming
 
Scaladoc for reflection
Scaladoc for reflectionScaladoc for reflection
Scaladoc for reflection
 
Bot Trends 2016
Bot Trends 2016Bot Trends 2016
Bot Trends 2016
 
Development and deployment of polyglot systems
Development and deployment of polyglot systemsDevelopment and deployment of polyglot systems
Development and deployment of polyglot systems
 
The Hitchhikers Guide To Html5 Offline Strategies (+firefoxOS)
The Hitchhikers Guide To Html5 Offline Strategies (+firefoxOS)The Hitchhikers Guide To Html5 Offline Strategies (+firefoxOS)
The Hitchhikers Guide To Html5 Offline Strategies (+firefoxOS)
 
ReactiveMongo - non blocking and asynchronous I/O operations
ReactiveMongo - non blocking and asynchronous I/O operationsReactiveMongo - non blocking and asynchronous I/O operations
ReactiveMongo - non blocking and asynchronous I/O operations
 
Will Chatbots kill apps? - Vienna Valley #7
Will Chatbots kill apps? - Vienna Valley #7Will Chatbots kill apps? - Vienna Valley #7
Will Chatbots kill apps? - Vienna Valley #7
 
play! scala file resource handling and image resizing
play! scala file resource handling and image resizingplay! scala file resource handling and image resizing
play! scala file resource handling and image resizing
 
Telegram's Bot Platform
Telegram's Bot PlatformTelegram's Bot Platform
Telegram's Bot Platform
 
html5 web apps vs native apps
html5 web apps vs native appshtml5 web apps vs native apps
html5 web apps vs native apps
 
warp engine - an open source realtime push engine
warp engine - an open source realtime push enginewarp engine - an open source realtime push engine
warp engine - an open source realtime push engine
 
Scala 2.10.0 (english version)
Scala 2.10.0 (english version)Scala 2.10.0 (english version)
Scala 2.10.0 (english version)
 
Metaprogramming in Scala 2.10, Eugene Burmako,
Metaprogramming  in Scala 2.10, Eugene Burmako, Metaprogramming  in Scala 2.10, Eugene Burmako,
Metaprogramming in Scala 2.10, Eugene Burmako,
 
Aspi google docs
Aspi google docsAspi google docs
Aspi google docs
 
The Connected Classroom, III Jornadas Internacionales de Lenguas Extranjeras,...
The Connected Classroom, III Jornadas Internacionales de Lenguas Extranjeras,...The Connected Classroom, III Jornadas Internacionales de Lenguas Extranjeras,...
The Connected Classroom, III Jornadas Internacionales de Lenguas Extranjeras,...
 
Brochure_PYS
Brochure_PYSBrochure_PYS
Brochure_PYS
 
CodeBook in the Cloud
CodeBook in the CloudCodeBook in the Cloud
CodeBook in the Cloud
 
Aspi new trends
Aspi new trendsAspi new trends
Aspi new trends
 
Taller 3 melissa andrea benavides caballero
Taller 3  melissa andrea benavides caballeroTaller 3  melissa andrea benavides caballero
Taller 3 melissa andrea benavides caballero
 
CodeBook at the Conferences
CodeBook at the ConferencesCodeBook at the Conferences
CodeBook at the Conferences
 

Semelhante a Scala reflection

Scalaマクロ入門 bizr20170217
Scalaマクロ入門 bizr20170217 Scalaマクロ入門 bizr20170217
Scalaマクロ入門 bizr20170217 dcubeio
 
Practical type mining in Scala
Practical type mining in ScalaPractical type mining in Scala
Practical type mining in ScalaRose Toomey
 
Reflection in Scala Whats, Whys and Hows - Walter Cazzola (Dipartimento di In...
Reflection in Scala Whats, Whys and Hows - Walter Cazzola (Dipartimento di In...Reflection in Scala Whats, Whys and Hows - Walter Cazzola (Dipartimento di In...
Reflection in Scala Whats, Whys and Hows - Walter Cazzola (Dipartimento di In...Scala Italy
 
.NET Attributes and Reflection - What a Developer Needs to Know...
.NET Attributes and Reflection - What a Developer Needs to Know....NET Attributes and Reflection - What a Developer Needs to Know...
.NET Attributes and Reflection - What a Developer Needs to Know...Dan Douglas
 
Reflection in java
Reflection in javaReflection in java
Reflection in javaupen.rockin
 
The Scala Refactoring Library: Problems and Perspectives
The Scala Refactoring Library: Problems and PerspectivesThe Scala Refactoring Library: Problems and Perspectives
The Scala Refactoring Library: Problems and PerspectivesMatthias Langer
 
DockerFinder: Multi-attribute search of Docker images
DockerFinder: Multi-attribute search of Docker imagesDockerFinder: Multi-attribute search of Docker images
DockerFinder: Multi-attribute search of Docker imagesDavide Neri
 
Extending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective LanguagesExtending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective Languagesfranciscoortin
 
Scala fun part: Reflection(runtime)
Scala fun part: Reflection(runtime)Scala fun part: Reflection(runtime)
Scala fun part: Reflection(runtime)vito jeng
 
scala.reflect, Eugene Burmako
scala.reflect, Eugene Burmakoscala.reflect, Eugene Burmako
scala.reflect, Eugene BurmakoVasil Remeniuk
 
Евгений Бурмако «scala.reflect»
Евгений Бурмако «scala.reflect»Евгений Бурмако «scala.reflect»
Евгений Бурмако «scala.reflect»e-Legion
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using ReflectionGanesh Samarthyam
 
Solr中国8月4日答疑交流v2
Solr中国8月4日答疑交流v2Solr中国8月4日答疑交流v2
Solr中国8月4日答疑交流v2longkeyy
 
L0043 - Interfacing to Eclipse Standard Views
L0043 - Interfacing to Eclipse Standard ViewsL0043 - Interfacing to Eclipse Standard Views
L0043 - Interfacing to Eclipse Standard ViewsTonny Madsen
 
Scala and its Ecosystem
Scala and its EcosystemScala and its Ecosystem
Scala and its EcosystemPetr Hošek
 
Software engineering: design for reuse
Software engineering: design for reuseSoftware engineering: design for reuse
Software engineering: design for reuseMarco Brambilla
 
Reflections the most important feature in java
Reflections   the most important feature in javaReflections   the most important feature in java
Reflections the most important feature in javaSarath Soman
 

Semelhante a Scala reflection (20)

Scalaマクロ入門 bizr20170217
Scalaマクロ入門 bizr20170217 Scalaマクロ入門 bizr20170217
Scalaマクロ入門 bizr20170217
 
Practical type mining in Scala
Practical type mining in ScalaPractical type mining in Scala
Practical type mining in Scala
 
Reflection in Scala Whats, Whys and Hows - Walter Cazzola (Dipartimento di In...
Reflection in Scala Whats, Whys and Hows - Walter Cazzola (Dipartimento di In...Reflection in Scala Whats, Whys and Hows - Walter Cazzola (Dipartimento di In...
Reflection in Scala Whats, Whys and Hows - Walter Cazzola (Dipartimento di In...
 
.NET Attributes and Reflection - What a Developer Needs to Know...
.NET Attributes and Reflection - What a Developer Needs to Know....NET Attributes and Reflection - What a Developer Needs to Know...
.NET Attributes and Reflection - What a Developer Needs to Know...
 
Reflection in java
Reflection in javaReflection in java
Reflection in java
 
The Scala Refactoring Library: Problems and Perspectives
The Scala Refactoring Library: Problems and PerspectivesThe Scala Refactoring Library: Problems and Perspectives
The Scala Refactoring Library: Problems and Perspectives
 
Decorator Pattern
Decorator PatternDecorator Pattern
Decorator Pattern
 
DockerFinder: Multi-attribute search of Docker images
DockerFinder: Multi-attribute search of Docker imagesDockerFinder: Multi-attribute search of Docker images
DockerFinder: Multi-attribute search of Docker images
 
Extending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective LanguagesExtending Rotor with Structural Reflection to support Reflective Languages
Extending Rotor with Structural Reflection to support Reflective Languages
 
Reflection in Java
Reflection in JavaReflection in Java
Reflection in Java
 
Scala fun part: Reflection(runtime)
Scala fun part: Reflection(runtime)Scala fun part: Reflection(runtime)
Scala fun part: Reflection(runtime)
 
scala.reflect, Eugene Burmako
scala.reflect, Eugene Burmakoscala.reflect, Eugene Burmako
scala.reflect, Eugene Burmako
 
Евгений Бурмако «scala.reflect»
Евгений Бурмако «scala.reflect»Евгений Бурмако «scala.reflect»
Евгений Бурмако «scala.reflect»
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
 
Solr中国8月4日答疑交流v2
Solr中国8月4日答疑交流v2Solr中国8月4日答疑交流v2
Solr中国8月4日答疑交流v2
 
L0043 - Interfacing to Eclipse Standard Views
L0043 - Interfacing to Eclipse Standard ViewsL0043 - Interfacing to Eclipse Standard Views
L0043 - Interfacing to Eclipse Standard Views
 
Scala and its Ecosystem
Scala and its EcosystemScala and its Ecosystem
Scala and its Ecosystem
 
core_java.ppt
core_java.pptcore_java.ppt
core_java.ppt
 
Software engineering: design for reuse
Software engineering: design for reuseSoftware engineering: design for reuse
Software engineering: design for reuse
 
Reflections the most important feature in java
Reflections   the most important feature in javaReflections   the most important feature in java
Reflections the most important feature in java
 

Mais de David Pichsenmeister

Bots as Marketing Channels for Events
Bots as Marketing Channels for EventsBots as Marketing Channels for Events
Bots as Marketing Channels for EventsDavid Pichsenmeister
 
The art of building successful products
The art of building successful productsThe art of building successful products
The art of building successful productsDavid Pichsenmeister
 
Vue.js SSR with Nuxt.js and Firebase
Vue.js SSR with Nuxt.js and Firebase Vue.js SSR with Nuxt.js and Firebase
Vue.js SSR with Nuxt.js and Firebase David Pichsenmeister
 
Work at oratio - Tools for distributed teams
Work at oratio - Tools for distributed teamsWork at oratio - Tools for distributed teams
Work at oratio - Tools for distributed teamsDavid Pichsenmeister
 
Chatbots - Canonical Interfaces as new Communication Channels
Chatbots - Canonical Interfaces as new Communication ChannelsChatbots - Canonical Interfaces as new Communication Channels
Chatbots - Canonical Interfaces as new Communication ChannelsDavid Pichsenmeister
 

Mais de David Pichsenmeister (8)

Bots as Marketing Channels for Events
Bots as Marketing Channels for EventsBots as Marketing Channels for Events
Bots as Marketing Channels for Events
 
The art of building successful products
The art of building successful productsThe art of building successful products
The art of building successful products
 
Basics of Product Strategy
Basics of Product StrategyBasics of Product Strategy
Basics of Product Strategy
 
Vue.js SSR with Nuxt.js and Firebase
Vue.js SSR with Nuxt.js and Firebase Vue.js SSR with Nuxt.js and Firebase
Vue.js SSR with Nuxt.js and Firebase
 
Work at oratio - Tools for distributed teams
Work at oratio - Tools for distributed teamsWork at oratio - Tools for distributed teams
Work at oratio - Tools for distributed teams
 
How to build a great bot
How to build a great botHow to build a great bot
How to build a great bot
 
Chatbots - Canonical Interfaces as new Communication Channels
Chatbots - Canonical Interfaces as new Communication ChannelsChatbots - Canonical Interfaces as new Communication Channels
Chatbots - Canonical Interfaces as new Communication Channels
 
Bot Trends 2017
Bot Trends 2017Bot Trends 2017
Bot Trends 2017
 

Último

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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 textsMaria Levchenko
 
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 slidevu2urc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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 RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Scala reflection

  • 1. (very) short introduction into scala reflection by david pichsenmeister
  • 2. Agenda ● What is Reflection? ● Scala reflection Universe ● Mirrors (information providers) ● Symbols ● Some Examples
  • 3. What is reflection? Reflection is the ability to inspect, and possibly even modify itself at runtime. [1] 1. Runtime reflection 2. Compile-time reflection 3. Reification introduced in Scala 2.10 [1]http://docs.scala-lang.org/overviews/reflection/overview.html
  • 4. (the) Universe entry point to Scala’s reflection provides an interface to main types: Types Symbols (definitions) Trees (abstract syntax trees) Names (terms and type names) Annotations Constants Positions (source position of tree nodes) FlagSet (sets of flags that apply to symbol and definition trees)
  • 6. Mirrors information provided by reflection accessible through mirrors different flavors of mirrors Classloader Mirrors Invoker Mirrors obtaining special Invoker Mirrors from Classloader Mirror
  • 7. Types of Mirrors & their usecases ReflectiveMirror loading symbols by name entry point to invoker mirrors InstanceMirror creating Invoker Mirrors MethodMirrors invoking instance methods
  • 8. Types of Mirrors & their usecases ClassMirror creating invoker mirrors for constructors ModuleMirror getting singleton instances of objects FieldMirror getting/settings instance fields
  • 9. Symbols bindings between a name and the entity it refers to TypeSymbol type, class, trait declarations e.g. ClassSymbol TermSymbol val, var, def, object declarations e.g. MethodSymbol, ModuleSymbol
  • 10. Examples val mirror: RuntimeMirror = universe.runtimeMirror(getClass.getClassLoader) > res0: reflect.runtime.universe.Mirror = JavaMirror with scala.tools.n… class Reflect(x: Int) val clz: ClassSymbol = typeOf[Reflect].typeSymbol.asClass > res1: reflect.runtime.universe.ClassSymbol = class Reflect def getTypeTag[T: universe.TypeTag](obj: T) = universe.typeTag[T] val r = new Reflect(4) val clz: ClassSymbol = getTypeTag( r).tpe.typeSymbol.asClass > res2: reflect.runtime.universe.ClassSymbol = class Reflect val cm: ClassMirror = mirror.reflectClass( clz) > res3: reflect.runtime.universe.ClassMirror = class mirror for Reflect (bound to null) object C{ def x = 2} val mod: ModuleSymbol = typeOf[C.type].termSymbol.asModule > res4: reflect.runtime.universe.ModuleSymbol = object C val mm: ModuleMirror = mirror.reflectModule( mod) > res5: reflect.runtime.universe.ModuleMirror = module mirror for C (bound to null)
  • 12. Examples invoking a class instance invoking an object instance