Enable generation of default (0-arguments) constructor when extending classes
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 30/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- android, cpp, java, javascript
Rechercherichtung
Das Issue enthält Beispiele in JavaScript und Java, nennt aber keine Quelldatei, keinen Test und keinen Einstiegspunkt. Beginne damit, den Pfad zur Generierung von Konstruktoren für Klassenerweiterungen zu ermitteln; fertig ist es, wenn eine Erweiterung einer Basisklasse ohne Konstruktor ohne Argumente einen generierten Konstruktor ohne Argumente bereitstellen kann, der wie angegeben delegiert, mit Testabdeckung für den gezeigten Fall.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- C++
- Sterne
- 563
- Forks
- 144
- Ø Merge
- 10 Std. 46 Min.
- Gemergte PRs (30 T.)
- 14
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus NativeScript/android
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 38/100
NativeScript/android#2039 · 1 Kommentar ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
NativeScript/android#2024 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
NativeScript/android#2020 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 42/100
NativeScript/android#2019 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
NativeScript/android#1986 ·
Alle Issues in NativeScript/android
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
duckdb/duckdb-wasm#2258 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
objectionary/eo-graphs#75 ·
-
Coarray integration tests carry no LABELS, so run_tests.py silently skips them under every backend Offencoarray
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
FISCO-BCOS/FISCO-BCOS#5642 ·