-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Java.Base] Bind package java.util.concurrent (#1274)
Context: 0aec86a Commit 0aec86a mentioned: > * Use of `JNIEnv.GetJniName()` > > string __id = "(L" + global::Android.Runtime.JNIEnv.GetJniName (GetType ().DeclaringType) + ";)V"; > > Impacts: NestedTypes.cs This issue also impacts [`java.util.concurrent.locks.AbstractQueuedSynchronizer.ConditionObject`][0]. Update `Java.Base` to bind the `java.util.concurrent` package, which will cause `AbstractQueuedSynchronizer` to be bound, which in turn forces us to update `generator` to not emit `JNIEnv.GetJniName()`. Instead of using `JNIEnv.GetJniName(GetType().DeclaringType)`, use: JniEnvironment.Runtime.TypeManager.GetTypeSignature (GetType ().DeclaringType).SimpleReference Update NestedTypes.cs to enable `TryJavaInterop1 => true`. Update `Java.Base.csproj` to ignore C# warning [CS0109][1], as [`CompletableFuture.handle()`][2] is emitted with a `new` which is not required: Java.Util.Concurrent.CompletableFuture.cs(629,76): warning CS0109: The member 'CompletableFuture.Handle(IBiFunction?)' does not hide an accessible member. The new keyword is not required. Add a test to `tests/Java.Base-Tests` which tests nested type support. Update `JavaNativeTypeManager.cs` so that `IsNonStaticInnerClass()` supports JavaInterop1-style attributes, not just XAJavaInterop1. Aside: I updated my local JDK to JDK-17 (from JDK-11), which caused many changes to `src/Java.Base-ref.cs`, particularly parameter names. TODO? Update `Java.Interop.Tools.JavaCallableWrappers` so that non-static inner classes don't have a prefix of their declaring type. This would result in `example/MyQueuedSynchronizer$MyConditionObject` instead of `example/MyQueuedSynchronizer$MyQueuedSynchronizer_MyConditionObject`. [0]: https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedSynchronizer.ConditionObject [1]: https://learn.microsoft.com/dotnet/csharp/misc/cs0109 [2]: https://developer.android.com/reference/java/util/concurrent/CompletableFuture#handle(java.util.function.BiFunction%3C?%20super%20T,java.lang.Throwable,?%20extends%20U%3E)
- Loading branch information
Showing
10 changed files
with
3,072 additions
and
35 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
|
||
using Java.Interop; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace Java.BaseTests { | ||
|
||
[TestFixture] | ||
public class NestedTypeTests : JavaVMFixture { | ||
|
||
[Test] | ||
public void Create_AbstractQueuedSynchronizer_ConditionObject () | ||
{ | ||
using var outer = new MyQueuedSynchronizer (); | ||
using var inner = new MyQueuedSynchronizer.MyConditionObject (outer); | ||
} | ||
} | ||
|
||
[JniTypeSignature (JniTypeName)] | ||
class MyQueuedSynchronizer : Java.Util.Concurrent.Locks.AbstractQueuedSynchronizer { | ||
internal const string JniTypeName = "example/MyQueuedSynchronizer"; | ||
|
||
public MyQueuedSynchronizer () | ||
{ | ||
} | ||
|
||
public class MyConditionObject : Java.Util.Concurrent.Locks.AbstractQueuedSynchronizer.ConditionObject { | ||
|
||
public MyConditionObject (MyQueuedSynchronizer outer) | ||
: base (outer) | ||
{ | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
tests/generator-Tests/expected.ji/NestedTypes/Java.Lang.Object.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters