Expressive and Safe Static Reflection with MorphJ

被引:10
|
作者
Huang, Shan Shan [1 ]
Smaragdakis, Yannis [2 ]
机构
[1] Georgia Inst Technol, Coll Comp, Atlanta, GA 30332 USA
[2] Univ Oregon, Dept Comp & Informat Sci, Eugene, OR 97403 USA
关键词
object-oriented programming; structural abstraction; class morphing; aspect-oriented programming; meta-programming; language extensions;
D O I
10.1145/1375581.1375592
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Recently, language extensions have been proposed for Java and C# to support pattern-based reflective declaration. These extensions introduce a disciplined form of meta-programming and aspect-oriented programming to mainstream languages: They allow members of a class (i.e., fields and methods) to be declared by statically iterating over and pattern-matching on members of other classes. Such techniques, however, have been unable to safely express simple, but common, idioms such as declaring getter and setter methods for fields. In this paper, we present a mechanism that addresses the lack of expressiveness in past work without sacrificing safety. Our technique is based on the idea of nested patterns that elaborate the outer-most pattern with blocking or enabling conditions. We implemented this mechanism in a language, MorphJ. We demonstrate the expressiveness of MorphJ with real-world applications. In particular, the MorphJ reimplementation of DSTM2, a software transactional memory library, reduces 1, 107 lines of Java reflection and bytecode engineering library calls to just 374 lines of MorphJ code. At the same time, the MorphJ solution is both high level and safer, as MorphJ can separately type check generic classes and catch errors early. We present and formalize the MorphJ type system, and offer a type-checking algorithm.
引用
收藏
页码:79 / +
页数:2
相关论文
共 50 条
  • [1] Expressive and safe static reflection with MorphJ
    Huang, Shan Shan
    Smaragdakis, Yannis
    [J]. ACM SIGPLAN NOTICES, 2008, 43 (06) : 79 - 89
  • [2] Expressive Exceptions for Safe Pervasive Spaces
    Cho, Eun-Sun
    Helal, Sumi
    [J]. JOURNAL OF INFORMATION PROCESSING SYSTEMS, 2012, 8 (02): : 279 - 300
  • [3] Marco: Safe, Expressive Macros for Any Language
    Lee, Byeongcheol
    Grimm, Robert
    Hirzel, Martin
    McKinley, Kathryn S.
    [J]. ECOOP 2012 - OBJECT-ORIENTED PROGRAMMING, 2012, 7313 : 589 - 613
  • [4] Expressive declassification policies and modular static enforcement
    Banerjee, Anindya
    Naumann, David A.
    Rosenberg, Stan
    [J]. PROCEEDINGS OF THE 2008 IEEE SYMPOSIUM ON SECURITY AND PRIVACY, 2008, : 339 - +
  • [6] Expressive and Strongly Type-Safe Code Generation
    Winant, Thomas
    Cockx, Jesper
    Devriese, Dominique
    [J]. PROCEEDINGS OF THE 19TH INTERNATIONAL SYMPOSIUM ON PRINCIPLES AND PRACTICE OF DECLARATIVE PROGRAMMING (PPDP 2017), 2017, : 199 - 210
  • [7] Safe Reflection Through Polymorphism
    Verwaest, Toon
    Renggli, Lukas
    [J]. CASTA 2009: WORKSHOP ON CONTEXT-AWARE SOFTWARE TECHNOLOGY AND APPLICATIONS, 2009, : 21 - 24
  • [8] Listeners' Perceptions of Choral Performances With Static and Expressive Movement
    Napoles, Jessica
    Geringer, John M.
    Adams, Kari
    Springer, D. Gregory
    [J]. JOURNAL OF RESEARCH IN MUSIC EDUCATION, 2022, 69 (04) : 457 - 472
  • [9] Fractional Types Expressive and Safe Space Management for Ancilla Bits
    Chen, Chao-Hong
    Choudhury, Vikraman
    Carette, Jacques
    Sabry, Amr
    [J]. REVERSIBLE COMPUTATION (RC 2020), 2020, 12227 : 169 - 186
  • [10] Cedar: A New Language for Expressive, Fast, Safe, and Analyzable Authorization
    Cutler, Joseph W.
    Disselkoen, Craig
    Eline, Aaron
    He, Shaobo
    Headley, Kyle
    Hicks, Michael
    Hietala, Kesha
    Ioannidis, Eleftherios
    Kastner, John
    Mamat, Anwar
    Mcadams, Darin
    McCutchen, Matt
    Rungta, Neha
    Torlak, Emina
    Wells, Andrew M.
    [J]. PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2024, 8 (OOPSLA):