Localization of try block and generation of catch block to handle exception using an improved LSTM

Preetesh Purohit, Anuradha Purohit, Vrinda Tokekar
{"title":"Localization of try block and generation of catch block to handle exception using an improved LSTM","authors":"Preetesh Purohit, Anuradha Purohit, Vrinda Tokekar","doi":"10.1007/s10586-024-04633-x","DOIUrl":null,"url":null,"abstract":"<p>Several contemporary programming languages, including Java, have exception management as a crucial built-in feature. By employing try-catch blocks, it enables developers to handle unusual or unexpected conditions that might arise at runtime beforehand. If exception management is neglected or applied improperly, it may result in serious incidents like equipment failure. Exception handling mechanisms are difficult to implement and time expensive with the preceding methodologies. This research introduces an efficient Long Short Term Memory (LSTM) technique for handling the exceptions automatically, which can identify the locations of the try blocks and automatically create the catch blocks. Bulky java code is collected from GitHub and splitted into several different fragments. For localization of the try block, Bidirectional LSTM (BiLSTM) is used initially as a token level encoder and then as a statement-level encoder. Then, the Support Vector Machine (SVM) is used to predict the try block present in the given source code. For generating a catch block, BiLSTM is initially used as an encoder, and LSTM is used as a decoder. Then, SVM is used here to predict the noisy tokens. The loss functions of this encoder-decoder model have been trained to be as small as possible. The trained model then uses the black widow method to forecast the following tokens one by one and then generates the entire catch block. The proposed work reaches 85% accuracy for try block localization and 50% accuracy for catch block generation. An improved LSTM with an attention mechanism method produces an optimal solution compared to the existing techniques. Thus the proposed method is the best choice for handling the exceptions.</p>","PeriodicalId":501576,"journal":{"name":"Cluster Computing","volume":"82 1","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-07-20","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Cluster Computing","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1007/s10586-024-04633-x","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

Several contemporary programming languages, including Java, have exception management as a crucial built-in feature. By employing try-catch blocks, it enables developers to handle unusual or unexpected conditions that might arise at runtime beforehand. If exception management is neglected or applied improperly, it may result in serious incidents like equipment failure. Exception handling mechanisms are difficult to implement and time expensive with the preceding methodologies. This research introduces an efficient Long Short Term Memory (LSTM) technique for handling the exceptions automatically, which can identify the locations of the try blocks and automatically create the catch blocks. Bulky java code is collected from GitHub and splitted into several different fragments. For localization of the try block, Bidirectional LSTM (BiLSTM) is used initially as a token level encoder and then as a statement-level encoder. Then, the Support Vector Machine (SVM) is used to predict the try block present in the given source code. For generating a catch block, BiLSTM is initially used as an encoder, and LSTM is used as a decoder. Then, SVM is used here to predict the noisy tokens. The loss functions of this encoder-decoder model have been trained to be as small as possible. The trained model then uses the black widow method to forecast the following tokens one by one and then generates the entire catch block. The proposed work reaches 85% accuracy for try block localization and 50% accuracy for catch block generation. An improved LSTM with an attention mechanism method produces an optimal solution compared to the existing techniques. Thus the proposed method is the best choice for handling the exceptions.

Abstract Image

使用改进型 LSTM 定位 try 块并生成 catch 块以处理异常
包括 Java 在内的多种现代编程语言都将异常管理作为一项重要的内置功能。通过使用 try-catch 块,开发人员可以事先处理运行时可能出现的异常或意外情况。如果忽视异常管理或应用不当,可能会导致设备故障等严重事故。以往的方法很难实现异常处理机制,而且耗时耗力。本研究引入了一种高效的长短期记忆(LSTM)技术来自动处理异常,它可以识别 try 块的位置并自动创建 catch 块。我们从 GitHub 收集了大量 Java 代码,并将其分割成多个不同的片段。为了定位 try 块,双向 LSTM(BiLSTM)最初用作标记级编码器,然后用作语句级编码器。然后,使用支持向量机(SVM)来预测给定源代码中存在的 try 代码块。在生成 catch 块时,BiLSTM 最初用作编码器,LSTM 用作解码器。然后,这里使用 SVM 来预测有噪声的标记。该编码器-解码器模型的损失函数已被训练得尽可能小。训练好的模型会使用黑寡妇方法逐个预测后面的标记,然后生成整个捕获块。所提议的工作在尝试块定位方面达到了 85% 的准确率,在捕捉块生成方面达到了 50% 的准确率。与现有技术相比,带有注意力机制的改进型 LSTM 方法能产生最佳解决方案。因此,所提出的方法是处理异常的最佳选择。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信