arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2405.11294cs.SE
收藏

在纯代码中序列化Java对象

Serializing Java Objects in Plain Code

Karlsruhe Institute of Technology(卡尔斯鲁厄理工学院);KTH Royal Institute of Technology(皇家理工学院)

Julian Wachter, Deepika Tiwari, Martin Monperrus, Benoit Baudry

AI总结:

本文提出纯代码序列化方法,通过将Java对象序列化为Java源代码,提高在测试用例中读取对象的可读性,并通过实验验证其性能和实用性。

摘要:

在管理语言中,对象的序列化通常是通过定制的二进制格式(如Protobuf)或标记语言(如XML或JSON)进行的。这些格式的主要局限性是可读性。人类开发者无法阅读二进制代码,并且在大多数情况下,会受到XML或JSON语法的困扰。当对象旨在嵌入并读取在源代码中时,如在测试用例中,这是一个主要问题。为了解决这个问题,我们提出了纯代码序列化。我们的核心思想是将运行时观察到的对象以编程语言的原生语法进行序列化。我们在这个背景下实现了Java,展示了将Java对象序列化为Java源代码的原型。结果源代码能够忠实重建运行时看到的对象。我们的原型称为ProDJ,并且已公开可用。我们通过ProDJ对4个开源Java应用程序执行期间观察到的174,699个对象进行了实验,成功实现了纯代码序列化。我们的性能测量表明,性能影响不明显。通过用户研究,我们展示了开发者更倾向于在自动生成的测试中使用纯代码序列化的对象,而不是作为XML或JSON的表示。

英文摘要:

In managed languages, serialization of objects is typically done in bespoke binary formats such as Protobuf, or markup languages such as XML or JSON. The major limitation of these formats is readability. Human developers cannot read binary code, and in most cases, suffer from the syntax of XML or JSON. This is a major issue when objects are meant to be embedded and read in source code, such as in test cases. To address this problem, we propose plain-code serialization. Our core idea is to serialize objects observed at runtime in the native syntax of a programming language. We realize this vision in the context of Java, and demonstrate a prototype which serializes Java objects to Java source code. The resulting source faithfully reconstructs the objects seen at runtime. Our prototype is called ProDJ and is publicly available. We experiment with ProDJ to successfully plain-code serialize 174,699 objects observed during the execution of 4 open-source Java applications. Our performance measurement shows that the performance impact is not noticeable. Through a user study, we demonstrate that developers prefer plain-code serialized objects within automatically generated tests over their representations as XML or JSON.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑