Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Java.Interop/Java.Interop/JniEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;

Expand All @@ -12,6 +13,7 @@ public static partial class JniEnvironment {
internal static readonly ThreadLocal<JniEnvironmentInfo> Info = new ThreadLocal<JniEnvironmentInfo> (() => new JniEnvironmentInfo (), trackAllValues: true);

internal static JniEnvironmentInfo CurrentInfo {
[MethodImpl (MethodImplOptions.AggressiveInlining)]
get {
var e = Info.Value;
if (!e.IsValid)
Expand All @@ -21,22 +23,27 @@ internal static JniEnvironmentInfo CurrentInfo {
}

public static JniRuntime Runtime {
[MethodImpl (MethodImplOptions.AggressiveInlining)]
get {return CurrentInfo.Runtime;}
}

public static IntPtr EnvironmentPointer {
[MethodImpl (MethodImplOptions.AggressiveInlining)]
get {return CurrentInfo.EnvironmentPointer;}
}

public static JniVersion JniVersion {
[MethodImpl (MethodImplOptions.AggressiveInlining)]
get {return (JniVersion) Versions.GetVersion ();}
}

public static int LocalReferenceCount {
[MethodImpl (MethodImplOptions.AggressiveInlining)]
get {return CurrentInfo.LocalReferenceCount;}
}

public static bool WithinNewObjectScope {
[MethodImpl (MethodImplOptions.AggressiveInlining)]
get {return CurrentInfo.WithinNewObjectScope;}
internal set {CurrentInfo.WithinNewObjectScope = value;}
}
Expand Down
9 changes: 8 additions & 1 deletion src/Java.Interop/Java.Interop/JniObjectReference.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

#if FEATURE_JNIOBJECTREFERENCE_SAFEHANDLES && FEATURE_JNIOBJECTREFERENCE_INTPTRS
Expand All @@ -24,6 +25,7 @@ internal JniReferenceSafeHandle SafeHandle {
get {return gcHandle.IsAllocated ? ((JniReferenceSafeHandle) gcHandle.Target) : JniReferenceSafeHandle.Null;}
}
public IntPtr Handle {
[MethodImpl (MethodImplOptions.AggressiveInlining)]
get {
var h = SafeHandle;
return h == null
Expand All @@ -32,7 +34,11 @@ public IntPtr Handle {
}
}
#elif FEATURE_JNIOBJECTREFERENCE_INTPTRS
public IntPtr Handle {get; private set;}
public IntPtr Handle {
[MethodImpl (MethodImplOptions.AggressiveInlining)]
get;
private set;
}
#endif

uint referenceInfo;
Expand All @@ -47,6 +53,7 @@ internal JniObjectReferenceFlags Flags {
}

public bool IsValid {
[MethodImpl (MethodImplOptions.AggressiveInlining)]
get {
#if FEATURE_JNIOBJECTREFERENCE_SAFEHANDLES
return SafeHandle != null && !SafeHandle.IsInvalid && !SafeHandle.IsClosed;
Expand Down
2 changes: 2 additions & 0 deletions src/Java.Interop/Java.Interop/JniType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;

using Java.Interop;
Expand Down Expand Up @@ -78,6 +79,7 @@ void RegisterWithRuntime ()
registered = true;
}

[MethodImpl (MethodImplOptions.AggressiveInlining)]
void AssertValid ()
{
if (!PeerReference.IsValid)
Expand Down