HamzaHassanain/polyman

Handle Java class naming conflict between Polygon and Executor

オープン

#6 opened on 2025/11/23

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)TypeScript (2 件のフォーク)auto 404
bugenhancementgood first issuehelp wanted

Repository metrics

Stars
 (33 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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).
  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.

コントリビューターガイド