Skip to content

Commit

Permalink
Revert back algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
masesdevelopers committed Sep 26, 2024
1 parent 79d2205 commit 1cf9b55
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/net/JNetReflector/JNetReflectorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,20 @@ public static IDictionary<Class, IReadOnlyDictionary<string, string>> ExtractJav
if (exited && process.ExitCode != 0) throw new InvalidOperationException($"javap falied with error {process.ExitCode}");

Dictionary<string, string> map = new Dictionary<string, string>();
string line;
int classCounter = -1;
int endCounter = 0;
string methodName = string.Empty;
string className = string.Empty;
bool nextLineIsDescriptor = false;
bool foundParenthesis = false;
#if TEST_ALGORITHM
int endCounter = 0;
int cycleCounter = 0;
do
{
string line = process.StandardOutput.ReadLine();
line = process.StandardOutput.ReadLine();
if (line == null)
{
if (!foundParenthesis)
if (endCounter != toBeAnalyzed.Count)
{
// wait a while
cycleCounter++;
Expand Down Expand Up @@ -164,34 +165,33 @@ public static IDictionary<Class, IReadOnlyDictionary<string, string>> ExtractJav
if (endCounter == toBeAnalyzed.Count) break;
}
while (cycleCounter < 100);

//foreach (var line in lines)
//{
// if (string.IsNullOrWhiteSpace(line)) continue;

// if (line.Contains("Compiled from"))
// {
// if (classCounter != -1) { dict.TryAdd(toBeAnalyzed[classCounter], map); }
// classCounter++;
// className = toBeAnalyzed[classCounter].Name;
// map = new Dictionary<string, string>();
// }
// if (nextLineIsDescriptor)
// {
// nextLineIsDescriptor = false;
// string signature = line.TrimStart().TrimEnd();
// signature = signature.Remove(0, "descriptor: ".Length);
// map.Add(methodName, signature);
// }
// bool isInterfaceOrClassLine = line.Contains("class") || line.Contains("interface");
// if (line.Contains("public") && !isInterfaceOrClassLine)
// {
// nextLineIsDescriptor = true;
// methodName = line.TrimStart().TrimEnd();
// methodName = methodName.RemoveThrowsAndCleanupSignature();
// methodName = methodName.AddClassNameToSignature(className);
// }
//}
#else
while ((line = process.StandardOutput.ReadLine()) != null)
{
if (line.Contains("Compiled from"))
{
if (classCounter != -1) { dict.TryAdd(toBeAnalyzed[classCounter], map); }
classCounter++;
className = toBeAnalyzed[classCounter].Name;
map = new Dictionary<string, string>();
}
if (nextLineIsDescriptor)
{
nextLineIsDescriptor = false;
string signature = line.TrimStart().TrimEnd();
signature = signature.Remove(0, "descriptor: ".Length);
map.Add(methodName, signature);
}
bool isInterfaceOrClassLine = line.Contains("class") || line.Contains("interface");
if (line.Contains("public") && !isInterfaceOrClassLine)
{
nextLineIsDescriptor = true;
methodName = line.TrimStart().TrimEnd();
methodName = methodName.RemoveThrowsAndCleanupSignature();
methodName = methodName.AddClassNameToSignature(className);
}
}
#endif
dict.TryAdd(toBeAnalyzed[classCounter], map);
}
catch { }
Expand Down

0 comments on commit 1cf9b55

Please sign in to comment.