Skip to content

Commit

Permalink
Revert "[class-parse] .jmod file support (#891)"
Browse files Browse the repository at this point in the history
This reverts commit 8ccb837.
  • Loading branch information
jonathanpeppers committed Oct 26, 2021
1 parent 974ad32 commit 2229ccc
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 912 deletions.
2 changes: 0 additions & 2 deletions src/Xamarin.Android.Tools.Bytecode/AttributeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ public string InnerName {
}
}

public string OuterClassName => OuterClass?.Name?.Value;

public override string ToString ()
{
return string.Format ("InnerClass(InnerClass='{0}', OuterClass='{1}', InnerName='{2}', InnerClassAccessFlags={3})",
Expand Down
37 changes: 6 additions & 31 deletions src/Xamarin.Android.Tools.Bytecode/ClassPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,14 @@ public ClassPath (string path = null)
Load (path);
}

public void Load (string filePath)
public void Load (string jarFile)
{
if (IsJmodFile (filePath)) {
using (var source = File.OpenRead (filePath)) {
var slice = new PartialStream (source, 4);
Load (slice);
}
return;
}
if (IsJarFile (filePath)) {
using (var jarStream = File.OpenRead (filePath)) {
Load (jarStream);
}
return;
if (!IsJarFile (jarFile))
throw new ArgumentException ("'jarFile' is not a valid .jar file.", "jarFile");

using (var jarStream = File.OpenRead (jarFile)) {
Load (jarStream);
}
throw new ArgumentException ($"`{filePath}` is not a supported file format.", nameof (filePath));
}

public void Load (Stream jarStream, bool leaveOpen = false)
Expand Down Expand Up @@ -121,23 +113,6 @@ public static bool IsJarFile (string jarFile)
}
}

public static bool IsJmodFile (string jmodFile)
{
if (jmodFile == null)
throw new ArgumentNullException (nameof (jmodFile));
try {
var f = File.OpenRead (jmodFile);
var h = new byte[4];
if (f.Read (h, 0, h.Length) != 4) {
return false;
}
return h[0] == 0x4a && h[1] == 0x4d && h[2] == 0x01 && h[3] == 0x00;
}
catch (Exception) {
return false;
}
}

XAttribute GetApiSource ()
{
if (string.IsNullOrEmpty (ApiSource))
Expand Down
8 changes: 0 additions & 8 deletions src/Xamarin.Android.Tools.Bytecode/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public static void Warning (int verbosity, string format, params object[] args)
log (TraceLevel.Warning, verbosity, format, args);
}

public static void Warning (int verbosity, string message) => Warning (verbosity, "{0}", message);

public static void Error (string format, params object[] args)
{
var log = OnLog;
Expand All @@ -25,8 +23,6 @@ public static void Error (string format, params object[] args)
log (TraceLevel.Error, 0, format, args);
}

public static void Error (string message) => Error ("{0}", message);

public static void Message (string format, params object[] args)
{
var log = OnLog;
Expand All @@ -35,17 +31,13 @@ public static void Message (string format, params object[] args)
log (TraceLevel.Info, 0, format, args);
}

public static void Message (string message) => Message ("{0}", message);

public static void Debug (string format, params object[] args)
{
var log = OnLog;
if (log == null)
return;
log (TraceLevel.Verbose, 0, format, args);
}

public static void Debug (string message) => Debug ("{0}", message);
}
}

Loading

0 comments on commit 2229ccc

Please sign in to comment.