Skip to content

Commit

Permalink
Update the body of the Main function like the one without variable ar…
Browse files Browse the repository at this point in the history
…guments (#511)
  • Loading branch information
masesdevelopers authored Aug 2, 2024
1 parent 4b27d9d commit e520e1d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/net/JNetReflector/InternalMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,7 @@ static string AnalyzeMethods(this Class classDefinition, IReadOnlyDictionary<str
}

bool bypass = false;
bool hasMainVarVargs = false;
bool hasVarArg = false;
List<Parameter> parameters = new List<Parameter>();
Parameter varArg = null;
Expand All @@ -1521,7 +1522,13 @@ static string AnalyzeMethods(this Class classDefinition, IReadOnlyDictionary<str
{
if (JNetReflectorCore.DisableGenerics && parameter.Type.IsOrInheritFromJVMGenericClass()) { bypass = true; break; }
if (parameter.MustBeAvoided(isGeneric)) { bypass = true; break; }
if (!parameter.IsVarArgs)
bool isParameterVarArgs = parameter.IsVarArgs;
if (isParameterVarArgs && methodNameOrigin == "main" && method.Parameters.Length == 1 && method.IsStatic())
{
isParameterVarArgs = false; // convert vararg parameter to a standard array parameter only for main method
hasMainVarVargs = true;
}
if (!isParameterVarArgs)
{
parameters.Add(parameter);
}
Expand Down Expand Up @@ -1753,7 +1760,9 @@ static string AnalyzeMethods(this Class classDefinition, IReadOnlyDictionary<str
isArrayReturnType = true;
}

if (paramCount == 1 && !parameters[0].IsVarArgs && parameters[0].Type(null, null, parameters[0].Name().Camel(), isGeneric, JNetReflectorCore.UseCamel).EndsWith(SpecialNames.ArrayTypeTrailer))
if (paramCount == 1
&& (hasMainVarVargs || !parameters[0].IsVarArgs)
&& parameters[0].Type(null, null, parameters[0].Name().Camel(), isGeneric, JNetReflectorCore.UseCamel).EndsWith(SpecialNames.ArrayTypeTrailer))
{
executionParamsString = string.Format(AllPackageClasses.ClassStub.MethodStub.SINGLE_ARRAY_EXECUTION_FORMAT, parameters[0].Name);
}
Expand Down

0 comments on commit e520e1d

Please sign in to comment.