Your browser does not allow JavaScript!
JavaScript is necessary for the proper functioning of this website. Please enable JavaScript or use a modern browser.
Open Science Slovenia
Open Science
DiKUL
slv
|
eng
Search
Browse
New in RUL
About RUL
In numbers
Help
Sign in
Večkratno razpošiljanje v Javi z obdelavo anotacij
ID
Kišek, Nejc
(
Author
),
ID
Mihelič, Jurij
(
Mentor
)
More about this mentor...
PDF - Presentation file,
Download
(1,51 MB)
MD5: FF48695D88B80AD1DF50FA1218033918
Image galllery
Abstract
Razpošiljanje je mehanizem, s katerim se v objektno usmerjenih programskih jezikih razlikuje med metodami, ki imajo enako ime in število parametrov. Deluje tako, da ob klicu metode na podlagi dinamičnih tipov podanih parametrov izbere najustreznejšo metodo. Enojno razpošiljanje med izvajanjem za to uporabi le tip enega parametra (prejemnika), medtem ko se tipi ostalih ugotovijo med prevajanjem. Pri večkratnem razpošiljanju se tipe vseh parametrov ugotovi šele med izvajanjem, kar je počasnejše, a bolj fleksibilno. V Javi in mnogih drugih objektno usmerjenih programskih jezikih je podprto le enojno razpošiljanje, večkratnega pa lahko na različne načine simuliramo. Cilj naloge je bil izdelati knjižnico, s pomočjo katere se na podlagi anotacij, ki jih dodamo v običajen javanski program, generira koda za simuliranje večkratnega razpošiljanja. Logika za razpošiljanje se generira šele med prevajanjem, zato je lahko poljubno zapletena, ne da bi vplivala na zapletenost izvorne kode. Pri uporabi te knjižnice so edina sprememba med pisanjem programa dodatne anotacije, kar je enostavnejše za uporabo kot podobne obstoječe rešitve, ki potrebujejo posebne prevajalnike ali pa zahtevajo klicanje metod na povsem drugačen način. Knjižnica je izvedena v treh različicah, ki uporabljajo različne načine za simuliranje večkratnega razpošiljanja: s pomočjo odločitvenega drevesa z neposrednim preverjanjem tipov, z uporabo odsevnosti in z razširjenim načrtovalskim vzorcem obiskovalec. Od teh sta prva dva podobna načinom, ki so uporabljeni v obstoječih rešitvah, tretji pa je manj znan in o njem do sedaj ni mogoče najti podrobne literature. V sklopu naloge so predstavljene implementacije, pa tudi rezultati eksperimentalne primerjave teh treh načinov, kjer primerjamo hitrost izvajanja, hitrost prevajanja in velikost prevedene kode.
Language:
Slovenian
Keywords:
razpošiljanje
,
večkratno razpošiljanje
,
anotacije
,
obdelava anotacij
,
generiranje kode
,
Java
,
javac
Work type:
Master's thesis/paper
Organization:
FRI - Faculty of Computer and Information Science
Year:
2018
PID:
20.500.12556/RUL-105199
Publication date in RUL:
08.11.2018
Views:
1143
Downloads:
252
Metadata:
Cite this work
Plain text
BibTeX
EndNote XML
EndNote/Refer
RIS
ABNT
ACM Ref
AMA
APA
Chicago 17th Author-Date
Harvard
IEEE
ISO 690
MLA
Vancouver
:
Copy citation
Share:
Secondary language
Language:
English
Title:
Multiple dispatch in Java using annotation processing
Abstract:
Dispatch is a mechanism in object-oriented programming languages used for distinguishing between methods with the same name and number of parameters. It works by examining the runtime types of parameters passed to a method call and selecting the most suitable method for them. Single dispatch selects a method based on the runtime type of just one of the parameters (the receiver), while the types of the rest of them are determined during compilation. Multiple dispatch determines the types of all the parameters during program execution, which is slower but more flexible. Java along with many other object-oriented languages supports single dispatch but not multiple dispatch. In such languages multiple dispatch can be simulated in different ways. The goal of this thesis was to create a library that uses annotations added to an ordinary Java program in order to generate code for simulating multiple dispatch. Because the dispatch logic is generated during compilation, it can be very complex without complicating the source code. The only change when writing a program that uses our library are additional annotations, which is much simpler than existing similar solutions that use special compilers or change the way methods can be used. There are three different versions of the library with three different mechanisms for simulating multiple dispatch: a decision tree with direct type inspection, a mechanism that uses reflection and an extended version of the visitor design pattern. The first two are similar to mechanisms used in other solutions while the third one is less known and is not found in the existing literature. In this thesis we show implementations of the three versions of our library and present the results of the experiments, where we compare them based on execution time, compilation time and size of the generated code.
Keywords:
dispatch
,
multiple dispatch
,
annotations
,
annotation processing
,
generating code
,
Java
,
javac
Similar documents
Similar works from RUL:
Similar works from other Slovenian collections:
Back