Skip to content

Commit

Permalink
[Java.Interop] Fix FEATURE_HANDLES_ARE_INTPTRS compilation.
Browse files Browse the repository at this point in the history
Commit 25de1f3 didn't compile when FEATURE_HANDLES_ARE_INTPTRS was
set. Oops.

Fix compilation and unit test failures.
  • Loading branch information
jonpryor committed Oct 22, 2015
1 parent 33ebcb8 commit 9b85e8d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Java.Interop/Java.Interop/JniAllocObjectRef.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;

#if FEATURE_HANDLES_ARE_SAFE_HANDLES
namespace Java.Interop {

sealed class JniAllocObjectRef : JniLocalReference
Expand All @@ -10,4 +11,4 @@ public JniAllocObjectRef (IntPtr handle)
}
}
}

#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES
11 changes: 11 additions & 0 deletions src/Java.Interop/Java.Interop/JniEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public JavaVM JavaVM {
}
}

#if FEATURE_HANDLES_ARE_SAFE_HANDLES
List<JniLocalReference> lrefs;
internal List<JniLocalReference> LocalReferences {
get {return lrefs ?? (lrefs = new List<JniLocalReference> ());}
Expand All @@ -92,6 +93,7 @@ internal static bool IsHandleValid (JniLocalReference lref)
}
return false;
}
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES

internal static bool HasCurrent {
get {return current != null;}
Expand Down Expand Up @@ -213,6 +215,15 @@ internal void DeleteLocalReference (JniLocalReference value, IntPtr handle)
value.SetHandleAsInvalid ();
}
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES
#if FEATURE_HANDLES_ARE_INTPTRS
internal void LogCreateLocalRef (IntPtr value)
{
if (value == IntPtr.Zero)
return;
var r = new JniObjectReference (value, JniObjectReferenceType.Local);
LogCreateLocalRef (r);
}
#endif // FEATURE_HANDLES_ARE_INTPTRS

JniInstanceMethodInfo Obj_toS;
internal JniInstanceMethodInfo Object_toString {
Expand Down
2 changes: 2 additions & 0 deletions src/Java.Interop/Java.Interop/JniLocalReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Runtime.InteropServices;

#if FEATURE_HANDLES_ARE_SAFE_HANDLES
namespace Java.Interop
{
class JniLocalReference : JniReferenceSafeHandle {
Expand Down Expand Up @@ -36,3 +37,4 @@ internal JniAllocObjectRef ToAllocObjectRef ()
}
}
}
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES
2 changes: 1 addition & 1 deletion src/Java.Interop/Java.Interop/JniObjectReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public bool IsValid {
return SafeHandle != null && !SafeHandle.IsInvalid && !SafeHandle.IsClosed;
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES
#if FEATURE_HANDLES_ARE_INTPTRS
return Handle == IntPtr.Zero;
return Handle != IntPtr.Zero;
#endif // FEATURE_HANDLES_ARE_SAFE_HANDLES
}
}
Expand Down

0 comments on commit 9b85e8d

Please sign in to comment.