SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
(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!

Contenu connexe

Tendances

L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses étatsJosé Paumard
 
Qlik TECH TALK 新しい編集モード New Authoring Experienceのご紹介
Qlik TECH TALK 新しい編集モード New Authoring Experienceのご紹介Qlik TECH TALK 新しい編集モード New Authoring Experienceのご紹介
Qlik TECH TALK 新しい編集モード New Authoring Experienceのご紹介QlikPresalesJapan
 
Qlik ReplicateでApache Kafkaをターゲットとして使用する
Qlik ReplicateでApache Kafkaをターゲットとして使用するQlik ReplicateでApache Kafkaをターゲットとして使用する
Qlik ReplicateでApache Kafkaをターゲットとして使用するQlikPresalesJapan
 
Ingesting streaming data into Graph Database
Ingesting streaming data into Graph DatabaseIngesting streaming data into Graph Database
Ingesting streaming data into Graph DatabaseGuido Schmutz
 
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...Edureka!
 
Apache Camel K - Copenhagen v2
Apache Camel K - Copenhagen v2Apache Camel K - Copenhagen v2
Apache Camel K - Copenhagen v2Claus Ibsen
 
Important React Hooks
Important React HooksImportant React Hooks
Important React HooksKnoldus Inc.
 
Kafka Tutorial - basics of the Kafka streaming platform
Kafka Tutorial - basics of the Kafka streaming platformKafka Tutorial - basics of the Kafka streaming platform
Kafka Tutorial - basics of the Kafka streaming platformJean-Paul Azar
 
Testing Kafka containers with Testcontainers: There and back again with Vikto...
Testing Kafka containers with Testcontainers: There and back again with Vikto...Testing Kafka containers with Testcontainers: There and back again with Vikto...
Testing Kafka containers with Testcontainers: There and back again with Vikto...HostedbyConfluent
 
Introdução ao Spring Framework MVC
Introdução ao Spring Framework MVCIntrodução ao Spring Framework MVC
Introdução ao Spring Framework MVCMessias Batista
 
Debugging Native heap OOM - JavaOne 2013
Debugging Native heap OOM - JavaOne 2013Debugging Native heap OOM - JavaOne 2013
Debugging Native heap OOM - JavaOne 2013MattKilner
 
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...Edureka!
 
Hook me UP ( React Hooks Introduction)
Hook me UP ( React Hooks Introduction)Hook me UP ( React Hooks Introduction)
Hook me UP ( React Hooks Introduction)Carlos Mafla
 

Tendances (20)

L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses états
 
Qlik TECH TALK 新しい編集モード New Authoring Experienceのご紹介
Qlik TECH TALK 新しい編集モード New Authoring Experienceのご紹介Qlik TECH TALK 新しい編集モード New Authoring Experienceのご紹介
Qlik TECH TALK 新しい編集モード New Authoring Experienceのご紹介
 
08 modificadores static
08   modificadores static08   modificadores static
08 modificadores static
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Qlik ReplicateでApache Kafkaをターゲットとして使用する
Qlik ReplicateでApache Kafkaをターゲットとして使用するQlik ReplicateでApache Kafkaをターゲットとして使用する
Qlik ReplicateでApache Kafkaをターゲットとして使用する
 
Ingesting streaming data into Graph Database
Ingesting streaming data into Graph DatabaseIngesting streaming data into Graph Database
Ingesting streaming data into Graph Database
 
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
 
Spring Data Jpa
Spring Data JpaSpring Data Jpa
Spring Data Jpa
 
Major Java 8 features
Major Java 8 featuresMajor Java 8 features
Major Java 8 features
 
Apache Camel K - Copenhagen v2
Apache Camel K - Copenhagen v2Apache Camel K - Copenhagen v2
Apache Camel K - Copenhagen v2
 
Important React Hooks
Important React HooksImportant React Hooks
Important React Hooks
 
Kafka Tutorial - basics of the Kafka streaming platform
Kafka Tutorial - basics of the Kafka streaming platformKafka Tutorial - basics of the Kafka streaming platform
Kafka Tutorial - basics of the Kafka streaming platform
 
Testing Kafka containers with Testcontainers: There and back again with Vikto...
Testing Kafka containers with Testcontainers: There and back again with Vikto...Testing Kafka containers with Testcontainers: There and back again with Vikto...
Testing Kafka containers with Testcontainers: There and back again with Vikto...
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
Introdução ao Spring Framework MVC
Introdução ao Spring Framework MVCIntrodução ao Spring Framework MVC
Introdução ao Spring Framework MVC
 
Debugging Native heap OOM - JavaOne 2013
Debugging Native heap OOM - JavaOne 2013Debugging Native heap OOM - JavaOne 2013
Debugging Native heap OOM - JavaOne 2013
 
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
 
Refactoring
RefactoringRefactoring
Refactoring
 
Hook me UP ( React Hooks Introduction)
Hook me UP ( React Hooks Introduction)Hook me UP ( React Hooks Introduction)
Hook me UP ( React Hooks Introduction)
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus 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
 

Plus 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
 

Dernier

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Dernier (20)

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

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