Skip to content

Commit

Permalink
Mangle names of synthetic script classes
Browse files Browse the repository at this point in the history
A script has to be compiled into a class to be executed, but it is
feasible to create a class within a script that has the same name of the
script file. This creates a conflict as the class and the script would
end up being compiled with the same name. Mangling the script name
ensures this cannot happen.

The mangling is kept to a minimum, by adding a $ at the end of the
generated script class name.

Signed-off-by: TheSilkMiner <[email protected]>
  • Loading branch information
TheSilkMiner committed May 22, 2024
1 parent 547b262 commit ed9c0c2
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ private String getClassName(String filename) {
.substring(0, filename.lastIndexOf('.')) //remove the .zs part
.replaceAll(specialCharRegex, "_")
.replace('[', '_')
.replace(File.separatorChar, '/');
.replace(File.separatorChar, '/')
.concat("$");
}
}

Expand Down

0 comments on commit ed9c0c2

Please sign in to comment.