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
8 changes: 6 additions & 2 deletions src/Java.Interop/Java.Interop-MonoAndroid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
<Import Project="..\..\Directory.Build.props" />
<PropertyGroup>
<XAConfigPath>..\..\bin\Build$(Configuration)\XAConfig.props</XAConfigPath>
</PropertyGroup>
<Import Condition="Exists ('$(XAConfigPath)')" Project="$(XAConfigPath)" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\Debug</OutputPath>
<DefineConstants>DEBUG;INTEROP;FEATURE_JNIENVIRONMENT_JI_PINVOKES;FEATURE_JNIOBJECTREFERENCE_INTPTRS;INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
<DefineConstants>DEBUG;INTEROP;FEATURE_JNIENVIRONMENT_JI_PINVOKES;FEATURE_JNIOBJECTREFERENCE_INTPTRS;INTERNAL_NULLABLE_ATTRIBUTES;$(JavaInteropDefineConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
Expand All @@ -39,7 +43,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<DefineConstants>INTEROP;FEATURE_JNIENVIRONMENT_JI_PINVOKES;FEATURE_JNIOBJECTREFERENCE_INTPTRS;INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
<DefineConstants>INTEROP;FEATURE_JNIENVIRONMENT_JI_PINVOKES;FEATURE_JNIOBJECTREFERENCE_INTPTRS;INTERNAL_NULLABLE_ATTRIBUTES;$(JavaInteropDefineConstants)</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<DocumentationFile>..\..\bin\Release\Java.Interop.xml</DocumentationFile>
Expand Down
6 changes: 5 additions & 1 deletion src/Java.Interop/Java.Interop.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<XAConfigPath>..\..\bin\Build$(Configuration)\XAConfig.props</XAConfigPath>
</PropertyGroup>
<Import Condition="Exists ('$(XAConfigPath)')" Project="$(XAConfigPath)" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<NoWarn>1591</NoWarn>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
<DefineConstants>INTEROP;FEATURE_JNIENVIRONMENT_JI_PINVOKES;FEATURE_JNIOBJECTREFERENCE_INTPTRS;INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
<DefineConstants>INTEROP;FEATURE_JNIENVIRONMENT_JI_PINVOKES;FEATURE_JNIOBJECTREFERENCE_INTPTRS;INTERNAL_NULLABLE_ATTRIBUTES;$(JavaInteropDefineConstants)</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\$(TargetFramework.ToLowerInvariant())\</IntermediateOutputPath>
Expand Down
2 changes: 0 additions & 2 deletions src/Java.Interop/Java.Interop/JniEnvironment.Errors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public static void ThrowNew (JniObjectReference klass, string message)
throw new InvalidOperationException (string.Format ("Could not raise an exception; JNIEnv::ThrowNew() returned {0}.", r));
}

#if !XA_INTEGRATION
public static void Throw (Exception e)
{
if (e == null)
Expand All @@ -41,7 +40,6 @@ public static void Throw (Exception e)
}
Throw (je.PeerReference);
}
#endif // !XA_INTEGRATION
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/Java.Interop/Java.Interop/JniEnvironment.References.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ public static void PushLocalFrame (int capacity)
throw new InvalidOperationException (string.Format ("Could not push a frame; JNIEnv::PushLocalFrame() returned {0}.", r));
}

#if !XA_INTEGRATION
public static int GetIdentityHashCode (JniObjectReference value)
{
return JniSystem.IdentityHashCode (value);
}
#endif // !XA_INTEGRATION

public static IntPtr NewReturnToJniRef (IJavaPeerable value)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Java.Interop/Java.Interop/JniEnvironment.Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static unsafe JniObjectReference NewString (string? value)
return NewString (s, value.Length);
}

#if !XA_INTEGRATION
public static string? ToString (IntPtr reference)
{
return ToString (new JniObjectReference (reference));
Expand All @@ -28,7 +27,6 @@ public static unsafe JniObjectReference NewString (string? value)
Debug.Assert (targetType == typeof (string), "Expected targetType==typeof(string); was: " + targetType);
return ToString (ref reference, transfer);
}
#endif // !XA_INTEGRATION

public static unsafe string? ToString (JniObjectReference value)
{
Expand Down
3 changes: 0 additions & 3 deletions src/Java.Interop/Java.Interop/JniObjectReferenceOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ partial struct JniObjectReference {
const JniObjectReferenceOptions DisposeSource = (JniObjectReferenceOptions) (1 << 1);
}

#if !XA_INTEGRATION
partial class JniRuntime {
partial class JniValueManager {
const JniObjectReferenceOptions DoNotRegisterTarget = (JniObjectReferenceOptions) (1 << 2);
}
}
#endif // !XA_INTEGRATION
}

Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public unsafe JniObjectReference StartCreateInstance (string constructorSignatur
return r;
}

#if !XA_INTEGRATION
internal JniObjectReference AllocObject (Type declaringType)
{
var r = GetConstructorsForType (declaringType)
Expand All @@ -120,7 +119,6 @@ internal JniObjectReference AllocObject (Type declaringType)
r.Flags = JniObjectReferenceFlags.Alloc;
return r;
}
#endif // !XA_INTEGRATION

internal unsafe JniObjectReference NewObject (string constructorSignature, Type declaringType, JniArgumentValue* parameters)
{
Expand Down
4 changes: 0 additions & 4 deletions src/Java.Interop/Java.Interop/JniPeerMembers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ public JniPeerMembers (string jniPeerTypeName, Type managedPeerType)
if (!typeof (IJavaPeerable).IsAssignableFrom (managedPeerType))
throw new ArgumentException ("'managedPeerType' must implement the IJavaPeerable interface.", nameof (managedPeerType));

#if !XA_INTEGRATION
Debug.Assert (
JniEnvironment.Runtime.TypeManager.GetTypeSignature (managedPeerType).SimpleReference == jniPeerTypeName,
string.Format ("ManagedPeerType <=> JniTypeName Mismatch! javaVM.GetJniTypeInfoForType(typeof({0})).JniTypeName=\"{1}\" != \"{2}\"",
managedPeerType.FullName,
JniEnvironment.Runtime.TypeManager.GetTypeSignature (managedPeerType).SimpleReference,
jniPeerTypeName));
#endif // !XA_INTEGRATION

ManagedPeerType = managedPeerType;
}
Expand All @@ -47,14 +45,12 @@ public JniPeerMembers (string jniPeerTypeName, Type managedPeerType)
if (!typeof (IJavaPeerable).IsAssignableFrom (managedPeerType))
throw new ArgumentException ("'managedPeerType' must implement the IJavaPeerable interface.", nameof (managedPeerType));

#if !XA_INTEGRATION
Debug.Assert (
JniEnvironment.Runtime.TypeManager.GetTypeSignature (managedPeerType).SimpleReference == jniPeerTypeName,
string.Format ("ManagedPeerType <=> JniTypeName Mismatch! javaVM.GetJniTypeInfoForType(typeof({0})).JniTypeName=\"{1}\" != \"{2}\"",
managedPeerType.FullName,
JniEnvironment.Runtime.TypeManager.GetTypeSignature (managedPeerType).SimpleReference,
jniPeerTypeName));
#endif // !XA_INTEGRATION
}

JniPeerTypeName = jniPeerTypeName;
Expand Down
4 changes: 2 additions & 2 deletions src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ IEnumerable<Type> CreateGetTypesEnumerator (JniTypeSignature typeSignature)
yield return type;
continue;
}
#if !XA_INTEGRATION

if (typeSignature.ArrayRank > 0) {
var rank = typeSignature.ArrayRank;
var arrayType = type;
Expand All @@ -214,7 +214,7 @@ IEnumerable<Type> CreateGetTypesEnumerator (JniTypeSignature typeSignature)
}
yield return arrayType;
}
#endif // !XA_INTEGRATION

if (typeSignature.ArrayRank > 0) {
var rank = typeSignature.ArrayRank;
var arrayType = type;
Expand Down
16 changes: 2 additions & 14 deletions src/Java.Interop/Java.Interop/JniRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ protected JniRuntime (CreationOptions options)
}
}

#if !XA_INTEGRATION
#if !XA_JI_EXCLUDE
ManagedPeer.Init ();
#endif // !XA_INTEGRATION
#endif // !XA_JI_EXCLUDE
}

T SetRuntime<T> (T value)
Expand Down Expand Up @@ -325,11 +325,9 @@ protected virtual void Dispose (bool disposing)
JniObjectReference.Dispose (ref ClassLoader);

ClearTrackedReferences ();
#if !XA_INTEGRATION
ValueManager.Dispose ();
marshalMemberBuilder?.Dispose ();
TypeManager.Dispose ();
#endif // !XA_INTEGRATION
ObjectReferenceManager.Dispose ();

var environments = JniEnvironment.Info.Values;
Expand Down Expand Up @@ -389,11 +387,7 @@ public void DestroyRuntime ()

public virtual Exception? GetExceptionForThrowable (ref JniObjectReference reference, JniObjectReferenceOptions options)
{
#if XA_INTEGRATION
throw new NotSupportedException ("Do not know h ow to convert a JniObjectReference to a System.Exception!");
#else // !XA_INTEGRATION
return ValueManager.GetValue<Exception> (ref reference, options);
#endif // !̣XA_INTEGRATION
}

public int GlobalReferenceCount {
Expand Down Expand Up @@ -436,13 +430,7 @@ partial class JniRuntime {

public virtual void RaisePendingException (Exception pendingException)
{
#if XA_INTEGRATION
if (pendingException == null)
throw new ArgumentNullException (nameof (pendingException));
throw new NotSupportedException ("Do not know how to marshal System.Exception instances.");
#else // !XA_INTEGRATION
JniEnvironment.Exceptions.Throw (pendingException);
#endif // !XA_INTEGRATION
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/Java.Interop/Java.Interop/JniType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ public override string ToString ()
return $"JniType(Name='{Name}' PeerReference={PeerReference})";
}

#if XA_INTEGRATION
internal
#else // !XA_INTEGRATION
public
#endif // !XA_INTEGRATION
void RegisterWithRuntime ()
public void RegisterWithRuntime ()
{
AssertValid ();

Expand Down