jplag / JPlag

State-of-the-Art Software Plagiarism & Collusion Detection
https://jplag.github.io/JPlag/
GNU General Public License v3.0
1.35k stars 309 forks source link

Support for Java Shell scripts? #1412

Open mrcalvin opened 9 months ago

mrcalvin commented 9 months ago

Hi!

Thank you for your great work!

I have the need for running JPlag on Java Shell scripts (JEP 222). Right now, Java processing fails with numerous:

Parser - Assignment1.jshell:106: error: class, interface, enum, or record expected

How can I make these artifacts processed correctly? Wrapping into some class/... harness won't work (e.g., because of freestanding methods). Can JavaC be instructed?

Thank you! Stefan

tsaglam commented 9 months ago

Good question. We do not exclude Java Shell scripts by design. It is probably an underlying issue of the JavaC API, and I am unsure if it supports them. Wrapping would have been my first suggestion as a hotfix. We will take a look at it, but I cannot promise that there will be a fast solution. If you could send us example files for reproduction, that would help (e.g. via jplag@ipd.kit.edu).

mrcalvin commented 9 months ago

Hi! Thx for your reply. In fact, one would have use the parser specific to Java Shell (ReplParser), which packs a shell snippet into a complete compilation unit (JCCompilationUnit) to be further processed by JavaC API. I suspect it would be fine to integrate with ReplParser, in one way or the other, in the JavacAdapter. I'd prefer an integration with the existing java language module, rather spinning another off. This is because I need to check mixed code bases (student assignments, some JShell, some pure).

One option could be to provide an alternative parsing route in response to catching the above JavaC exception, e.g., by calling out to ReplParser in executeCompilationTask?

If you provided some guidance (design-wise), I could offer my take on it? I'd build test cases using the JShell collection of test data.

tsaglam commented 6 months ago

Sorry for the late reply, it seems like I overlooked your answer. An integration in the Java module would indeed be preferable. Catching this particular exception would be okay, iff we can ensure that we only act on the specific exceptions. If you want you can provide a PR and we can guide you on JPlag-specific design decisions.