-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Java preview features #1303
Comments
It's currently not possible to pass arguments to the language module directly, and I think this isn't something that can be added easily. Additionally, the token extraction does not cover preview features, so while passing the option would turn the error into a warning, plagiarism detection might not work as expected in such cases. There are also breaking changes between the preview features in Java 17 and their finalized versions in Java 21, so supporting preview features likely causes additional work twice. You can run JPlag with Java 21, from a quick test that seems to work, but the problem of the preview feature having slight syntactical and semantical differences will persist (it might result in different compilation errors). Alternatively, you can probably either fork or extend the existing Java language module to suite your needs, I'm not sure if the JPlag maintainers are interested in such changes. (@tsaglam this would be a case where a lexer-based language module is benefitial - with the aforementioned limitations) |
That means, plagiarism in switch expressions would likely not be detected? |
All the code elements should be reached, so the code of each case will be handled just fine, but the pattern itself is not covered - whether this helps or hurts the detection is unclear. |
I think this is fine for now. Thank you. I have forked the repository and added the required flags to enable preview features in the parser. |
We could probably consider supporting preview features with JPlag. I will take this into our internal discussions. |
Closed by #1370. |
I still have this error:
I downloaded the latest jar in the Releases section |
There is an error message when using Java 23. Does this relate to this usse?
|
@koppor What is your exact Java version? What source code did you parse (or which preview feature)? |
I used JDK23. When switching to JDK21, it worked fine. |
The In theory it's possible to set the version dynamically, but that defeats the purpose of the flag as it means there might be incompatibilities (i.e. Java 21 and 22 can deal with string templates, but Java 23 can't). |
I did not specify any flags. Just executed jplag with following command line
Thus, no |
Similar problem here with JDK22. It seems I have to downgrade to 21. |
Yes, I can confirm that going back to JDK21 from JDK22 made the error
go away and the same jplag-5.1.0-jar-with-dependencies.jar file to work ok. |
Sorry @koppor, I should have clarified that this is a problem inside of JPlag. JPlag itself uses these flags when passing the code to the javac tool here JPlag/languages/java/src/main/java/de/jplag/java/JavacAdapter.java Lines 44 to 45 in 3fb0b8f
|
I guess the intented behaviour is not for JPlag released JAR not to work and give cryptic error messages when run with JDK22 or JDK23 but to work fine with JDK21. At least for me, it was a bit of a challenge to figure out that the errors I was getting were not because I was wrong with the command line options but because the compiled code was unhappy with my execution environment, as I haven't used JPlag for many years. For me it is very convenient to just download the released JAR and run it in the command line. Perhaphs downloading the source and building it from scratch will fix it but who has time for that :-) |
I did not have the chance to fully read all comments here as I am currently out of office, but the issues might be resolved with #1854. The next release will include this fix, which will most likely be released before the end of February. If your issues above are not addressed by #1854, we will take a look at them. |
I am working with submissions that use pattern matching in switch statements, which is a language feature hidden behind the
--enable-preview
flag in Java 17. Is it possible to tell JPlag to enable preview features when parsing Java files? Currently, it fails with the following error message:The text was updated successfully, but these errors were encountered: