Enable generation of default (0-arguments) constructor when extending classes
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 30/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- android, cpp, java, javascript
研究方向
該 issue 提供了 JavaScript 和 Java 範例,但沒有指出原始檔、測試或進入點。首先定位類別擴充的建構函式產生路徑;完成的標準是:沒有無參數建構函式的基底類別之擴充能夠提供一個依指定方式委派的產生零參數建構函式,並涵蓋所示案例。
由索引模型根據 Issue 內容生成。
描述
If the developer extends a base class with no default constructor, they have no way of explicitly specifying that they want a default constructor code to be generated in Java. This is a certain limitation if the class needs to be declared in the AndroidManifest and is instantiated by the system (attempting to use IntentService is one such case - Android will attempt to create an instance of the implementation of IntentService, but will crash, as it tries to invoke a default constructor, which the developer cannot declare).
Given the following Java class:
package a.b;
public class Base {
public Base(String a) { ... }
}
and the following implementation in JavaScript:
a.b.Base.extend("a.b.ExtendedBase", {
init: function() {
_this("arbitrary string");
// -> will introduce additional logic in the sole ctor block
// in Java, but will not create an additional constructor
}
});
will output
package a.b;
@com.tns.JavaScriptImplementation(javaScriptFile = "./ExtendedBase.js")
public class ExtendedBase extends a.b.Base implements com.tns.NativeScriptHashCodeProvider {
/* No default constructor */
public ExtendedBase (java.lang.String param_0){
super(param_0);
/*
Additional logic to handle more arguments -> a result of the init function
*/
com.tns.Runtime.initInstance(this);
}
public boolean equals__super(java.lang.Object other) {
return super.equals(other);
}
public int hashCode__super() {
return super.hashCode();
}
}
Developers have no way to declare a default constructor for a.b.ExtendedBase.
Instead what I need is
package a.b;
@com.tns.JavaScriptImplementation(javaScriptFile = "./ExtendedBase.js")
public class ExtendedBase extends a.b.Base implements com.tns.NativeScriptHashCodeProvider {
/* default constructor */
public ExtendedBase () {
this("Arbitrary String");
}
public ExtendedBase (java.lang.String param_0){
super(param_0);
/*
Additional logic to handle more arguments -> a result of the init function
*/
com.tns.Runtime.initInstance(this);
}
}
Generating custom constructors based on the javascript code will require additional analysis, and may not be worth looking into at the moment.
- 主要語言
- C++
- 星號
- 563
- 分支
- 144
- 平均合併
- 10 小時 46 分鐘
- 30 天內合併 PR
- 14
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
NativeScript/android 的其他 Issue
-
難度 5/5 一週以上 新手友好度 38/100
NativeScript/android#2039 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 48/100
NativeScript/android#2024 ·
-
難度 5/5 一週以上 新手友好度 20/100
NativeScript/android#2020 ·
-
難度 5/5 一週以上 新手友好度 42/100
NativeScript/android#2019 ·
-
難度 4/5 3-5 天 新手友好度 55/100
NativeScript/android#1986 ·
查看 NativeScript/android 的全部 Issue
相似的 Issue
-
ai_reviewed
難度 2/5 1-3 小時 新手友好度 68/100
ydb-platform/ydb#53869 · 3 則留言 ·
-
bug cert blocker needs triage
難度 2/5 1-3 小時 新手友好度 82/100
project-chip/connectedhomeip#74373 ·
-
upstream update
難度 2/5 1-3 小時 新手友好度 75/100
conan-io/conan-center-index#31035 ·
-
Bug
難度 2/5 1-3 小時 新手友好度 68/100
-
documentation
難度 1/5 1 小時以內 新手友好度 85/100
vllm-project/vllm-ascend#17329 ·