Commit 9b7edbc
committed
[Java.Base, generator] Bind all of package java.lang
Context: bc5bcf4
Bind all classes and interfaces in the `java.lang` package.
Alter Java array binding, so that instead of `IList<T>`, we get
"direct" Java arrays, e.g.
namespace Java.Lang {
partial class Character {
// Previous/Xamarin.Android-like
public static int CodePointAt (IList<char>? a, int index);
// New/Desktop
public static int CodePointAt (JavaCharArray? a, int index);
}
}
Rationale: it *allows* for more efficient JVM :: .NET array copying,
by making copies explicit (to the dev), not implicit. We can
add an implicit conversion from e.g. `IEnumerable<char>` to
`JavaCharArray` in the future, if deemed useful.
This also impacts method return types, properties, and fields.
Bind the `java.lang.module` package in the namespace
`Java.Lang.Modules`. This is to avoid a type/namespace conflict
with `java.lang.Module`, bound as `Java.Lang.Module`.
Continue updating `generator` to remove "Android-isms".
Update `Java.Base.csproj` to ignore [warning CS0108][0]:
Java.Lang.Reflect.IAnnotatedArrayType.cs(15,45):
warning CS0108: 'IAnnotatedArrayType.AnnotatedOwnerType' hides inherited member
'IAnnotatedType.AnnotatedOwnerType'. Use the new keyword if hiding was intended.
The problem here is that we have:
public partial interface IAnnotatedType {
// Contains default interface method
virtual unsafe IAnnotatedType? AnnotatedOwnerType => …;
}
public partial interface IAnnotatedArrayType : IAnnotatedType {
// Contains *no* method body; re-abstracted
IAnnotatedType? AnnotatedOwnerType {get;}
}
TODO: figure out how to properly fix this. `managedOverride`
metadata (5a0e37e) doesn't seem useful to "re-abstract" a default
interface member.
Update `Java.Base.targets` to use `generator --global`. This is so
that `java.lang.System` can be bound as `Java.Lang.System` without
causing various C# compilation errors due to type lookup.
(Compare to Xamarin.Android's `Java.Lang.JavaSystem`, which got a
`Java*` prefix to avoid these compilation errors.)
Update `JavaInteropCodeGeneratorTests.CreateOptions()` so that C#
features such as default interface methods and nested interface types
are enabled within the unit tests.
TODO:
* When `generator --codegen-target=JavaInterop1` is used, all the
language features should also be enabled by default.
* Certain Java Annotation-related types aren't bound in
JavaInterop1, vs. XAJavaInterop1. Revisit this.
* "Revisit" use of `JNIEnv.ToLocalJniHandle()` in Xamarin.Android
bindings, and it's outright removal in JavaInterop1 bindings.
@jonpryor *thinks* the `JNIENv.ToLocalJniHandle(v)` was introduced
"in case" `v` would be collected by the GC "during" a JNI call.
Use of `GC.KeepAlive()` (1f21f38, da73d6a), would be a better
solution, but also requires auditing `generator` output.
* Bind the rest of `java.base.jmod` (bc5bcf4).
[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs01081 parent 05bfece commit 9b7edbc
File tree
70 files changed
+954
-316
lines changed- src/Java.Base
- Java.Lang
- Transforms
- tests/generator-Tests
- Integration-Tests
- Unit-Tests
- CodeGeneratorExpectedResults/JavaInterop1
- expected.ji
- Arrays
- Streams
- expected.xaji/TestInterface
- expected
- AccessModifiers
- Adapters
- Android.Graphics.Color
- Arrays
- CSharpKeywords
- Constructors
- Core_ClassParse
- Core_Jar2Xml
- EnumerationFixup
- GenericArguments
- InterfaceMethodsConflict
- NestedTypes
- NonStaticFields
- NormalMethods
- NormalProperties
- ParameterXPath
- StaticFields
- StaticMethods
- StaticProperties
- Streams
- TestInterface
- java.lang.Enum
- java.lang.Object
- java.util.List
- tools/generator
- Java.Interop.Tools.Generator.ObjectModel
- Symbols
- SourceWriters
- Extensions
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
70 files changed
+954
-316
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 5 | + | |
| 6 | + | |
15 | 7 | | |
16 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
0 commit comments