Skip to content

Commit 85fc91d

Browse files
radekdoulikjonpryor
authored andcommitted
[Java.Interop] Ignore swallowing exceptions for optional assembly load (#235)
The method: System.Void Java.Interop.JniRuntime::SetMarshalMemberBuilder(Java.Interop.JniRuntime/CreationOptions) tries to load optional Export assembly. We don't care about the problem loading it and presume it is missing when exception is caught.
1 parent d437af2 commit 85fc91d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

gendarme-ignore.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ R: Gendarme.Rules.Design.Generic.DoNotExposeNestedGenericSignaturesRule
224224
M: System.Linq.Expressions.Expression`1<System.Func`4<System.Reflection.ConstructorInfo,Java.Interop.JniObjectReference,System.Object[],System.Object>> Java.Interop.JniRuntime/JniMarshalMemberBuilder::CreateConstructActivationPeerExpression(System.Reflection.ConstructorInfo)
225225

226226
R: Gendarme.Rules.Exceptions.DoNotSwallowErrorsCatchingNonSpecificExceptionsRule
227+
# the *.Export assemblies are optional, so we don't care when they cannot be loaded (they are presumably missing)
228+
M: System.Void Java.Interop.JniRuntime::SetMarshalMemberBuilder(Java.Interop.JniRuntime/CreationOptions)
227229
M: System.Reflection.Assembly Java.Interop.JniRuntime/JniTypeManager::TryLoadAssembly(System.Reflection.AssemblyName)
228230
# The exception is transitioned to Jni
229231
M:System.Void Java.Interop.ManagedPeer::Construct(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)

src/Java.Interop/Java.Interop/JniRuntime.JniMarshalMemberBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ partial void SetMarshalMemberBuilder (CreationOptions options)
3232
Assembly jie;
3333
try {
3434
jie = Assembly.Load (new AssemblyName ("Java.Interop.Export"));
35-
} catch (Exception) {
35+
} catch (Exception e) {
36+
System.Diagnostics.Debug.WriteLine ($"Java.Interop.Export assembly was not loaded: {e}");
3637
return;
3738
}
3839
var t = jie.GetType ("Java.Interop.MarshalMemberBuilder");

0 commit comments

Comments
 (0)