From 922fef4a7648dbb8f11b4d43d3d63405ced89f54 Mon Sep 17 00:00:00 2001 From: andyjjrt Date: Tue, 21 Nov 2023 22:56:26 +0800 Subject: [PATCH 1/2] docs(api): Fix constructor example --- docs/source/api.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index 1e708527..03fbec64 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -51,7 +51,8 @@ Reflection classes .. attribute:: __javaconstructor__ If not set, we assume the default constructor takes no parameters. - Otherwise, it can be a list of all possible signatures of the + Otherwise, it can be a list of all possible signatures and if it can + take a variable number of arguments or not as parameters of the constructor. For example, a reflection of the String java class would look like:: @@ -59,10 +60,10 @@ Reflection classes __javaclass__ = 'java/lang/String' __metaclass__ = MetaJavaClass __javaconstructor__ = ( - '()V', - '(Ljava/lang/String;)V', - '([C)V', - '([CII)V', + ('()V', False), + ('(Ljava/lang/String;)V', False), + ('([C)V', False), + ('([CII)V', False), # ... ) From b7a4e5c4e4ce905b1be0b5d2f01e243e9c223940 Mon Sep 17 00:00:00 2001 From: andyjjrt Date: Wed, 22 Nov 2023 00:11:57 +0800 Subject: [PATCH 2/2] docs(api): Fix JavaMultipleMethod example and description --- docs/source/api.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index 03fbec64..60ca82ed 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -51,10 +51,9 @@ Reflection classes .. attribute:: __javaconstructor__ If not set, we assume the default constructor takes no parameters. - Otherwise, it can be a list of all possible signatures and if it can - take a variable number of arguments or not as parameters of the - constructor. For example, a reflection of the String java class would - look like:: + Otherwise, it can be a list of all possible signatures and if it is + varArgs or not as parameters of the constructor. For example, + a reflection of the String java class would look like:: class String(JavaClass): __javaclass__ = 'java/lang/String' @@ -153,9 +152,12 @@ Reflection classes __metaclass__ = MetaJavaClass getBytes = JavaMultipleMethod([ - '(Ljava/lang/String;)[B', - '(Ljava/nio/charset/Charset;)[B', - '()[B']) + ('(Ljava/lang/String;)[B', False, False), + ('(Ljava/nio/charset/Charset;)[B', False, False), + ('()[B', False, False)]) + + Each method should contain three informations: its signature, is static, + and is varArgs. Then, when you try to access this method, it will choose the best method available according to the type of the arguments you're using.