Skip to content

Commit 9b85e8d

Browse files
committed
[Java.Interop] Fix FEATURE_HANDLES_ARE_INTPTRS compilation.
Commit 25de1f3 didn't compile when FEATURE_HANDLES_ARE_INTPTRS was set. Oops. Fix compilation and unit test failures.
1 parent 33ebcb8 commit 9b85e8d

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/Java.Interop/Java.Interop/JniAllocObjectRef.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22

3+
#if FEATURE_HANDLES_ARE_SAFE_HANDLES
34
namespace Java.Interop {
45

56
sealed class JniAllocObjectRef : JniLocalReference
@@ -10,4 +11,4 @@ public JniAllocObjectRef (IntPtr handle)
1011
}
1112
}
1213
}
13-
14+
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES

src/Java.Interop/Java.Interop/JniEnvironment.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public JavaVM JavaVM {
7373
}
7474
}
7575

76+
#if FEATURE_HANDLES_ARE_SAFE_HANDLES
7677
List<JniLocalReference> lrefs;
7778
internal List<JniLocalReference> LocalReferences {
7879
get {return lrefs ?? (lrefs = new List<JniLocalReference> ());}
@@ -92,6 +93,7 @@ internal static bool IsHandleValid (JniLocalReference lref)
9293
}
9394
return false;
9495
}
96+
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES
9597

9698
internal static bool HasCurrent {
9799
get {return current != null;}
@@ -213,6 +215,15 @@ internal void DeleteLocalReference (JniLocalReference value, IntPtr handle)
213215
value.SetHandleAsInvalid ();
214216
}
215217
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES
218+
#if FEATURE_HANDLES_ARE_INTPTRS
219+
internal void LogCreateLocalRef (IntPtr value)
220+
{
221+
if (value == IntPtr.Zero)
222+
return;
223+
var r = new JniObjectReference (value, JniObjectReferenceType.Local);
224+
LogCreateLocalRef (r);
225+
}
226+
#endif // FEATURE_HANDLES_ARE_INTPTRS
216227

217228
JniInstanceMethodInfo Obj_toS;
218229
internal JniInstanceMethodInfo Object_toString {

src/Java.Interop/Java.Interop/JniLocalReference.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Diagnostics;
33
using System.Runtime.InteropServices;
44

5+
#if FEATURE_HANDLES_ARE_SAFE_HANDLES
56
namespace Java.Interop
67
{
78
class JniLocalReference : JniReferenceSafeHandle {
@@ -36,3 +37,4 @@ internal JniAllocObjectRef ToAllocObjectRef ()
3637
}
3738
}
3839
}
40+
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES

src/Java.Interop/Java.Interop/JniObjectReference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public bool IsValid {
4848
return SafeHandle != null && !SafeHandle.IsInvalid && !SafeHandle.IsClosed;
4949
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES
5050
#if FEATURE_HANDLES_ARE_INTPTRS
51-
return Handle == IntPtr.Zero;
51+
return Handle != IntPtr.Zero;
5252
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES
5353
}
5454
}

0 commit comments

Comments
 (0)