Skip to content

Commit ba6b013

Browse files
authored
[Java.Runtime.Environment] Fix CS0436 warnings (dotnet#799)
Fixes: dotnet#792 Commit cba6137 added `[assembly: InternalsVisibleTo]`, allowing the internal types from `Java.Interop.dll` to be seen from/used by `Java.Runtime.Environment.dll`, so that `MonoRuntimeValueManager` could use the type `JniLocationException`. The downside to this change is that types internal to `Java.Interop.dll` were visible to `Java.Runtime.Environment.dll`. Types such as `Java.Interop.NativeMethods`, which "conflicts" with `Java.Interop.NativeMethods` type in `Java.Runtime.Environment.dll`. The result: 31 CS0436 warnings were introduced with commit cba6137: Java.Interop/MonoRuntimeObjectReferenceManager.cs(16,14): warning CS0436: The type 'NativeMethods' in '…/src/Java.Runtime.Environment/Java.Interop/JreRuntime.cs' conflicts with the imported type 'NativeMethods' in 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. Using the type defined in '…/src/Java.Runtime.Environment/Java.Interop/JreRuntime.cs'. Fix these warnings by *removing* the `[assembly: InternalsVisibleTo]` added in cba6137, and copy `JniLocationException` into `Java.Runtime.Environment.dll`, renamed as `OverrideStackTrace`.
1 parent b46598a commit ba6b013

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/Java.Interop/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,3 @@
2828
"814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0" +
2929
"d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b" +
3030
"2c9733db")]
31-
[assembly: InternalsVisibleTo (
32-
"Java.Runtime.Environment, PublicKey=" +
33-
"0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf1" +
34-
"6cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2" +
35-
"814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0" +
36-
"d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b" +
37-
"2c9733db")]

src/Java.Runtime.Environment/Java.Interop/MonoRuntimeValueManager.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public override IJavaPeerable PeekPeer (JniObjectReference reference)
236236
static Exception CreateJniLocationException ()
237237
{
238238
using (var e = new JavaException ()) {
239-
return new JniLocationException (e.ToString ());
239+
return new OverrideStackTrace (e.ToString ());
240240
}
241241
}
242242

@@ -402,5 +402,21 @@ partial class NativeMethods {
402402
[DllImport (JavaInteropLib, CallingConvention=CallingConvention.Cdecl)]
403403
internal static extern void java_interop_gc_bridge_wait_for_bridge_processing (IntPtr bridge);
404404
}
405+
406+
sealed class OverrideStackTrace : Exception {
407+
408+
readonly string stackTrace;
409+
410+
public OverrideStackTrace (string stackTrace)
411+
{
412+
this.stackTrace = stackTrace;
413+
}
414+
415+
public override string StackTrace {
416+
get {
417+
return stackTrace;
418+
}
419+
}
420+
}
405421
}
406422

0 commit comments

Comments
 (0)