Currently available tools for semantic clone detection have serious type limitations related to objects, in particular related to instantiation and comparison. The trend in the recent research has focused on improving the performance rather than removing these constraints. This paper proposes a test-based approach for semantic clone detection in Java which overcomes these problems. The test-based approach consists in running two methods with the same input and comparing their outputs. For object instantiation, the approach uses EvoSuite, an automatic JUnit test generator, to create the tests with correct instantiations of all the needed classes, which are then modified to make them suitable for semantic clone detection. The output comparison uses the DeepHash function to obtain numerical values for objects, considering the values of each instance variable. The approach was evaluated with SemanticCloneBench. The results show that the proposed approach performs very well in terms of precision, achieving 94.4%, which is about 8% higher than the reported precision of SLACC, a recent semantic clone detector. Furthermore, out of 228 methods used for the evaluation, the approach was not able to perform the detection for only ten methods.

Gli strumenti attualmente disponibili per l’individuazione dei cloni semantici nel codice hanno limitazioni molto importanti per quel che riguarda gli oggetti relative ai tipi, correlate in particolare all’istanziazione e alla comparazione. Il trende nella recente ricerca è stato quello di focalizzarsi sul migliorare le prestazioni, piuttosto che risolvere questi limiti. Questa tesi propone un approccio basato sui test per l’individuazione dei cloni semantici in Java, che superi questi problemi. Ingenerale, l’approccio basato sul test consiste nell’eseguire due metodi con lo stesso input per poi compararne l’output. Per quel che riguarda l’instanziazione degli oggetti, nell’approccio proposto viene usato EvoSuite, un generatore di test JUnit automatico, per creare dei test che contengano la corretta instanziazione di tutte le classi necessarie. Suddetti test vengono poi modificati a dovere in modo che siano adatti all’individuazione dei cloni semantici. Nel confronto degli output viene usata la funzione DeepHash per ottenere valori numerici per ogni oggetto, considerando il contenuto di ogni variabile d’istanza. L’approccio è stato valutato usando il benchmark SemanticCloneBench. I risultati mostrano che l’approccio proposto performa molto bene in termini di precisione, raggiungendo il 94.4%, circa 8% in più rispetto alla precisione riportata per SLACC, un altro recente strumento per l’individuazione di cloni semantici. Inoltre, su un totale di 228 metodi usati per la valutazione, non è stato possibile effettuare la ricerca dei cloni solo per 10 metodi.

Semantic clone detection without type limitations

LEONE, FRANCESCO
2024/2025

Abstract

Currently available tools for semantic clone detection have serious type limitations related to objects, in particular related to instantiation and comparison. The trend in the recent research has focused on improving the performance rather than removing these constraints. This paper proposes a test-based approach for semantic clone detection in Java which overcomes these problems. The test-based approach consists in running two methods with the same input and comparing their outputs. For object instantiation, the approach uses EvoSuite, an automatic JUnit test generator, to create the tests with correct instantiations of all the needed classes, which are then modified to make them suitable for semantic clone detection. The output comparison uses the DeepHash function to obtain numerical values for objects, considering the values of each instance variable. The approach was evaluated with SemanticCloneBench. The results show that the proposed approach performs very well in terms of precision, achieving 94.4%, which is about 8% higher than the reported precision of SLACC, a recent semantic clone detector. Furthermore, out of 228 methods used for the evaluation, the approach was not able to perform the detection for only ten methods.
ING - Scuola di Ingegneria Industriale e dell'Informazione
10-ott-2024
2024/2025
Gli strumenti attualmente disponibili per l’individuazione dei cloni semantici nel codice hanno limitazioni molto importanti per quel che riguarda gli oggetti relative ai tipi, correlate in particolare all’istanziazione e alla comparazione. Il trende nella recente ricerca è stato quello di focalizzarsi sul migliorare le prestazioni, piuttosto che risolvere questi limiti. Questa tesi propone un approccio basato sui test per l’individuazione dei cloni semantici in Java, che superi questi problemi. Ingenerale, l’approccio basato sul test consiste nell’eseguire due metodi con lo stesso input per poi compararne l’output. Per quel che riguarda l’instanziazione degli oggetti, nell’approccio proposto viene usato EvoSuite, un generatore di test JUnit automatico, per creare dei test che contengano la corretta instanziazione di tutte le classi necessarie. Suddetti test vengono poi modificati a dovere in modo che siano adatti all’individuazione dei cloni semantici. Nel confronto degli output viene usata la funzione DeepHash per ottenere valori numerici per ogni oggetto, considerando il contenuto di ogni variabile d’istanza. L’approccio è stato valutato usando il benchmark SemanticCloneBench. I risultati mostrano che l’approccio proposto performa molto bene in termini di precisione, raggiungendo il 94.4%, circa 8% in più rispetto alla precisione riportata per SLACC, un altro recente strumento per l’individuazione di cloni semantici. Inoltre, su un totale di 228 metodi usati per la valutazione, non è stato possibile effettuare la ricerca dei cloni solo per 10 metodi.
File allegati
File Dimensione Formato  
Leone_Tesi_Final.pdf

accessibile in internet per tutti

Descrizione: Tesi estesa
Dimensione 1.96 MB
Formato Adobe PDF
1.96 MB Adobe PDF Visualizza/Apri
Leone_Tesi_executive_summary.pdf

accessibile in internet per tutti

Descrizione: Executive summary
Dimensione 544.46 kB
Formato Adobe PDF
544.46 kB Adobe PDF Visualizza/Apri

I documenti in POLITesi sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/10589/227895