Defining Name Accessibility Using Scope Graphs

Authors Aron Zwaan , Casper Bach Poulsen



PDF
Thumbnail PDF

File

LIPIcs.ECOOP.2024.47.pdf
  • Filesize: 1.09 MB
  • 29 pages

Document Identifiers

Author Details

Aron Zwaan
  • Delft University of Technology, The Netherlands
Casper Bach Poulsen
  • Delft University of Technology, The Netherlands

Acknowledgements

We thank Friedrich Steimann for challenging us to specify and formalize access modifiers using scope graphs, and the anonymous reviewers for their helpful comments.

Cite AsGet BibTex

Aron Zwaan and Casper Bach Poulsen. Defining Name Accessibility Using Scope Graphs. In 38th European Conference on Object-Oriented Programming (ECOOP 2024). Leibniz International Proceedings in Informatics (LIPIcs), Volume 313, pp. 47:1-47:29, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2024)
https://doi.org/10.4230/LIPIcs.ECOOP.2024.47

Abstract

Many programming languages allow programmers to regulate accessibility; i.e., annotating a declaration with keywords such as export and private to indicate where it can be accessed. Despite the importance of name accessibility for, e.g., compilers, editor auto-completion and tooling, and automated refactorings, few existing type systems provide a formal account of name accessibility. We present a declarative, executable, and language-parametric model for name accessibility, which provides a formal specification of name accessibility in Java, C#, C++, Rust, and Eiffel. We achieve this by defining name accessibility as a predicate on resolution paths through scope graphs. Since scope graphs are a language-independent model of name resolution, our model provides a uniform approach to defining different accessibility policies for different languages. Our model is implemented in Statix, a logic language for executable type system specification using scope graphs. We evaluate its correctness on a test suite that compares it with the C#, Java, and Rust compilers, and show we can synthesize access modifiers in programs with holes accurately.

Subject Classification

ACM Subject Classification
  • Software and its engineering → Compilers
  • Software and its engineering → Language features
  • Theory of computation → Program constructs
Keywords
  • access modifier
  • visibility
  • scope graph
  • name resolution

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Sven Apel, Sergiy S. Kolesnikov, Jörg Liebig, Christian Kästner, Martin Kuhlemann, and Thomas Leich. Access control in feature-oriented programming. Science of Computer Programming, 77(3):174-187, 2012. URL: https://doi.org/10.1016/j.scico.2010.07.005.
  2. Sven Apel, Jörg Liebig, Christian Kästner, Martin Kuhlemann, and Thomas Leich. An orthogonal access modifier model for feature-oriented programming. In Sven Apel, William R. Cook, Krzysztof Czarnecki, Christian Kästner, Neil Loughran, and Oscar Nierstrasz, editors, Proceedings of the First International Workshop on Feature-Oriented Software Development, FOSD 2009, Denver, Colorado, USA, October 6, 2009, ACM International Conference Proceeding Series, pages 27-33. ACM, 2009. URL: https://doi.org/10.1145/1629716.1629723.
  3. Casper Bach Poulsen, Xulei Liu, and Luka Miljak. Towards a Language-parametric DSL for Refactoring (Short Paper), 2024. URL: https://popl24.sigplan.org/details?action-call-with-get-request-type=1&c9432bfaa61a48fb852237f9e99a821daction_1742650661080820307cb713fc2d28c30ae360b0bed=1&__ajax_runtime_request__=1&context=POPL-2024&track=pepm-2024&urlKey=8&decoTitle=Towards-a-Language-parametric-DSL-for-Refactoring-Short-Paper-.
  4. Andrew P. Black. Object-oriented programming: Some history, and challenges for the next fifty years. Inf. Comput., 231:3-20, 2013. URL: https://doi.org/10.1016/j.ic.2013.08.002.
  5. Philipp Bouillon, Eric Großkinsky, and Friedrich Steimann. Controlling Accessibility in Agile Projects with the Access Modifier Modifier. In Richard F. Paige and Bertrand Meyer, editors, Objects, Components, Models and Patterns, 46th International Conference, TOOLS EUROPE 2008, volume 11 of Lecture Notes in Business Information Processing, pages 41-59. Springer, 2008. URL: https://doi.org/10.1007/978-3-540-69824-1_4.
  6. Toktam Ramezani Farkhani, Mohammadreza Razzazi, and Peyman Teymoori. Eam: Expansive access modifiers in oop. In 2008 International Conference on Computer and Communication Engineering, pages 589-594, 2008. URL: https://doi.org/10.1109/ICCCE.2008.4580672.
  7. The Rust Foundation. The Rust Reference. Accessed 25-09-2023. URL: https://doc.rust-lang.org/reference/.
  8. The Standard C++ Foundation. Working Draft, Standard for Programming Language C++. Online version from https://github.com/cplusplus/draft/releases/tag/n4868 was consulted. Per release notes, `only editorial changes compared to C++20' were made.
  9. Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns: Abstraction and Reuse of Object-Oriented Design. In Oscar M. Nierstrasz, editor, ECOOP' 93 - Object-Oriented Programming, pages 406-431, Berlin, Heidelberg, 1993. Springer Berlin Heidelberg. URL: https://doi.org/10.1007/3-540-47910-4_21.
  10. Adrian Giurca and Dorel Savulea. Logic programs with access modifiers. In 4th International Conference on Artificial Intelligence and Digital Communication, AIDC, pages 22-31, 2004. Google Scholar
  11. James Gosling, Bill Joy, Guy Steele, Gilad Bracha, and Alex Buckley. The Java Language Specification - Java SE 8 Edition, February 2015. URL: https://docs.oracle.com/javase/specs/jls/se8/html/.
  12. Lennart C. L. Kats, Rob Vermaas, and Eelco Visser. Integrated language definition testing: enabling test-driven language development. In Cristina Videira Lopes and Kathleen Fisher, editors, Proceedings of the 26th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2011, part of SPLASH 2011, Portland, OR, USA, October 22 - 27, 2011, pages 139-154. ACM, 2011. URL: https://doi.org/10.1145/2048066.2048080.
  13. Lennart C. L. Kats and Eelco Visser. The Spoofax language workbench: rules for declarative specification of languages and IDEs. In William R. Cook, Siobhán Clarke, and Martin C. Rinard, editors, Proceedings of the 25th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2010, pages 444-463, Reno/Tahoe, Nevada, 2010. ACM. URL: https://doi.org/10.1145/1869459.1869497.
  14. Eva Magnusson, Torbjorn Ekman, and Gorel Hedin. Extending Attribute Grammars with Collection Attributes-Evaluation and Applications. Source Code Analysis and Manipulation, IEEE International Workshop on, 0, 2007. URL: https://doi.org/10.1109/SCAM.2007.13.
  15. Luka Miljak, Casper Bach Poulsen, and Flip van Spaendonck. Verifying Well-Typedness Preservation of Refactorings using Scope Graphs. In Aaron Tomb, editor, Proceedings of the 25th ACM International Workshop on Formal Techniques for Java-like Programs, FTfJP 2023, Seattle, WA, USA, 18 July 2023, pages 44-50. ACM, 2023. URL: https://doi.org/10.1145/3605156.3606455.
  16. Phil Misteli. Renaming for Everyone: Language-parametric Renaming in Spoofax. Master’s thesis, Delft University of Technology, May 2021. URL: http://resolver.tudelft.nl/uuid:60f5710d-445d-4583-957c-79d6afa45be5.
  17. Andreas Müller. Bytecode analysis for checking java access modifiers. In Work in Progress and Poster Session, 8th Int. Conf. on Principles and Practice of Programming in Java (PPPJ 2010), Vienna, Austria, pages 1-4, 2010. Google Scholar
  18. Pierre Néron, Andrew P. Tolmach, Eelco Visser, and Guido Wachsmuth. A Theory of Name Resolution. In Jan Vitek, editor, Programming Languages and Systems - 24th European Symposium on Programming, ESOP 2015, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2015, London, UK, April 11-18, 2015. Proceedings, volume 9032 of Lecture Notes in Computer Science, pages 205-231. Springer, 2015. URL: https://doi.org/10.1007/978-3-662-46669-8_9.
  19. Daniël A. A. Pelsmaeker, Hendrik van Antwerpen, Casper Bach Poulsen, and Eelco Visser. Language-parametric static semantic code completion. Proceedings of the ACM on Programming Languages, 6(OOPSLA):1-30, 2022. URL: https://doi.org/10.1145/3527329.
  20. Casper Bach Poulsen, Aron Zwaan, and Paul Hübner. A Monadic Framework for Name Resolution in Multi-phased Type Checkers. In Coen De Roover, Bernhard Rumpe, and Amir Shaikhha, editors, Proceedings of the 22nd ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences, GPCE 2023, Cascais, Portugal, October 22-23, 2023, pages 14-28. ACM, 2023. URL: https://doi.org/10.1145/3624007.3624051.
  21. Mark Reinhold. Java platform module system, August 2017. URL: https://jcp.org/en/jsr/detail?id=376.
  22. Arjen Rouvoet, Hendrik van Antwerpen, Casper Bach Poulsen, Robbert Krebbers, and Eelco Visser. Knowing when to ask: sound scheduling of name resolution in type checkers derived from declarative specifications. Proceedings of the ACM on Programming Languages, 4(OOPSLA), 2020. URL: https://doi.org/10.1145/3428248.
  23. Max Schäfer, Andreas Thies, Friedrich Steimann, and Frank Tip. A Comprehensive Approach to Naming and Accessibility in Refactoring Java Programs. IEEE Trans. Software Eng., 38(6):1233-1257, 2012. URL: https://doi.org/10.1109/TSE.2012.13.
  24. Friedrich Steimann, Christian Kollee, and Jens von Pilgrim. A Refactoring Constraint Language and Its Application to Eiffel. In Mira Mezini, editor, ECOOP 2011 - Object-Oriented Programming - 25th European Conference, Lancaster, UK, July 25-29, 2011 Proceedings, volume 6813 of Lecture Notes in Computer Science, pages 255-280. Springer, 2011. URL: https://doi.org/10.1007/978-3-642-22655-7_13.
  25. Friedrich Steimann and Andreas Thies. From Public to Private to Absent: Refactoring Java Programs under Constrained Accessibility. In Sophia Drossopoulou, editor, ECOOP 2009 - Object-Oriented Programming, 23rd European Conference, Genoa, Italy, July 6-10, 2009. Proceedings, volume 5653 of Lecture Notes in Computer Science, pages 419-443. Springer, 2009. URL: https://doi.org/10.1007/978-3-642-03013-0_19.
  26. Hendrik van Antwerpen, Pierre Néron, Andrew P. Tolmach, Eelco Visser, and Guido Wachsmuth. A constraint language for static semantic analysis based on scope graphs. In Martin Erwig and Tiark Rompf, editors, Proceedings of the 2016 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, PEPM 2016, St. Petersburg, FL, USA, January 20 - 22, 2016, pages 49-60. ACM, 2016. URL: https://doi.org/10.1145/2847538.2847543.
  27. Hendrik van Antwerpen, Casper Bach Poulsen, Arjen Rouvoet, and Eelco Visser. Scopes as types. Proceedings of the ACM on Programming Languages, 2(OOPSLA), 2018. URL: https://doi.org/10.1145/3276484.
  28. Hendrik van Antwerpen and Eelco Visser. Scope States: Guarding Safety of Name Resolution in Parallel Type Checkers. In Anders Møller and Manu Sridharan, editors, 35th European Conference on Object-Oriented Programming, ECOOP 2021, July 11-17, 2021, Aarhus, Denmark (Virtual Conference), volume 194 of LIPIcs. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2021. URL: https://doi.org/10.4230/LIPIcs.ECOOP.2021.1.
  29. Loek Van der Gugten. Function Inlining as a Language Parametric Refactoring. Master’s thesis, Delft University of Technology, June 2022. URL: http://resolver.tudelft.nl/uuid:15057a42-f049-4321-b9ee-f62e7f1fda9f.
  30. Eric Van Wyk, Oege de Moor, Kevin Backhouse, and Paul Kwiatkowski. Forwarding in Attribute Grammars for Modular Language Design. In R. Nigel Horspool, editor, Compiler Construction, 11th International Conference, CC 2002, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2002, Grenoble, France, April 8-12, 2002, Proceedings, volume 2304 of Lecture Notes in Computer Science, pages 128-142. Springer, 2002. URL: https://doi.org/10.1007/3-540-45937-5_11.
  31. Guido Wachsmuth, Gabriël Konat, and Eelco Visser. Language Design with the Spoofax Language Workbench. IEEE Software, 31(5):35-43, 2014. URL: https://doi.org/10.1109/MS.2014.100.
  32. Bill Wagner, Manuel Zelenka, and Youssef Victor. C#Reference - Keywords - file, November 2022. URL: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/file.
  33. Wuu Yang. Discovering anomalies in access modifiers in java with a formal specification, 1998. URL: http://dspace.fcu.edu.tw/bitstream/2377/2120/1/ce07ics001998000164.pdf.
  34. Christian Zoller and Axel Schmolitzky. Measuring Inappropriate Generosity with Access Modifiers in Java Systems. In 2012 Joint Conference of the 22nd International Workshop on Software Measurement and the 2012 Seventh International Conference on Software Process and Product Measurement, Assisi, Italy, October 17-19, 2012, pages 43-52. IEEE Computer Society, 2012. URL: https://doi.org/10.1109/IWSM-MENSURA.2012.15.
  35. Aron Zwaan and Casper Bach Poulsen. Defining Name Accessibility using Scope Graphs (Artifact), May 2024. URL: https://doi.org/10.5281/zenodo.11179594.
  36. Aron Zwaan and Casper Bach Poulsen. Defining Name Accessibility using Scope Graphs (Extended Edition). CoRR, May 2024. URL: https://doi.org/10.48550/arXiv.2407.09320.
  37. Aron Zwaan and Casper Bach Poulsen. Defining Name Accessibility using Scope Graphs (Artifact). Software (visited on 2024-08-05). URL: https://zenodo.org/records/11179594.
  38. Aron Zwaan and Hendrik van Antwerpen. Scope Graphs: The Story so Far. In Ralf Lämmel, Peter D. Mosses, and Friedrich Steimann, editors, Eelco Visser Commemorative Symposium, EVCS 2023, April 5, 2023, Delft, The Netherlands, volume 109 of OASIcs. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2023. URL: https://doi.org/10.4230/OASIcs.EVCS.2023.32.
  39. Aron Zwaan, Hendrik van Antwerpen, and Eelco Visser. Incremental type-checking for free: using scope graphs to derive incremental type-checkers. Proceedings of the ACM on Programming Languages, 6(OOPSLA2):424-448, 2022. URL: https://doi.org/10.1145/3563303.
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail