diff --git a/src/net/JNet/Developed/Java/Lang/Iterable.cs b/src/net/JNet/Developed/Java/Lang/Iterable.cs index 2c690233d7b..e9736bf3722 100644 --- a/src/net/JNet/Developed/Java/Lang/Iterable.cs +++ b/src/net/JNet/Developed/Java/Lang/Iterable.cs @@ -43,17 +43,9 @@ public class Iterable : JVMBridgeBaseEnumerable, IIterable public override string BridgeClassName => "java.lang.Iterable"; /// public override bool IsBridgeInterface => true; - /// - /// Default constructor: even if the corresponding Java class does not have one, it is mandatory for JCOBridge - /// - public Iterable() { } /// public Iterable(IJVMBridgeBaseInitializer initializer) : base(initializer) { } /// - /// Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class - /// - public Iterable(params object[] args) : base(args) { } - /// /// Returns an iterator over elements of type /// /// An @@ -84,16 +76,8 @@ public class Iterable : MASES.JNet.Specific.JNetAsyncEnumerable, public override string BridgeClassName => "java.lang.Iterable"; /// public override bool IsBridgeInterface => true; - /// - /// Default constructor: even if the corresponding Java class does not have one, it is mandatory for JCOBridge - /// - public Iterable() { } /// public Iterable(IJVMBridgeBaseInitializer initializer) : base(initializer) { } - /// - /// Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class - /// - public Iterable(params object[] args) : base(args) { } /// /// Returns an iterator over elements of type . diff --git a/src/net/JNet/Developed/Java/Util/Collection.cs b/src/net/JNet/Developed/Java/Util/Collection.cs index cd5309d7646..be42e784d4b 100644 --- a/src/net/JNet/Developed/Java/Util/Collection.cs +++ b/src/net/JNet/Developed/Java/Util/Collection.cs @@ -36,8 +36,6 @@ public partial class Collection /// public class Collection : Java.Lang.Iterable { - /// - public Collection() { } /// public Collection(IJVMBridgeBaseInitializer initializer) : base(initializer) { } /// diff --git a/src/net/JNet/Developed/Java/Util/Concurrent/ForkJoinPool.cs b/src/net/JNet/Developed/Java/Util/Concurrent/ForkJoinPool.cs index 616b6642ed7..b4df5d82630 100644 --- a/src/net/JNet/Developed/Java/Util/Concurrent/ForkJoinPool.cs +++ b/src/net/JNet/Developed/Java/Util/Concurrent/ForkJoinPool.cs @@ -34,8 +34,9 @@ public partial class ForkJoinPool /// /// public ForkJoinPool(int arg0, Java.Util.Concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory arg1, Java.Lang.Thread.UncaughtExceptionHandler arg2, bool arg3, int arg4, int arg5, int arg6, Java.Util.Function.Predicate arg7, long arg8, Java.Util.Concurrent.TimeUnit arg9) - : base(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + : base(MASES.JCOBridge.C2JBridge.JVMBridgeBase.InitializerInstance) { + InvokeInitializer(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); } /// /// @@ -45,8 +46,9 @@ public ForkJoinPool(int arg0, Java.Util.Concurrent.ForkJoinPool.ForkJoinWorkerTh /// /// public ForkJoinPool(int arg0, Java.Util.Concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory arg1, Java.Lang.Thread.UncaughtExceptionHandler arg2, bool arg3) - : base(arg0, arg1, arg2, arg3) + : base(MASES.JCOBridge.C2JBridge.JVMBridgeBase.InitializerInstance) { + InvokeInitializer(arg0, arg1, arg2, arg3); } } } diff --git a/src/net/JNet/Developed/Java/Util/Iterator.cs b/src/net/JNet/Developed/Java/Util/Iterator.cs index 91a46ee9016..11668fdff16 100644 --- a/src/net/JNet/Developed/Java/Util/Iterator.cs +++ b/src/net/JNet/Developed/Java/Util/Iterator.cs @@ -31,17 +31,9 @@ public partial class Iterator : MASES.JCOBridge.C2JBridge.JVMBridgeBase "java.util.Iterator"; /// public override bool IsBridgeInterface => true; - /// - /// Default constructor: even if the corresponding Java class does not have one, it is mandatory for JCOBridge - /// - public Iterator() { } /// public Iterator(IJVMBridgeBaseInitializer initializer) : base(initializer) { } /// - /// Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class - /// - public Iterator(params object[] args) : base(args) { } - /// /// /// public bool HasNext() => IExecute("hasNext"); @@ -106,17 +98,9 @@ public partial class Iterator : JVMBridgeBase>, IIterator public override string BridgeClassName => "java.util.Iterator"; /// public override bool IsBridgeInterface => true; - /// - /// Default constructor: even if the corresponding Java class does not have one, it is mandatory for JCOBridge - /// - public Iterator() { } /// public Iterator(IJVMBridgeBaseInitializer initializer) : base(initializer) { } /// - /// Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class - /// - public Iterator(params object[] args) : base(args) { } - /// /// Converts an to a /// public static implicit operator JVMBridgeBaseEnumerator(Iterator it) => new JVMBridgeBaseEnumerator(it.BridgeInstance); diff --git a/src/net/JNet/Specific/AsyncEnumerable.cs b/src/net/JNet/Specific/AsyncEnumerable.cs index b4baba2711d..e47d4f5b8b8 100644 --- a/src/net/JNet/Specific/AsyncEnumerable.cs +++ b/src/net/JNet/Specific/AsyncEnumerable.cs @@ -84,20 +84,9 @@ public ValueTask MoveNextAsync() public abstract class JNetAsyncEnumerable : JVMBridgeBaseEnumerable, IAsyncEnumerable where TClass : class, IJVMBridgeBase { - /// - /// Create an instance of - /// - public JNetAsyncEnumerable() { } /// public JNetAsyncEnumerable(IJVMBridgeBaseInitializer initializer) : base(initializer) { } - /// - /// Create an instance of - /// - /// The arguments to send to base class - public JNetAsyncEnumerable(params object[] args) - : base(args) - { - } + /// public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) { diff --git a/src/net/JNetReflector/Templates/AllPackageClassesStubClass.template b/src/net/JNetReflector/Templates/AllPackageClassesStubClass.template index 2aeccbe894f..b7d1a75a55c 100644 --- a/src/net/JNetReflector/Templates/AllPackageClassesStubClass.template +++ b/src/net/JNetReflector/Templates/AllPackageClassesStubClass.template @@ -10,11 +10,6 @@ public partial class ALLPACKAGE_CLASSES_STUB_CLASS_PLACEHOLDER : ALLPACKAGE_CLAS [global::System.Obsolete("This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")] public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(IJVMBridgeBaseInitializer initializer) : base(initializer) { } - /// - /// Generic constructor used by JCOBridge when a derived class needs to forward arguments to the base JVMBridgeBase class. - /// - public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(params object[] args) : base(args) { } - private static readonly global::System.Exception _LocalBridgeClazzException = null; private static readonly MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType _LocalBridgeClazz = JVMBridgeBase.ClazzOf(_bridgeClassName, out _LocalBridgeClazzException, false); private static MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType LocalBridgeClazz => _LocalBridgeClazz ?? throw _LocalBridgeClazzException ?? new global::System.InvalidOperationException($"Class {_bridgeClassName} was not found."); diff --git a/src/net/JNetReflector/Templates/AllPackageClassesStubClassInterfaceOrAbstract.template b/src/net/JNetReflector/Templates/AllPackageClassesStubClassInterfaceOrAbstract.template index edef42659f8..b7d1a75a55c 100644 --- a/src/net/JNetReflector/Templates/AllPackageClassesStubClassInterfaceOrAbstract.template +++ b/src/net/JNetReflector/Templates/AllPackageClassesStubClassInterfaceOrAbstract.template @@ -10,16 +10,6 @@ public partial class ALLPACKAGE_CLASSES_STUB_CLASS_PLACEHOLDER : ALLPACKAGE_CLAS [global::System.Obsolete("This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")] public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(IJVMBridgeBaseInitializer initializer) : base(initializer) { } - /// - /// Generic constructor used by JCOBridge when a derived class needs to forward arguments to the base JVMBridgeBase class. - /// - /// - /// represents a JVM interface or abstract class in .NET. - /// Instantiating it directly outside of JCOBridge infrastructure is not supported and may produce undefined behavior. - /// - [global::System.Obsolete("ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER class represents, in .NET, an instance of a JVM interface or abstract class. This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")] - public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(params object[] args) : base(args) { } - private static readonly global::System.Exception _LocalBridgeClazzException = null; private static readonly MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType _LocalBridgeClazz = JVMBridgeBase.ClazzOf(_bridgeClassName, out _LocalBridgeClazzException, false); private static MASES.JCOBridge.C2JBridge.JVMInterop.IJavaType LocalBridgeClazz => _LocalBridgeClazz ?? throw _LocalBridgeClazzException ?? new global::System.InvalidOperationException($"Class {_bridgeClassName} was not found."); diff --git a/src/net/JNetReflector/Templates/SingleConstructor.template b/src/net/JNetReflector/Templates/SingleConstructor.template index 2d0473c59fb..db478a76630 100644 --- a/src/net/JNetReflector/Templates/SingleConstructor.template +++ b/src/net/JNetReflector/Templates/SingleConstructor.template @@ -1,5 +1,5 @@ CONSTRUCTOR_STUB_CONSTRUCTOR_DECORATION_PLACEHOLDER -publicCONSTRUCTOR_STUB_MODIFIER_PLACEHOLDER CONSTRUCTOR_STUB_CONSTRUCTOR_NAME_PLACEHOLDER(CONSTRUCTOR_STUB_PARAMETERS_PLACEHOLDER) - : base(CONSTRUCTOR_STUB_EXECUTION_PLACEHOLDER) +publicCONSTRUCTOR_STUB_MODIFIER_PLACEHOLDER CONSTRUCTOR_STUB_CONSTRUCTOR_NAME_PLACEHOLDER(CONSTRUCTOR_STUB_PARAMETERS_PLACEHOLDER) : base(JVMBridgeBase.InitializerInstance) { + InvokeInitializer(CONSTRUCTOR_STUB_EXECUTION_PLACEHOLDER); } \ No newline at end of file diff --git a/tests/net/JNetTest/Program.cs b/tests/net/JNetTest/Program.cs index 737daba7a17..ee5e2b9320e 100644 --- a/tests/net/JNetTest/Program.cs +++ b/tests/net/JNetTest/Program.cs @@ -614,7 +614,7 @@ static void TestExtensions() if (printVerbose) System.Console.WriteLine($"{tuple.Item1} Elapsed ticks: {w.Elapsed.Ticks}"); w.Restart(); - Java.Util.ArrayList alist = new Java.Util.ArrayList(); + Java.Util.ArrayList alist = new(); for (int i = 0; i < elementsInexecution; i++) { alist.Add(i); @@ -640,7 +640,7 @@ static void TestExtensions() w.Restart(); var tmpJList = JNetHelper.ListFrom(tmpArray); - alist = new Java.Util.ArrayList(tmpJList); + Java.Util.ArrayList rawArraylist = new(tmpJList); w.Stop(); tuple = new System.Tuple("Java.Util.ArrayList from array", w.Elapsed.Ticks); singleExecutionData.Add(tuple); @@ -663,7 +663,7 @@ static void TestExtensions() w.Restart(); var tmpJList3 = JNetHelper.ListFrom(tmpArray, true); - alist = new Java.Util.ArrayList(tmpJList3); + rawArraylist = new Java.Util.ArrayList(tmpJList3); w.Stop(); tuple = new System.Tuple("Java.Util.ArrayList from raw array buffered", w.Elapsed.Ticks); singleExecutionData.Add(tuple);