SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
(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!

Más contenido relacionado

La actualidad más candente

Parallelizing with Apache Spark in Unexpected Ways
Parallelizing with Apache Spark in Unexpected WaysParallelizing with Apache Spark in Unexpected Ways
Parallelizing with Apache Spark in Unexpected WaysDatabricks
 
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...Databricks
 
How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...DataWorks Summit/Hadoop Summit
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to ElasticsearchRuslan Zavacky
 
Introduction to Apache Calcite
Introduction to Apache CalciteIntroduction to Apache Calcite
Introduction to Apache CalciteJordan Halterman
 
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
The Data Lake Engine Data Microservices in Spark using Apache Arrow FlightThe Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
The Data Lake Engine Data Microservices in Spark using Apache Arrow FlightDatabricks
 
Performance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark MetricsPerformance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark MetricsDatabricks
 
Parquet performance tuning: the missing guide
Parquet performance tuning: the missing guideParquet performance tuning: the missing guide
Parquet performance tuning: the missing guideRyan Blue
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleMartin Odersky
 
Apache Spark on K8S Best Practice and Performance in the Cloud
Apache Spark on K8S Best Practice and Performance in the CloudApache Spark on K8S Best Practice and Performance in the Cloud
Apache Spark on K8S Best Practice and Performance in the CloudDatabricks
 
in-memory database system and low latency
in-memory database system and low latencyin-memory database system and low latency
in-memory database system and low latencyhyeongchae lee
 
Spark SQL Tutorial | Spark SQL Using Scala | Apache Spark Tutorial For Beginn...
Spark SQL Tutorial | Spark SQL Using Scala | Apache Spark Tutorial For Beginn...Spark SQL Tutorial | Spark SQL Using Scala | Apache Spark Tutorial For Beginn...
Spark SQL Tutorial | Spark SQL Using Scala | Apache Spark Tutorial For Beginn...Simplilearn
 
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...StampedeCon
 
Continuous Application with FAIR Scheduler with Robert Xue
Continuous Application with FAIR Scheduler with Robert XueContinuous Application with FAIR Scheduler with Robert Xue
Continuous Application with FAIR Scheduler with Robert XueDatabricks
 
Koalas: Making an Easy Transition from Pandas to Apache Spark
Koalas: Making an Easy Transition from Pandas to Apache SparkKoalas: Making an Easy Transition from Pandas to Apache Spark
Koalas: Making an Easy Transition from Pandas to Apache SparkDatabricks
 
Building Reliable Lakehouses with Apache Flink and Delta Lake
Building Reliable Lakehouses with Apache Flink and Delta LakeBuilding Reliable Lakehouses with Apache Flink and Delta Lake
Building Reliable Lakehouses with Apache Flink and Delta LakeFlink Forward
 
Real-Time Data Flows with Apache NiFi
Real-Time Data Flows with Apache NiFiReal-Time Data Flows with Apache NiFi
Real-Time Data Flows with Apache NiFiManish Gupta
 
Apache Spark Core—Deep Dive—Proper Optimization
Apache Spark Core—Deep Dive—Proper OptimizationApache Spark Core—Deep Dive—Proper Optimization
Apache Spark Core—Deep Dive—Proper OptimizationDatabricks
 

La actualidad más candente (20)

Parallelizing with Apache Spark in Unexpected Ways
Parallelizing with Apache Spark in Unexpected WaysParallelizing with Apache Spark in Unexpected Ways
Parallelizing with Apache Spark in Unexpected Ways
 
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
 
How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 
Introduction to Apache Calcite
Introduction to Apache CalciteIntroduction to Apache Calcite
Introduction to Apache Calcite
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
The Data Lake Engine Data Microservices in Spark using Apache Arrow FlightThe Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
 
Fluent Bit: Log Forwarding at Scale
Fluent Bit: Log Forwarding at ScaleFluent Bit: Log Forwarding at Scale
Fluent Bit: Log Forwarding at Scale
 
Performance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark MetricsPerformance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark Metrics
 
Parquet performance tuning: the missing guide
Parquet performance tuning: the missing guideParquet performance tuning: the missing guide
Parquet performance tuning: the missing guide
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simple
 
Apache Spark on K8S Best Practice and Performance in the Cloud
Apache Spark on K8S Best Practice and Performance in the CloudApache Spark on K8S Best Practice and Performance in the Cloud
Apache Spark on K8S Best Practice and Performance in the Cloud
 
in-memory database system and low latency
in-memory database system and low latencyin-memory database system and low latency
in-memory database system and low latency
 
Spark SQL Tutorial | Spark SQL Using Scala | Apache Spark Tutorial For Beginn...
Spark SQL Tutorial | Spark SQL Using Scala | Apache Spark Tutorial For Beginn...Spark SQL Tutorial | Spark SQL Using Scala | Apache Spark Tutorial For Beginn...
Spark SQL Tutorial | Spark SQL Using Scala | Apache Spark Tutorial For Beginn...
 
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
 
Continuous Application with FAIR Scheduler with Robert Xue
Continuous Application with FAIR Scheduler with Robert XueContinuous Application with FAIR Scheduler with Robert Xue
Continuous Application with FAIR Scheduler with Robert Xue
 
Koalas: Making an Easy Transition from Pandas to Apache Spark
Koalas: Making an Easy Transition from Pandas to Apache SparkKoalas: Making an Easy Transition from Pandas to Apache Spark
Koalas: Making an Easy Transition from Pandas to Apache Spark
 
Building Reliable Lakehouses with Apache Flink and Delta Lake
Building Reliable Lakehouses with Apache Flink and Delta LakeBuilding Reliable Lakehouses with Apache Flink and Delta Lake
Building Reliable Lakehouses with Apache Flink and Delta Lake
 
Real-Time Data Flows with Apache NiFi
Real-Time Data Flows with Apache NiFiReal-Time Data Flows with Apache NiFi
Real-Time Data Flows with Apache NiFi
 
Apache Spark Core—Deep Dive—Proper Optimization
Apache Spark Core—Deep Dive—Proper OptimizationApache Spark Core—Deep Dive—Proper Optimization
Apache Spark Core—Deep Dive—Proper Optimization
 

Destacado

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
 

Destacado (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
 

Similar 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
 

Similar 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
 

Más 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
 

Más 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

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
 
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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
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
 
"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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
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
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Último (20)

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!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
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
 
"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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
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
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

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