Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/2543728.2543739acmconferencesArticle/Chapter ViewAbstractPublication PagespepmConference Proceedingsconference-collections
research-article

Compile-time reflection and metaprogramming for Java

Published: 11 January 2014 Publication History

Abstract

Java reflection enables us to write reusable programs that are independent of certain classes. However, when runtime performance is a big concern, we propose to use compile-time reflection for writing metaprograms that generate non-reflective class/type specific code, which has lower runtime cost.
We proposed both compile-time reflection and metaprogramming for Java, and extended our previous work on pattern-based traits. Pattern-based traits integrate pattern-based reflection with flexible composition of traits. They are capable of pattern-matching over class members and generating expressive code. We add and formalize pattern-based reflection at the statement-level, which enables a meta program to generate statements. We add reified generics for pattern-based traits, which enables a pattern to iterate over any class when traits are instantiated. We implemented an ORM tool (called PtjORM) using pattern-based traits. PtjORM uses compile-time reflection and our benchmark tests show that it has competitive runtime performance compared to the mainstream Java ORM tools.

References

[1]
David Abrahams and Aleksey Gurtovoy. C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ in Depth Series). Addison-Wesley Professional, 2004.
[2]
Michael J. Carey, David J. DeWitt, and Jeffrey F. Naughton. The 007 benchmark. In Proceedings of the 1993 ACM SIGMOD international conference on Management of data, SIGMOD '93, pages 12--21, New York, NY, USA, 1993. ACM.
[3]
Dirk Draheim, Christof Lutteroth, and Gerald Weber. A type system for reflective program generators. In Proc. of the Conf. on Generative Programming and Component Engineering. Springer, 2005.
[4]
Derek Dreyer and Andreas Rossberg. Mixin' up the ml module system. In Proc. of the 13th ACM SIGPLAN International Conference on Functional Programming. ACM, 2008.
[5]
Stéphane Ducasse, Oscar Nierstrasz, Nathanael Schärli, Roel Wuyts, and Andrew P. Black. Traits: A mechanism for fine-grained reuse. ACM Trans. Program. Lang. Syst., 2006.
[6]
Manuel Fähndrich, Michael Carbin, and James R. Larus. Reflective program generation with patterns. In Proc. of the Conf. on Generative Programming and Component Engineering. ACM, 2006.
[7]
Kathleen Fisher. A typed calculus of traits. In Workshop on Foundations of Object-oriented Programming, 2004.
[8]
Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. Classes and mixins. In Proc. of the Symposium on Principles of Programming Languages. ACM, 1998.
[9]
Ira R. Forman and Nate Forman. Java Reflection in Action (In Action series). Manning Publications Co., Greenwich, CT, USA, 2004.
[10]
Ronald Garcia and Andrew Lumsdaine. Toward foundations for type-reflective metaprogramming. In Proc. of the Conf. on Generative Programming and Component Engineering. ACM, 2009.
[11]
Shan Shan Huang and Yannis Smaragdakis. Expressive and safe static reflection with morphj. In Proc. of the Conf. on Programming Language Design and Implementation. ACM, 2008.
[12]
Shan Shan Huang, David Zook, and Yannis Smaragdakis. Morphing: Safely shaping a class in the image of others. In Proc. of the European Conf. on Object-Oriented Programming. Springer-Verlag, 2007.
[13]
Shan Shan Huang, David Zook, and Yannis Smaragdakis. Statically safe program generation with safegen. Sci. Comput. Program., 2011.
[14]
Ali Ibrahim and William R. Cook. Automatic prefetching by traversal profiling in object persistence architectures. In Proceedings of the 20th European conference on Object-Oriented Programming, ECOOP'06, pages 50--73, Berlin, Heidelberg, 2006. Springer-Verlag.
[15]
Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. Featherweight Java: a minimal core calculus for Java and GJ. ACM Trans. Program. Lang. Syst., 2001.
[16]
Gregor Kiczales, Erik Hilsdale, Jim Hugunin, Mik Kersten, Jeffrey Palm, and William G. Griswold. An overview of aspectj. In Proc. of the European Conf. on Object-Oriented Programming. Springer-Verlag, 2001.
[17]
Gregor Kiczales, John Lamping, Anurag Mendhekar, Chris Maeda, Cristina Lopes, Jean marc Loingtier, and John Irwin. Aspect-oriented programming. In Proc. of the European Conf. on Object-Oriented Programming. Springer-Verlag, 1997.
[18]
Giovanni Lagorio, Marco Servetto, and Elena Zucca. Featherweight jigsaw: A minimal core calculus for modular composition of classes. In Proc. of the European Conf. on Object-Oriented Programming. Springer-Verlag, 2009.
[19]
Luigi Liquori and Arnaud Spiwack. Feathertrait: A modest extension of featherweight java. ACM Trans. Program. Lang. Syst., 2008.
[20]
Weiyu Miao and Jeremy Siek. Pattern-based traits. In Proceedings of the 27th Annual ACM Symposium on Applied Computing, SAC '12, pages 1729--1736. ACM, 2012.
[21]
Oscar Nierstrasz, Stéphane Ducasse, and Nathanael Schärli. Flattening traits. Journal of Object Technology, 2006.
[22]
John Reppy and Aaron Turon. Metaprogramming with traits. In Proc. of the European Conf. on Object-Oriented Programming. Springer, 2007.
[23]
Nathanael Schärli, Stephane Ducasse, Oscar Nierstrasz, and Andrew P. Black. Traits: Composable units of behaviour. In Proc. European Conf. on Object-Oriented Programming. Springer, 2003.
[24]
Tim Sheard and Simon Peyton Jones. Template metaprogramming for Haskell. In Haskell Workshop '02. ACM, 2002.
[25]
Charles Smith and Sophia Drossopoulou. Chai: Traits for Java-Like Languages. In Proc. of the European Conf. on Object-Oriented Programming. Springer, 2005.
[26]
Walid Taha and Tim Sheard. Multi-stage programming with explicit annotations. In Proc. of the 1997 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation. ACM, 1997.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PEPM '14: Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation
January 2014
202 pages
ISBN:9781450326193
DOI:10.1145/2543728
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 11 January 2014

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. compile-time reflection
  2. metaprogramming
  3. object-oriented programming
  4. traits

Qualifiers

  • Research-article

Conference

POPL '14
Sponsor:

Acceptance Rates

PEPM '14 Paper Acceptance Rate 17 of 22 submissions, 77%;
Overall Acceptance Rate 66 of 120 submissions, 55%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)4
  • Downloads (Last 6 weeks)1
Reflects downloads up to 24 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2019)A Survey of Metaprogramming LanguagesACM Computing Surveys10.1145/335458452:6(1-39)Online publication date: 16-Oct-2019
  • (2018)Efficient Reusable CollectionsIEICE Transactions on Information and Systems10.1587/transinf.2018EDP7105E101.D:11(2710-2719)Online publication date: 1-Nov-2018
  • (2017)Structured Program Generation TechniquesGrand Timely Topics in Software Engineering10.1007/978-3-319-60074-1_7(154-178)Online publication date: 29-Jun-2017
  • (2015)FᴏᴏProceedings of the 17th Workshop on Formal Techniques for Java-like Programs10.1145/2786536.2786540(1-4)Online publication date: 7-Jul-2015
  • (2014)MorphScalaProceedings of the Fifth Annual Scala Workshop10.1145/2637647.2637650(18-22)Online publication date: 28-Jul-2014

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media