Skip to content

Commit

Permalink
Prebuild signatures and update search behavior, update startup with a…
Browse files Browse the repository at this point in the history
… better filter for JAR content (#547)

* Prebuild signatures and update search behavior, update startup with a better filter for JAR content

* Added tracing to file
  • Loading branch information
masesdevelopers authored Sep 27, 2024
1 parent 8d3168a commit d1cdb8e
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 50 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/generateclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,15 @@ jobs:
shell: cmd
run: |
cd binReflector\net8.0
MASES.JNetReflector.exe -TraceLevel 0 -DestinationRootPath ..\..\src\ -ConfigurationFile ..\..\src\configuration.json
MASES.JNetReflector.exe -TraceLevel 1 -TraceTo .\JNetReflector.txt -DestinationRootPath ..\..\src\ -ConfigurationFile ..\..\src\configuration.json
env:
JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ONLINE }}

- uses: actions/upload-artifact@v4
with:
name: JNetReflector report
path: .\JNetReflector.txt

- name: Try Java compilation
continue-on-error: true
run: mvn "-Djcobridgepath=../../../binReflector/net8.0/JCOBridge.jar" --file ./src/jvm/jnet/pom.xml --no-transfer-progress package
Expand Down
33 changes: 29 additions & 4 deletions src/net/JNetReflector/InternalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,36 @@ public static string AddClassNameToSignature(this string methodSignature, string
return methodSignature;
}

public static string SignatureFromGenericString(this IReadOnlyDictionary<string, string> methodSignatures, Method entry)
public static string SignatureFromGenericString(this Method entry)
{
var filteredGenString = entry.GenericString.RemoveThrowsAndCleanupSignature();
string signature = null;
if (!methodSignatures.TryGetValue(filteredGenString, out signature))
string signature = SignatureFromGenericString(filteredGenString, entry.DeclaringClass);
if (signature == null)
{
ReflectionUtils.ReportTrace(ReflectionUtils.ReflectionTraceLevel.Critical, $"SignatureFromGenericString: signature not found for method {entry.Name} (Generic string: {entry.GenericString}) of class {entry.DeclaringClass.TypeName} using {filteredGenString} not found.");
}
return signature;
}

static string SignatureFromGenericString(string filteredGenString, Class checkClass)
{
if (checkClass == null || checkClass.TypeName == "java.lang.Object") return null;
var methodSignatures = JNetReflectorHelper.SignatureForClass(checkClass);
string signature = null;
if (methodSignatures != null && methodSignatures.TryGetValue(filteredGenString, out signature))
{
return signature;
}
try
{
return SignatureFromGenericString(filteredGenString, checkClass.SuperClass);
}
catch
{
return null;
}
}

#endregion

#region ZipArchiveEntry extension
Expand Down Expand Up @@ -364,6 +383,12 @@ public static bool IsFolder(this ZipArchiveEntry entry)
return false;
}

public static bool IsClass(this ZipArchiveEntry entry)
{
if (entry.Name.Contains(SpecialNames.ClassExtension)) return true;
return false;
}

public static bool IsJVMNestedClass(this ZipArchiveEntry entry)
{
if (entry.Length != 0
Expand Down Expand Up @@ -1632,7 +1657,7 @@ public static bool IsSpecialClass(this Class entry)
return true;
}

string className = entry.JVMNestedClassName(entry.JVMNestingLevels(), null, true, false);
string className = entry.JVMNestedClassName(entry.JVMNestingLevels(), null, true, false, true);

if (entry.IsJVMNestedClass()
&& SpecialNames.SpecialNumberedNames.Any((o) => className.StartsWith(o))) return true;
Expand Down
Loading

0 comments on commit d1cdb8e

Please sign in to comment.