-
Notifications
You must be signed in to change notification settings - Fork 260
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
Change Java to compiled language to facilitate multi-file #644
base: master
Are you sure you want to change the base?
Conversation
Currently, Piston does not support multi-file Java submissions This change turns Java into a compiled language, while still maintaining the flexibility of single file submissions.
Hi! I talked about this pull request awhile ago with Hex who asked me to push it upstream. I'm only about a year late in actually getting to this, so it may not be something that is wanted/needed anymore. |
I think this feature is required. I am having a similar request in these lines, where i can be able to have a multi class single java file to execute. Currently it is not supported with piston. |
Just a note! I identified a minor bug with file passing, aka if you want to pass in a .txt file that a .java file should read from. I have resolved this issue and will commit changes soon. |
# Remove .java extension from the main class name if present | ||
mainClass="${1%.java}" | ||
# Execute the main class | ||
java "$mainClass" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this into a run
script - compile
should only ever compile the files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to conditionally trigger a run/compile depending on how many files a user submits?
This workaround is necessary for single-file submissions, as currently, for single-file submissions:
- In piston, if a user uploads a .java filename that does not correspond to the classname it still compiles and runs.
- This function would no longer work if this logic was removed, javac requires filenames to match classnames.
Is there a reason why we could not remove the run script and switch it to a compiled language, using the above logic scheme to maintain functionality of single file submissions?
Any updates? |
Pull Request: Enhance Java Support for Multi-File Submissions
Overview
This pull request aims to extend the functionality of our Java execution environment to support multi-file Java programs. Historically, our system has only supported single-file submissions, limiting the complexity and scope of projects that users can run. This update is a significant step towards accommodating more advanced Java applications and improving the versatility of our execution platform.
Goals
.java
file's name does not match the public class name.Changes
1. Multi-File Support Implementation
compile
file to the Java package. This script leverages the existing Piston infrastructure to compile and execute multi-file Java programs. It automatically detects and compiles all.java
files present in the request2. Single File Submissions
.java
file where the file name does not necessarily match the public class name, and it will continue to be supported seamlessly.3. Multi-File Java Program Support
public static void main(String[] args)
method must be the first file passed into the API. This ensures the correct entry point is identified and executed.