/* *Copyright(C)2015TheAndroidOpenSourceProject * *LicensedundertheApacheLicense,Version2.0(the"License"); *youmaynotusethisfileexceptincompliancewiththeLicense. *YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting,software *distributedundertheLicenseisdistributedonan"ASIS"BASIS, *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. *SeetheLicenseforthespecificlanguagegoverningpermissionsand *limitationsundertheLicense.
*/ class Main extends Impl implements Iface { publicstaticvoid main(String[] args) {
System.loadLibrary(args[0]);
System.out.println("Create Main instance");
Main m = new Main();
callMain(m);
}
publicstaticvoid callMain(Main m) {
System.out.println("Test method with concrete implementation");
m.test_correct();
System.out.println("Test method with concrete implementation via JNI call"); long iface_id = GetMethodId(false, Iface.class, "test_correct", "()V"); long main_id = GetMethodId(false, Main.class, "test_correct", "()V"); long impl_id = GetMethodId(false, Impl.class, "test_correct", "()V"); if (iface_id != main_id) {
System.out.println("Abstract interface and Main have different method ids");
} else {
System.out.println("Unexpected: Abstract interface and Main have same method ids");
}
CallNonvirtual(m, Main.class, main_id);
System.out.println("Test method with no concrete implementation"); try {
m.test_throws();
} catch (AbstractMethodError e) {
System.out.println("Expected AME Thrown on Main");
} long iface_throws_id = GetMethodId(false, Iface.class, "test_throws", "()V"); long main_throws_id = GetMethodId(false, Main.class, "test_throws", "()V"); try { long id = GetMethodId(false, Impl.class, "test_throws", "()V");
} catch (NoSuchMethodError e) {
System.out.println("Expected NoSuchMethodError on Main");
} if (iface_throws_id == main_throws_id) {
System.out.println("Abstract interface and Main have same method ids");
} else {
System.out.println("Unexpected: Abstract interface and Main have different method ids");
}
try {
CallNonvirtual(m, Main.class, main_throws_id);
} catch (AbstractMethodError e) {
System.out.println("Expected AME Thrown on Main via JNI call");
} return;
}
privatestaticnativelong GetMethodId(boolean is_static, Class k, String name, String sig); privatestaticnativelong CallNonvirtual(Object obj, Class k, long methodid);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.