HamzaHassanain/polyman
Handle Java class naming conflict between Polygon and Executor
Aperta
#6 aperta il 23 nov 2025
bugenhancementgood first issuehelp wanted
Metriche repository
- Star
- (33 stelle)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
Description
There is currently a compatibility issue between our internal executor and Polygon regarding Java submission naming conventions:
- Internal Executor: Requires the public class name to strictly match the file name (Standard JLS 7.6 rules).
- Polygon: Mandates that the entry point class be named
Mainregardless 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
Mainto match the destination filename.- Example:
Solution.javareceives code transformed topublic class Solution.
- Example:
2. On Push (Local → Polygon)
- Input: A local Java file (e.g.,
ProblemA.javacontainingpublic class ProblemA). - Action: Rename the public class to
Mainbefore 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.
- Risk: Simple string replacement must be avoided to prevent false positives in string literals (e.g.,
- References:
- Java Language Specification 7.6: Top-level public classes must match the filename.
- Polygon/Codeforces: Requires
public class Main.