diff --git a/tests/Java.Interop-Tests/Java.Interop-Tests.targets b/tests/Java.Interop-Tests/Java.Interop-Tests.targets index b62ad593d..3f6e36bc6 100644 --- a/tests/Java.Interop-Tests/Java.Interop-Tests.targets +++ b/tests/Java.Interop-Tests/Java.Interop-Tests.targets @@ -1,12 +1,47 @@ + + <_BuildJavaInteropTestsJarInputs Include="$(TargetPath)" /> + <_BuildJavaInteropTestsJarInputs Include="$(MSBuildThisFileFullPath)" /> + <_BuildJavaInteropTestsJarInputs Include="java\**\*.java" /> + + + + + + + + <_RefAsmDirs Include="@(ReferencePathWithRefAssemblies->'%(RootDir)%(Directory).'->Distinct())" /> + + + <_JcwGen>"$(UtilityOutputFullPath)/jcw-gen.dll" + <_Target>--codegen-target JavaInterop1 + <_Output>-o "$(IntermediateOutputPath)/java" + <_Libpath>@(_RefAsmDirs->'-L "%(Identity)"', ' ') + + + + + + + + <_GeneratedJcwSource Include="$(IntermediateOutputPath)java\**\*.java" /> + + + <_Source Include="@(JavaInteropTestJar->Replace('%5c', '/'))" /> + <_Source Include="@(_GeneratedJcwSource->Replace('%5c', '/'))" /> (() => new JavaObject (ref r, JniObjectReferenceOptions.CopyAndDispose)); - // Note: This may break if/when JavaVM provides "default" - Assert.Throws (() => new JavaObjectWithNoJavaPeer ()); #if __ANDROID__ Assert.Throws (() => new JavaObjectWithMissingJavaPeer ()).Dispose (); #else // !__ANDROID__ + // Note: `JavaObjectWithNoJavaPeer` creation works on Android because tooling provides all + // typemap entries. On desktop, we use the hardcoded cit in JavaVMFixture, which deliberately + // *lacks* an entry for `JavaObjectWithNoJavaPeer`. + Assert.Throws (() => new JavaObjectWithNoJavaPeer ()); Assert.Throws (() => new JavaObjectWithMissingJavaPeer ()).Dispose (); #endif // !__ANDROID__ } @@ -201,17 +203,21 @@ public void DisposeAccessesThis () } } +#if !__ANDROID__ class JavaObjectWithNoJavaPeer : JavaObject { } +#endif // !__ANDROID__ [JniTypeSignature (JniTypeName, GenerateJavaPeer=false)] class JavaObjectWithMissingJavaPeer : JavaObject { internal const string JniTypeName = "__this__/__type__/__had__/__better__/__not__/__Exist__"; } - [JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] + [JniTypeSignature (JniTypeName)] class JavaDisposedObject : JavaObject { + internal const string JniTypeName = "net/dot/jni/test/JavaDisposedObject"; + public Action OnDisposed; public Action OnFinalized; @@ -230,8 +236,10 @@ protected override void Dispose (bool disposing) } } - [JniTypeSignature ("java/lang/Object", GenerateJavaPeer=false)] + [JniTypeSignature (JniTypeName)] class MyDisposableObject : JavaObject { + internal const string JniTypeName = "net/dot/jni/test/MyDisposableObject"; + bool _isDisposed; public MyDisposableObject () diff --git a/tests/Java.Interop-Tests/Java.Interop/JavaVMFixture.cs b/tests/Java.Interop-Tests/Java.Interop/JavaVMFixture.cs index ba74d62c8..18014c33c 100644 --- a/tests/Java.Interop-Tests/Java.Interop/JavaVMFixture.cs +++ b/tests/Java.Interop-Tests/Java.Interop/JavaVMFixture.cs @@ -40,6 +40,9 @@ class JavaVMFixtureTypeManager : JniRuntime.JniTypeManager { [CallVirtualFromConstructorBase.JniTypeName] = typeof (CallVirtualFromConstructorBase), [CallVirtualFromConstructorDerived.JniTypeName] = typeof (CallVirtualFromConstructorDerived), [GetThis.JniTypeName] = typeof (GetThis), + [JavaDisposedObject.JniTypeName] = typeof (JavaDisposedObject), + [JavaObjectWithMissingJavaPeer.JniTypeName] = typeof (JavaObjectWithMissingJavaPeer), + [MyDisposableObject.JniTypeName] = typeof (JavaDisposedObject), }; public JavaVMFixtureTypeManager ()