Enable generation of default (0-arguments) constructor when extending classes
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- android, cpp, java, javascript
Hướng nghiên cứu
Issue cung cấp các ví dụ bằng JavaScript và Java nhưng không nêu tệp nguồn, kiểm thử hoặc điểm vào nào. Hãy bắt đầu bằng việc xác định đường dẫn tạo constructor cho các phần mở rộng lớp; công việc được xem là hoàn tất khi một phần mở rộng của lớp cơ sở không có constructor không tham số có thể cung cấp một constructor không tham số được tạo tự động, constructor này ủy quyền như đã chỉ định, kèm theo việc bao phủ trường hợp được minh họa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C++
- Star
- 563
- Fork
- 144
- Merge trung bình
- 10 giờ 46 phút
- Pull request đã merge (30 ngày)
- 14
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NativeScript/android
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
NativeScript/android#2039 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
NativeScript/android#2024 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
NativeScript/android#2020 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
NativeScript/android#2019 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
NativeScript/android#1986 ·
Tất cả issue của NativeScript/android
Issue tương tự
-
Website Doc Typo Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
autowarefoundation/autoware_universe#13413 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
automated-analysis bug memory-safety
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100