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
178 changes: 0 additions & 178 deletions Xamarin.Android.sln

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build-tools/scripts/JavaCallableWrappers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/>
<ItemGroup>
<_JavaSources Include="$(IntermediateOutputPath)jcw\src\**\*.java" />
<_JavaSources Include="$(JavaInteropSourceDirectory)\src\Java.Interop\java\com\xamarin\**\*.java" />
</ItemGroup>
<WriteLinesToFile
File="$(IntermediateOutputPath)jcw\classes.txt"
Expand Down
2 changes: 1 addition & 1 deletion external/Java.Interop
39 changes: 39 additions & 0 deletions src/Mono.Android/Android.Runtime/AndroidRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public AndroidRuntimeOptions (IntPtr jnienv, IntPtr vm, bool allocNewObjectSuppo
NewObjectRequired = !allocNewObjectSupported;
ObjectReferenceManager = new AndroidObjectReferenceManager ();
TypeManager = new AndroidTypeManager ();
ValueManager = new AndroidValueManager ();
}
}

Expand Down Expand Up @@ -225,5 +226,43 @@ protected override IEnumerable<string> GetSimpleReferences (Type type)
.Concat (Enumerable.Repeat (j, 1));
}
}

class AndroidValueManager : JniRuntime.JniValueManager {

public override void WaitForGCBridgeProcessing ()
{
JNIEnv.WaitForBridgeProcessing ();
}

public override void AddPeer (IJavaPeerable value)
{
throw new NotImplementedException ();
}

public override void RemovePeer (IJavaPeerable value)
{
throw new NotImplementedException ();
}

public override IJavaPeerable PeekPeer (JniObjectReference reference)
{
throw new NotImplementedException ();
}

public override void CollectPeers ()
{
throw new NotImplementedException ();
}

public override void FinalizePeer (IJavaPeerable value)
{
throw new NotImplementedException ();
}

public override List<JniSurfacedPeerInfo> GetSurfacedPeers ()
{
throw new NotImplementedException ();
}
}
}
#endif // JAVA_INTEROP
14 changes: 6 additions & 8 deletions src/Mono.Android/Java.Interop/JavaConvert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ public static T FromJavaObject<T>(IJavaObject value, out bool set)
set = true;
return value._JavaCast<T>();
}
var o = value as JavaObject;
if (o != null) {
if (value is Android.Runtime.JavaObject o) {
set = true;
if (o.Instance is T)
return (T) o.Instance;
Expand Down Expand Up @@ -255,8 +254,7 @@ public static object FromJavaObject (IJavaObject value, Type targetType = null)
return JavaObjectExtensions.JavaCast (value, targetType);
}

var o = value as JavaObject;
if (o != null) {
if (value is Android.Runtime.JavaObject o) {
if (targetType == null)
return o.Instance;
return Convert.ChangeType (o.Instance, targetType);
Expand Down Expand Up @@ -306,7 +304,7 @@ public static IJavaObject ToJavaObject<T>(T value)
Func<object, IJavaObject> converter = GetJavaObjectConverter (typeof (T));
if (converter != null)
return converter (value);
return new JavaObject (value);
return new Android.Runtime.JavaObject (value);
}

static Dictionary<Type, Func<object, IntPtr>> LocalJniHandleConverters = new Dictionary<Type, Func<object, IntPtr>> {
Expand Down Expand Up @@ -352,8 +350,8 @@ public static IJavaObject ToJavaObject<T>(T value)
using (var v = new Java.Lang.String (value.ToString ()))
return JNIEnv.ToLocalJniHandle (v);
} },
{ typeof (JavaObject), value => {
return value == null ? IntPtr.Zero : JNIEnv.ToLocalJniHandle (new JavaObject (value));
{ typeof (Android.Runtime.JavaObject), value => {
return value == null ? IntPtr.Zero : JNIEnv.ToLocalJniHandle (new Android.Runtime.JavaObject (value));
} },
};

Expand All @@ -364,7 +362,7 @@ static Func<object, IntPtr> GetLocalJniHandleConverter<T> (T value, Type sourceT
return converter;
if (value != null && LocalJniHandleConverters.TryGetValue (value.GetType (), out converter))
return converter;
return LocalJniHandleConverters [typeof (JavaObject)];
return LocalJniHandleConverters [typeof (Android.Runtime.JavaObject)];
}

public static TReturn WithLocalJniHandle<TValue, TReturn>(TValue value, Func<IntPtr, TReturn> action)
Expand Down
4 changes: 4 additions & 0 deletions src/Mono.Android/Mono.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
<HintPath>$(OutputPath)..\v1.0\System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Collections">
<HintPath>$(OutputPath)..\v1.0\Facades\System.Collections.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Core">
<HintPath>$(OutputPath)..\v1.0\System.Core.dll</HintPath>
<Private>False</Private>
Expand Down
3 changes: 1 addition & 2 deletions src/Mono.Android/Mono.Android.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
Outputs="$(OutputPath)\..\v1.0\Java.Interop.dll">
<MSBuild
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we shouldn't need this <MSBuild/> invocation anymore, nor the _BuildJavaInterop target, nor the @(Assembly) item group (below).

Instead -- ideally -- we'd have a @(ProjectReference) within Mono.Android.csproj referring to Java.Interop.csproj, and MSBuild would handle it "normally".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will try it in the next PR.

Projects="$(JavaInteropFullPath)\src\Java.Interop\Java.Interop.csproj"
Properties="Configuration=XAIntegration$(Configuration)"
/>
<ItemGroup>
<Assembly Include="$(JavaInteropFullPath)\bin\XAIntegration$(Configuration)\*.dll*" />
<Assembly Include="$(JavaInteropFullPath)\bin\$(Configuration)\*.dll*" />
</ItemGroup>
<Copy
SourceFiles="@(Assembly)"
Expand Down