首页> 外文会议>Systems and Information Engineering Design Symposium >A framework for building type-safe configurations for JVM using code generation techniques
【24h】

A framework for building type-safe configurations for JVM using code generation techniques

机译:使用代码生成技术构建JVM的类型安全配置的框架

获取原文

摘要

One of the common errors in software development is a configuration mistake. This type of error can have a wide range of severity levels. Consequences of a wrong configuration can be small and insignificant such as a website showing an incorrect font type, or large and consequential such as deleting customer data, incorrect price calculation, or charging a fee twice. In addition, an incorrect configuration may introduce subtle and lurking vulnerabilities into a system. Statically typed programming languages generally can mitigate these kinds of problems to some extent. At compile time, a compiler can detect incorrect types as well as other common mistakes such as some typographical errors, invalid type coercions, and invalid object references. It goes without saying that developers need to correct all compile-time errors before a project can be built. However, hardcoded configurations are not desirable since the input data cannot be changed without rebuilding a project. Due to this inflexibility, external configuration files are needed, but they bring back some thorny issues since the compiler cannot validate the types in those files. Adding validation logic does not substantially mitigate this problem because it is activated at runtime, and errors may not be discovered until a project is deployed to production servers. An external configuration file somewhat lessens the benefit of static type-checking that a compiler provides. Furthermore, string keys are needed for linking the variables in the source code to the values in configuration files. If a key is required to be renamed, it should be renamed in both configuration file and source code. Otherwise, the link will be broken. We propose a new framework that can generate source code from configuration files during development. Many configuration file formats support basic data types and nested object structure which can be mapped to Java types and the Java static nested class. The configuration library that we used is config by typesafehub. The library supports the Human-Optimized Config Object Notation (HOCON) file format which is a superset of the JavaScript Object Notation (JSON). The library's objects are encapsulated in the generated configuration object, which cannot be directly accessed by developers. We discovered that this method can prevent some types of human errors, and it also takes advantage of the validation provided by a compiler. The configuration key is no longer a string, rather a chain of methods or attributes, which is more flexible and type-safe. The configuration objects and their values are immutable. The complexity of how mutable values are converted to immutable ones is hidden from the developers. There are a number of other subtle details that are addressed in the paper, as well as some limitations and enhancements.
机译:软件开发中的一个常见错误是配置错误。这种错误可以具有广泛的严重性级别。错误配置的后果可能是小而微不足道的诸如网站,显示错误的字体类型,或者删除客户数据,价格计算不正确或两次收费的大规模和后果。此外,配置不正确的配置可能会将微妙和潜伏的漏洞引入系统中。静态类型的编程语言通常可以在一定程度上减轻这些问题。在编译时,编译器可以检测到不正确的类型以及其他常见错误,例如某些印刷错误,无效类型胁迫和无效的对象引用。不言而喻,开发人员需要在构建项目之前纠正所有编译时错误。但是,由于在不重建项目的情况下无法更改输入数据,因此不希望硬编码配置。由于这种不灵活性,需要外部配置文件,但它们会带回一些棘手的问题,因为编译器无法验证这些文件中的类型。添加验证逻辑不会显着减轻此问题,因为它在运行时激活,并且在将项目部署到生产服务器之前,可能无法发现错误。外部配置文件有点减少了编译器提供的静态类型检查的好处。此外,需要将源代码中的变量链接到配置文件中的值的字符串键。如果需要重命名一个密钥,则应在配置文件和源代码中重命名。否则,链接将被打破。我们提出了一个新的框架,可以在开发期间从配置文件生成源代码。许多配置文件格式支持基本数据类型和嵌套对象结构,可以映射到Java类型和Java静态嵌套类。我们使用的配置库是按TyouneAfehub配置的。该库支持人为优化的配置对象符号(河组)文件格式,它是JavaScript对象符号(JSON)的超集。库的对象封装在生成的配置对象中,这些对象无法直接由开发人员访问。我们发现此方法可以防止某些类型的人类错误,并且还利用编译器提供的验证。配置密钥不再是一个字符串,而不是一系列方法或属性,这更灵活,键入安全。配置对象及其值是不可变的。将变形值转换为不可变形的复杂性是从开发人员隐藏的。纸质中有许多其他微妙的细节,以及一些限制和增强功能。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号