SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
(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!

Weitere Àhnliche Inhalte

Was ist angesagt?

Project Reactor Now and Tomorrow
Project Reactor Now and TomorrowProject Reactor Now and Tomorrow
Project Reactor Now and TomorrowVMware Tanzu
 
Declarative Concurrency with Reactive Programming
Declarative Concurrency with Reactive ProgrammingDeclarative Concurrency with Reactive Programming
Declarative Concurrency with Reactive ProgrammingFlorian Stefan
 
Concurrency in Java
Concurrency in  JavaConcurrency in  Java
Concurrency in JavaAllan Huang
 
Sql cheat-sheet
Sql cheat-sheetSql cheat-sheet
Sql cheat-sheetSteve Tran
 
Java 8 Lambda and Streams
Java 8 Lambda and StreamsJava 8 Lambda and Streams
Java 8 Lambda and StreamsVenkata Naga Ravi
 
Amazon DynamoDB Design Patterns for Ultra-High Performance Apps (DAT304) | AW...
Amazon DynamoDB Design Patterns for Ultra-High Performance Apps (DAT304) | AW...Amazon DynamoDB Design Patterns for Ultra-High Performance Apps (DAT304) | AW...
Amazon DynamoDB Design Patterns for Ultra-High Performance Apps (DAT304) | AW...Amazon Web Services
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockitoshaunthomas999
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and AkkaYung-Lin Ho
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJSBrainhub
 
Java lesson khmer
Java lesson khmerJava lesson khmer
Java lesson khmerUl Sovanndy
 
RxJS - The Basics & The Future
RxJS - The Basics & The FutureRxJS - The Basics & The Future
RxJS - The Basics & The FutureTracy Lee
 
Open Liberty / WebSphere Liberty
Open Liberty / WebSphere LibertyOpen Liberty / WebSphere Liberty
Open Liberty / WebSphere LibertyTakakiyo Tanaka
 
SQL for NoSQL and how Apache Calcite can help
SQL for NoSQL and how  Apache Calcite can helpSQL for NoSQL and how  Apache Calcite can help
SQL for NoSQL and how Apache Calcite can helpChristian Tzolov
 

Was ist angesagt? (20)

Project Reactor Now and Tomorrow
Project Reactor Now and TomorrowProject Reactor Now and Tomorrow
Project Reactor Now and Tomorrow
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Declarative Concurrency with Reactive Programming
Declarative Concurrency with Reactive ProgrammingDeclarative Concurrency with Reactive Programming
Declarative Concurrency with Reactive Programming
 
Introduction to thymeleaf
Introduction to thymeleafIntroduction to thymeleaf
Introduction to thymeleaf
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Concurrency in Java
Concurrency in  JavaConcurrency in  Java
Concurrency in Java
 
Sql cheat-sheet
Sql cheat-sheetSql cheat-sheet
Sql cheat-sheet
 
Java 8 Lambda and Streams
Java 8 Lambda and StreamsJava 8 Lambda and Streams
Java 8 Lambda and Streams
 
Amazon DynamoDB Design Patterns for Ultra-High Performance Apps (DAT304) | AW...
Amazon DynamoDB Design Patterns for Ultra-High Performance Apps (DAT304) | AW...Amazon DynamoDB Design Patterns for Ultra-High Performance Apps (DAT304) | AW...
Amazon DynamoDB Design Patterns for Ultra-High Performance Apps (DAT304) | AW...
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
 
Redux essentials
Redux essentialsRedux essentials
Redux essentials
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and Akka
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJS
 
Nextjs13.pptx
Nextjs13.pptxNextjs13.pptx
Nextjs13.pptx
 
Java lesson khmer
Java lesson khmerJava lesson khmer
Java lesson khmer
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 
RxJS - The Basics & The Future
RxJS - The Basics & The FutureRxJS - The Basics & The Future
RxJS - The Basics & The Future
 
Spring boot
Spring bootSpring boot
Spring boot
 
Open Liberty / WebSphere Liberty
Open Liberty / WebSphere LibertyOpen Liberty / WebSphere Liberty
Open Liberty / WebSphere Liberty
 
SQL for NoSQL and how Apache Calcite can help
SQL for NoSQL and how  Apache Calcite can helpSQL for NoSQL and how  Apache Calcite can help
SQL for NoSQL and how Apache Calcite can help
 

Andere mochten auch

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
 
html5 web apps vs native apps
html5 web apps vs native appshtml5 web apps vs native apps
html5 web apps vs native appsDavid 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
 
Aspi google docs
Aspi google docsAspi google docs
Aspi google docsmariacolussa
 
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
 
Brochure_PYS
Brochure_PYSBrochure_PYS
Brochure_PYSSatpal Singh
 
Aspi new trends
Aspi new trendsAspi new trends
Aspi new trendsmariacolussa
 
Taller 3 melissa andrea benavides caballero
Taller 3  melissa andrea benavides caballeroTaller 3  melissa andrea benavides caballero
Taller 3 melissa andrea benavides caballeromelissa1andrea
 
CodeBook at the Conferences
CodeBook at the ConferencesCodeBook at the Conferences
CodeBook at the ConferencesCodeBookUserGroup
 

Andere mochten auch (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
 

Ähnlich wie 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
 
Decorator Pattern
Decorator PatternDecorator Pattern
Decorator PatternDimuthu Anuraj
 
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
 
Reflection in Java
Reflection in JavaReflection in Java
Reflection in JavaNikhil Bhardwaj
 
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
 
core_java.ppt
core_java.pptcore_java.ppt
core_java.pptYashikaDave
 
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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

KĂŒrzlich hochgeladen

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
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 Processorsdebabhi2
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vĂĄzquez
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

KĂŒrzlich hochgeladen (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
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...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

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