Skip to content

Commit

Permalink
Do not create main vararg method on Main-Class (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
masesdevelopers authored Aug 1, 2024
1 parent 783dae3 commit 4b27d9d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/net/JNetReflector/InternalMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,11 @@ static string AnalyzeMethods(this Class classDefinition, IReadOnlyDictionary<str
for (int i = 0; i < parameters.Count; i++)
{
var parameter = parameters[i];
bool isParameterVarArgs = parameter.IsVarArgs;
if (isParameterVarArgs && methodNameOrigin == "main" && parameters.Count == 1 && method.IsStatic())
{
isParameterVarArgs = false; // convert vararg parameter to a standard array parameter only for main method
}

List<string> paramGenArguments = new List<string>();
List<KeyValuePair<string, string>> paramGenClauses = new List<KeyValuePair<string, string>>();
Expand All @@ -1562,7 +1567,7 @@ static string AnalyzeMethods(this Class classDefinition, IReadOnlyDictionary<str
{
bool usableGenStrings = true;
if (typeStr.IsNetNativeType()) usableGenStrings = false;
else if (parameter.IsVarArgs && typeStr.EndsWith(SpecialNames.ArrayTypeTrailer))
else if (isParameterVarArgs && typeStr.EndsWith(SpecialNames.ArrayTypeTrailer))
{
typeStr = typeStr.Substring(0, typeStr.IndexOf(SpecialNames.ArrayTypeTrailer));
}
Expand Down Expand Up @@ -1599,7 +1604,7 @@ static string AnalyzeMethods(this Class classDefinition, IReadOnlyDictionary<str
}
var content = string.Format(helpFormat, typeStrForDoc.ConvertToJavadoc());
methodHelpBuilder.AppendLine(string.Format(AllPackageClasses.ClassStub.MethodStub.HELP_PARAM_DECORATION, parameter.Name(), content));
if (parameter.IsVarArgs)
if (isParameterVarArgs)
{
if (!typeStr.EndsWith(SpecialNames.ArrayTypeTrailer)) typeStr += SpecialNames.ArrayTypeTrailer;
methodParamsBuilder.AppendFormat($"params {typeStr} {varArg.Name()}, ");
Expand Down

0 comments on commit 4b27d9d

Please sign in to comment.