Metametaprogramming for Java with Spoon

Detta är en Master-uppsats från KTH/Skolan för elektroteknik och datavetenskap (EECS)

Författare: Andrew Bwogi; [2021]

Nyckelord: ;

Sammanfattning: Metaprogramming is used to abstract away complicated code by o˙ering a more intuitive interface that automatically generates it. Spoon and ASM are two metaprogram libraries for Java that operate on programs at source code and bytecode level respectively. The thesis investigates what subset of Spoon metaprograms can be transformed to functionally equivalent ASM metapro-grams, how Spoon works as an interface to ASM, and how the generated ASM metaprograms work. The metaprogram transformer combines code templates with the output from the code generation tool ASMifier. The method that verifies equivalence runs semantically equivalent test programs through Spoon metaprograms and generated ASM metaprograms, and compares the outputs with the code clone detection program SootDi˙. Results show that there exists a subset of transformable Spoon metaprograms that insert an invocation together with its corresponding definition at the beginning of a chosen method or replace all return expressions of the method with the invocation if the return types match. Spoon itself can be abstracted away to leave a basic Java class as an interface for generating bytecode level metaprograms. The generated ASM metaprograms use the visitor design pattern and Java Reflection API to modify the input programs.

  HÄR KAN DU HÄMTA UPPSATSEN I FULLTEXT. (följ länken till nästa sida)