HamzaHassanain / HamzaHassanain/polyman
Handle Java class naming conflict between Polygon and Executor
- Dominant language
- TypeScript
- Stars
- 35
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
## Description
There is currently a compatibility issue between our internal executor and Polygon regarding Java submission naming conventions:
1. **Internal Executor:** Requires the **public class name** to strictly match the **file name** (Standard [JLS 7.6 rules](https://docs.oracle.com/javase/specs/jls/se8/html/jls-7.html#jls-7.6)).
2. **Polygon:** Mandates that the entry point class be named `Main` regardless of the filename.
Currently, this mismatch requires manual intervention or causes compilation errors when moving code between the two environments.
## Proposed Solution
Implement an automated class renaming strategy during the synchronization process to satisfy both environments:
### 1. On Pull (Polygon → Local)
* **Input:** A Java file from Polygon containing `public class Main`.
* **Action:** Parse the file and rename the class `Main` to match the destination filename.
* *Example:* `Solution.java` receives code transformed to `public class Solution`.
### 2. On Push (Local → Polygon)
* **Input:** A local Java file (e.g., `ProblemA.java` containing `public class ProblemA`).
* **Action:** Rename the public class to `Main` before uploading to Polygon.
## Technical Implementation Details
* **Regex/AST Strategy:** We must use a safe replacement strategy (preferably parsing or strict Regex) to ensure we only rename the **class declaration** and its **constructors**.
* *Risk:* Simple string replacement must be avoided to prevent false positives in string literals (e.g., `String s = "Main";`) or comments.
* **References:**
* **Java Language Specification 7.6:** Top-level public classes must match the filename.
* **Polygon/Codeforces:** Requires `public class Main`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.