Make libjavacore independent of libnativehelper for the PDK.
Bug: 6369821
Change-Id: Ie038571a5dac1f301c0c3c6fb84df432e67b62c0
diff --git a/Android.mk b/Android.mk
index b969317..0532402 100644
--- a/Android.mk
+++ b/Android.mk
@@ -58,6 +58,7 @@
dalvik \
$(HOST_OUT)/bin/dalvikvm \
$(HOST_OUT)/bin/dexopt \
+ $(HOST_OUT)/lib/libjavacore.so \
cacerts-host \
$(HOST_OUT)/usr/share/zoneinfo/zoneinfo.dat \
$(HOST_OUT)/usr/share/zoneinfo/zoneinfo.idx \
diff --git a/NativeCode.mk b/NativeCode.mk
index bee4658..2a222b1 100644
--- a/NativeCode.mk
+++ b/NativeCode.mk
@@ -87,7 +87,7 @@
# Define the rules.
LOCAL_SRC_FILES := $(core_src_files)
LOCAL_C_INCLUDES := $(core_c_includes)
-LOCAL_SHARED_LIBRARIES := $(core_shared_libraries)
+LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libexpat libicuuc libicui18n libssl libcrypto libz libnativehelper
LOCAL_STATIC_LIBRARIES := $(core_static_libraries)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libjavacore
@@ -95,7 +95,7 @@
LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include
LOCAL_SHARED_LIBRARIES += libstlport
-include $(BUILD_STATIC_LIBRARY)
+include $(BUILD_SHARED_LIBRARY)
#
# Build for the host.
@@ -106,9 +106,12 @@
# Define the rules.
LOCAL_SRC_FILES := $(core_src_files)
LOCAL_CFLAGS += $(core_cflags)
- LOCAL_CPPFLAGS += $(core_cppflags)
LOCAL_C_INCLUDES := $(core_c_includes)
+ LOCAL_CPPFLAGS += $(core_cppflags)
+ LOCAL_LDLIBS += -ldl -lpthread
LOCAL_MODULE_TAGS := optional
- LOCAL_MODULE := libjavacore-host
- include $(BUILD_HOST_STATIC_LIBRARY)
+ LOCAL_MODULE := libjavacore
+ LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libexpat libicuuc libicui18n libssl libcrypto libz-host
+ LOCAL_STATIC_LIBRARIES := $(core_static_libraries)
+ include $(BUILD_HOST_SHARED_LIBRARY)
endif
diff --git a/luni/src/main/native/Register.cpp b/luni/src/main/native/Register.cpp
index c242895..36abd7b 100644
--- a/luni/src/main/native/Register.cpp
+++ b/luni/src/main/native/Register.cpp
@@ -21,93 +21,56 @@
#include <stdlib.h>
-extern int register_java_io_Console(JNIEnv* env);
-extern int register_java_io_File(JNIEnv* env);
-extern int register_java_io_ObjectStreamClass(JNIEnv* env);
-extern int register_java_lang_Character(JNIEnv* env);
-extern int register_java_lang_Math(JNIEnv* env);
-extern int register_java_lang_ProcessManager(JNIEnv* env);
-extern int register_java_lang_RealToString(JNIEnv* env);
-extern int register_java_lang_StrictMath(JNIEnv* env);
-extern int register_java_lang_StringToReal(JNIEnv* env);
-extern int register_java_lang_System(JNIEnv* env);
-extern int register_java_math_NativeBN(JNIEnv* env);
-extern int register_java_nio_ByteOrder(JNIEnv* env);
-extern int register_java_nio_charset_Charsets(JNIEnv* env);
-extern int register_java_text_Bidi(JNIEnv* env);
-extern int register_java_util_regex_Matcher(JNIEnv* env);
-extern int register_java_util_regex_Pattern(JNIEnv* env);
-extern int register_java_util_zip_Adler32(JNIEnv* env);
-extern int register_java_util_zip_CRC32(JNIEnv* env);
-extern int register_java_util_zip_Deflater(JNIEnv* env);
-extern int register_java_util_zip_Inflater(JNIEnv* env);
-extern int register_libcore_icu_ICU(JNIEnv* env);
-extern int register_libcore_icu_NativeBreakIterator(JNIEnv* env);
-extern int register_libcore_icu_NativeCollation(JNIEnv* env);
-extern int register_libcore_icu_NativeConverter(JNIEnv* env);
-extern int register_libcore_icu_NativeDecimalFormat(JNIEnv* env);
-extern int register_libcore_icu_NativeIDN(JNIEnv* env);
-extern int register_libcore_icu_NativeNormalizer(JNIEnv* env);
-extern int register_libcore_icu_NativePluralRules(JNIEnv* env);
-extern int register_libcore_icu_TimeZones(JNIEnv* env);
-extern int register_libcore_io_AsynchronousCloseMonitor(JNIEnv* env);
-extern int register_libcore_io_Memory(JNIEnv* env);
-extern int register_libcore_io_OsConstants(JNIEnv* env);
-extern int register_libcore_io_Posix(JNIEnv* env);
-extern int register_libcore_net_RawSocket(JNIEnv* env);
-extern int register_org_apache_harmony_dalvik_NativeTestTarget(JNIEnv* env);
-extern int register_org_apache_harmony_xml_ExpatParser(JNIEnv* env);
-extern int register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(JNIEnv* env);
-
// DalvikVM calls this on startup, so we can statically register all our native methods.
-int registerCoreLibrariesJni(JNIEnv* env) {
+int JNI_OnLoad(JavaVM* vm, void*) {
+ JNIEnv* env;
+ if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
+ ALOGE("JavaVM::GetEnv() failed");
+ abort();
+ }
+
ScopedLocalFrame localFrame(env);
JniConstants::init(env);
- bool result =
- register_java_io_Console(env) != -1 &&
- register_java_io_File(env) != -1 &&
- register_java_io_ObjectStreamClass(env) != -1 &&
- register_java_lang_Character(env) != -1 &&
- register_java_lang_Math(env) != -1 &&
- register_java_lang_ProcessManager(env) != -1 &&
- register_java_lang_RealToString(env) != -1 &&
- register_java_lang_StrictMath(env) != -1 &&
- register_java_lang_StringToReal(env) != -1 &&
- register_java_lang_System(env) != -1 &&
- register_java_math_NativeBN(env) != -1 &&
- register_java_nio_ByteOrder(env) != -1 &&
- register_java_nio_charset_Charsets(env) != -1 &&
- register_java_text_Bidi(env) != -1 &&
- register_java_util_regex_Matcher(env) != -1 &&
- register_java_util_regex_Pattern(env) != -1 &&
- register_java_util_zip_Adler32(env) != -1 &&
- register_java_util_zip_CRC32(env) != -1 &&
- register_java_util_zip_Deflater(env) != -1 &&
- register_java_util_zip_Inflater(env) != -1 &&
- register_libcore_icu_ICU(env) != -1 &&
- register_libcore_icu_NativeBreakIterator(env) != -1 &&
- register_libcore_icu_NativeCollation(env) != -1 &&
- register_libcore_icu_NativeConverter(env) != -1 &&
- register_libcore_icu_NativeDecimalFormat(env) != -1 &&
- register_libcore_icu_NativeIDN(env) != -1 &&
- register_libcore_icu_NativeNormalizer(env) != -1 &&
- register_libcore_icu_NativePluralRules(env) != -1 &&
- register_libcore_icu_TimeZones(env) != -1 &&
- register_libcore_io_AsynchronousCloseMonitor(env) != -1 &&
- register_libcore_io_Memory(env) != -1 &&
- register_libcore_io_OsConstants(env) != -1 &&
- register_libcore_io_Posix(env) != -1 &&
- register_libcore_net_RawSocket(env) != -1 &&
- register_org_apache_harmony_dalvik_NativeTestTarget(env) != -1 &&
- register_org_apache_harmony_xml_ExpatParser(env) != -1 &&
- register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(env) != -1 &&
- true;
-
- if (!result) {
- ALOGE("Failed to initialize the core libraries; aborting...");
- abort();
- }
- return 0;
+#define REGISTER(FN) extern void FN(JNIEnv*); FN(env)
+ REGISTER(register_java_io_Console);
+ REGISTER(register_java_io_File);
+ REGISTER(register_java_io_ObjectStreamClass);
+ REGISTER(register_java_lang_Character);
+ REGISTER(register_java_lang_Math);
+ REGISTER(register_java_lang_ProcessManager);
+ REGISTER(register_java_lang_RealToString);
+ REGISTER(register_java_lang_StrictMath);
+ REGISTER(register_java_lang_StringToReal);
+ REGISTER(register_java_lang_System);
+ REGISTER(register_java_math_NativeBN);
+ REGISTER(register_java_nio_ByteOrder);
+ REGISTER(register_java_nio_charset_Charsets);
+ REGISTER(register_java_text_Bidi);
+ REGISTER(register_java_util_regex_Matcher);
+ REGISTER(register_java_util_regex_Pattern);
+ REGISTER(register_java_util_zip_Adler32);
+ REGISTER(register_java_util_zip_CRC32);
+ REGISTER(register_java_util_zip_Deflater);
+ REGISTER(register_java_util_zip_Inflater);
+ REGISTER(register_libcore_icu_ICU);
+ REGISTER(register_libcore_icu_NativeBreakIterator);
+ REGISTER(register_libcore_icu_NativeCollation);
+ REGISTER(register_libcore_icu_NativeConverter);
+ REGISTER(register_libcore_icu_NativeDecimalFormat);
+ REGISTER(register_libcore_icu_NativeIDN);
+ REGISTER(register_libcore_icu_NativeNormalizer);
+ REGISTER(register_libcore_icu_NativePluralRules);
+ REGISTER(register_libcore_icu_TimeZones);
+ REGISTER(register_libcore_io_AsynchronousCloseMonitor);
+ REGISTER(register_libcore_io_Memory);
+ REGISTER(register_libcore_io_OsConstants);
+ REGISTER(register_libcore_io_Posix);
+ REGISTER(register_libcore_net_RawSocket);
+ REGISTER(register_org_apache_harmony_dalvik_NativeTestTarget);
+ REGISTER(register_org_apache_harmony_xml_ExpatParser);
+ REGISTER(register_org_apache_harmony_xnet_provider_jsse_NativeCrypto);
+#undef REGISTER
+ return JNI_VERSION_1_6;
}
diff --git a/luni/src/main/native/java_io_Console.cpp b/luni/src/main/native/java_io_Console.cpp
index 9150fb7..512bc72 100644
--- a/luni/src/main/native/java_io_Console.cpp
+++ b/luni/src/main/native/java_io_Console.cpp
@@ -46,6 +46,6 @@
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(Console, setEchoImpl, "(ZI)I"),
};
-int register_java_io_Console(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/io/Console", gMethods, NELEM(gMethods));
+void register_java_io_Console(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/io/Console", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_io_File.cpp b/luni/src/main/native/java_io_File.cpp
index 3cc76e6..ba1f55a 100644
--- a/luni/src/main/native/java_io_File.cpp
+++ b/luni/src/main/native/java_io_File.cpp
@@ -168,6 +168,6 @@
NATIVE_METHOD(File, realpath, "(Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(File, setLastModifiedImpl, "(Ljava/lang/String;J)Z"),
};
-int register_java_io_File(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/io/File", gMethods, NELEM(gMethods));
+void register_java_io_File(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/io/File", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_io_ObjectStreamClass.cpp b/luni/src/main/native/java_io_ObjectStreamClass.cpp
index 721136e..f6bd560 100644
--- a/luni/src/main/native/java_io_ObjectStreamClass.cpp
+++ b/luni/src/main/native/java_io_ObjectStreamClass.cpp
@@ -63,6 +63,6 @@
NATIVE_METHOD(ObjectStreamClass, hasClinit, "(Ljava/lang/Class;)Z"),
NATIVE_METHOD(ObjectStreamClass, newInstance, "(Ljava/lang/Class;I)Ljava/lang/Object;"),
};
-int register_java_io_ObjectStreamClass(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/io/ObjectStreamClass", gMethods, NELEM(gMethods));
+void register_java_io_ObjectStreamClass(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/io/ObjectStreamClass", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_lang_Character.cpp b/luni/src/main/native/java_lang_Character.cpp
index 2ec029e..7dbef90 100644
--- a/luni/src/main/native/java_lang_Character.cpp
+++ b/luni/src/main/native/java_lang_Character.cpp
@@ -160,6 +160,6 @@
NATIVE_METHOD(Character, toTitleCaseImpl, "!(I)I"),
NATIVE_METHOD(Character, toUpperCaseImpl, "!(I)I"),
};
-int register_java_lang_Character(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/lang/Character", gMethods, NELEM(gMethods));
+void register_java_lang_Character(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/lang/Character", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_lang_Math.cpp b/luni/src/main/native/java_lang_Math.cpp
index 4a41af2..273820e 100644
--- a/luni/src/main/native/java_lang_Math.cpp
+++ b/luni/src/main/native/java_lang_Math.cpp
@@ -131,6 +131,6 @@
NATIVE_METHOD(Math, tanh, "!(D)D"),
};
-int register_java_lang_Math(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/lang/Math", gMethods, NELEM(gMethods));
+void register_java_lang_Math(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/lang/Math", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_lang_ProcessManager.cpp b/luni/src/main/native/java_lang_ProcessManager.cpp
index c5efea2..6302d13 100644
--- a/luni/src/main/native/java_lang_ProcessManager.cpp
+++ b/luni/src/main/native/java_lang_ProcessManager.cpp
@@ -265,6 +265,6 @@
static JNINativeMethod methods[] = {
NATIVE_METHOD(ProcessManager, exec, "([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Z)I"),
};
-int register_java_lang_ProcessManager(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/lang/ProcessManager", methods, NELEM(methods));
+void register_java_lang_ProcessManager(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/lang/ProcessManager", methods, NELEM(methods));
}
diff --git a/luni/src/main/native/java_lang_RealToString.cpp b/luni/src/main/native/java_lang_RealToString.cpp
index 835151e..7036fe8 100644
--- a/luni/src/main/native/java_lang_RealToString.cpp
+++ b/luni/src/main/native/java_lang_RealToString.cpp
@@ -237,6 +237,6 @@
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(RealToString, bigIntDigitGenerator, "(JIZI)V"),
};
-int register_java_lang_RealToString(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/lang/RealToString", gMethods, NELEM(gMethods));
+void register_java_lang_RealToString(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/lang/RealToString", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_lang_StrictMath.cpp b/luni/src/main/native/java_lang_StrictMath.cpp
index 6df3f01..959ddc6 100644
--- a/luni/src/main/native/java_lang_StrictMath.cpp
+++ b/luni/src/main/native/java_lang_StrictMath.cpp
@@ -145,6 +145,6 @@
NATIVE_METHOD(StrictMath, tanh, "!(D)D"),
};
-int register_java_lang_StrictMath(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/lang/StrictMath", gMethods, NELEM(gMethods));
+void register_java_lang_StrictMath(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/lang/StrictMath", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_lang_StringToReal.cpp b/luni/src/main/native/java_lang_StringToReal.cpp
index 5dc096e..d401e65 100644
--- a/luni/src/main/native/java_lang_StringToReal.cpp
+++ b/luni/src/main/native/java_lang_StringToReal.cpp
@@ -1008,6 +1008,6 @@
NATIVE_METHOD(StringToReal, parseFltImpl, "(Ljava/lang/String;I)F"),
NATIVE_METHOD(StringToReal, parseDblImpl, "(Ljava/lang/String;I)D"),
};
-int register_java_lang_StringToReal(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/lang/StringToReal", gMethods, NELEM(gMethods));
+void register_java_lang_StringToReal(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/lang/StringToReal", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_lang_System.cpp b/luni/src/main/native/java_lang_System.cpp
index 33f418d..8cfd070 100644
--- a/luni/src/main/native/java_lang_System.cpp
+++ b/luni/src/main/native/java_lang_System.cpp
@@ -88,6 +88,6 @@
NATIVE_METHOD(System, setFieldImpl, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V"),
NATIVE_METHOD(System, specialProperties, "()[Ljava/lang/String;"),
};
-int register_java_lang_System(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/lang/System", gMethods, NELEM(gMethods));
+void register_java_lang_System(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/lang/System", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_math_NativeBN.cpp b/luni/src/main/native/java_math_NativeBN.cpp
index f6a3590..5e111d7 100644
--- a/luni/src/main/native/java_math_NativeBN.cpp
+++ b/luni/src/main/native/java_math_NativeBN.cpp
@@ -553,6 +553,6 @@
NATIVE_METHOD(NativeBN, sign, "(I)I"),
NATIVE_METHOD(NativeBN, twosComp2bn, "([BII)Z"),
};
-int register_java_math_NativeBN(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/math/NativeBN", gMethods, NELEM(gMethods));
+void register_java_math_NativeBN(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/math/NativeBN", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_nio_ByteOrder.cpp b/luni/src/main/native/java_nio_ByteOrder.cpp
index b1695a9..3269bc2 100644
--- a/luni/src/main/native/java_nio_ByteOrder.cpp
+++ b/luni/src/main/native/java_nio_ByteOrder.cpp
@@ -27,6 +27,6 @@
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(ByteOrder, isLittleEndian, "!()Z"),
};
-int register_java_nio_ByteOrder(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/nio/ByteOrder", gMethods, NELEM(gMethods));
+void register_java_nio_ByteOrder(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/nio/ByteOrder", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_nio_charset_Charsets.cpp b/luni/src/main/native/java_nio_charset_Charsets.cpp
index 22422fe..a49ba22 100644
--- a/luni/src/main/native/java_nio_charset_Charsets.cpp
+++ b/luni/src/main/native/java_nio_charset_Charsets.cpp
@@ -245,6 +245,6 @@
NATIVE_METHOD(Charsets, toIsoLatin1Bytes, "([CII)[B"),
NATIVE_METHOD(Charsets, toUtf8Bytes, "([CII)[B"),
};
-int register_java_nio_charset_Charsets(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/nio/charset/Charsets", gMethods, NELEM(gMethods));
+void register_java_nio_charset_Charsets(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/nio/charset/Charsets", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_text_Bidi.cpp b/luni/src/main/native/java_text_Bidi.cpp
index 27d3ddb..93c02bb 100644
--- a/luni/src/main/native/java_text_Bidi.cpp
+++ b/luni/src/main/native/java_text_Bidi.cpp
@@ -187,6 +187,6 @@
NATIVE_METHOD(Bidi, ubidi_setLine, "(JII)J"),
NATIVE_METHOD(Bidi, ubidi_setPara, "(J[CII[B)V"),
};
-int register_java_text_Bidi(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/text/Bidi", gMethods, NELEM(gMethods));
+void register_java_text_Bidi(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/text/Bidi", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_util_regex_Matcher.cpp b/luni/src/main/native/java_util_regex_Matcher.cpp
index 024a6f0..0f91bd5 100644
--- a/luni/src/main/native/java_util_regex_Matcher.cpp
+++ b/luni/src/main/native/java_util_regex_Matcher.cpp
@@ -211,6 +211,6 @@
NATIVE_METHOD(Matcher, useAnchoringBoundsImpl, "(IZ)V"),
NATIVE_METHOD(Matcher, useTransparentBoundsImpl, "(IZ)V"),
};
-int register_java_util_regex_Matcher(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/util/regex/Matcher", gMethods, NELEM(gMethods));
+void register_java_util_regex_Matcher(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/util/regex/Matcher", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_util_regex_Pattern.cpp b/luni/src/main/native/java_util_regex_Pattern.cpp
index 1e0e1e3..cad154f 100644
--- a/luni/src/main/native/java_util_regex_Pattern.cpp
+++ b/luni/src/main/native/java_util_regex_Pattern.cpp
@@ -95,6 +95,6 @@
NATIVE_METHOD(Pattern, closeImpl, "(I)V"),
NATIVE_METHOD(Pattern, compileImpl, "(Ljava/lang/String;I)I"),
};
-int register_java_util_regex_Pattern(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/util/regex/Pattern", gMethods, NELEM(gMethods));
+void register_java_util_regex_Pattern(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/util/regex/Pattern", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_util_zip_Adler32.cpp b/luni/src/main/native/java_util_zip_Adler32.cpp
index d0c96ea..9358f26 100644
--- a/luni/src/main/native/java_util_zip_Adler32.cpp
+++ b/luni/src/main/native/java_util_zip_Adler32.cpp
@@ -40,6 +40,6 @@
NATIVE_METHOD(Adler32, updateImpl, "([BIIJ)J"),
NATIVE_METHOD(Adler32, updateByteImpl, "(IJ)J"),
};
-int register_java_util_zip_Adler32(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/util/zip/Adler32", gMethods, NELEM(gMethods));
+void register_java_util_zip_Adler32(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/util/zip/Adler32", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_util_zip_CRC32.cpp b/luni/src/main/native/java_util_zip_CRC32.cpp
index ecfde7f..502a4ecf 100644
--- a/luni/src/main/native/java_util_zip_CRC32.cpp
+++ b/luni/src/main/native/java_util_zip_CRC32.cpp
@@ -40,6 +40,6 @@
NATIVE_METHOD(CRC32, updateImpl, "([BIIJ)J"),
NATIVE_METHOD(CRC32, updateByteImpl, "(BJ)J"),
};
-int register_java_util_zip_CRC32(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/util/zip/CRC32", gMethods, NELEM(gMethods));
+void register_java_util_zip_CRC32(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/util/zip/CRC32", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_util_zip_Deflater.cpp b/luni/src/main/native/java_util_zip_Deflater.cpp
index 82d081b..e129134 100644
--- a/luni/src/main/native/java_util_zip_Deflater.cpp
+++ b/luni/src/main/native/java_util_zip_Deflater.cpp
@@ -146,6 +146,6 @@
NATIVE_METHOD(Deflater, setInputImpl, "([BIIJ)V"),
NATIVE_METHOD(Deflater, setLevelsImpl, "(IIJ)V"),
};
-int register_java_util_zip_Deflater(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/util/zip/Deflater", gMethods, NELEM(gMethods));
+void register_java_util_zip_Deflater(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/util/zip/Deflater", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/java_util_zip_Inflater.cpp b/luni/src/main/native/java_util_zip_Inflater.cpp
index 192d1b5..890c6dc 100644
--- a/luni/src/main/native/java_util_zip_Inflater.cpp
+++ b/luni/src/main/native/java_util_zip_Inflater.cpp
@@ -168,6 +168,6 @@
NATIVE_METHOD(Inflater, setFileInputImpl, "(Ljava/io/FileDescriptor;JIJ)I"),
NATIVE_METHOD(Inflater, setInputImpl, "([BIIJ)V"),
};
-int register_java_util_zip_Inflater(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "java/util/zip/Inflater", gMethods, NELEM(gMethods));
+void register_java_util_zip_Inflater(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "java/util/zip/Inflater", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_icu_ICU.cpp b/luni/src/main/native/libcore_icu_ICU.cpp
index 3f2313e..5a07694 100644
--- a/luni/src/main/native/libcore_icu_ICU.cpp
+++ b/luni/src/main/native/libcore_icu_ICU.cpp
@@ -577,7 +577,7 @@
NATIVE_METHOD(ICU, toLowerCase, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ICU, toUpperCase, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
};
-int register_libcore_icu_ICU(JNIEnv* env) {
+void register_libcore_icu_ICU(JNIEnv* env) {
std::string path;
path = u_getDataDirectory();
path += "/";
@@ -586,11 +586,11 @@
#define FAIL_WITH_STRERROR(s) \
ALOGE("Couldn't " s " '%s': %s", path.c_str(), strerror(errno)); \
- return -1;
+ abort();
#define MAYBE_FAIL_WITH_ICU_ERROR(s) \
if (status != U_ZERO_ERROR) {\
ALOGE("Couldn't initialize ICU (" s "): %s (%s)", u_errorName(status), path.c_str()); \
- return -1; \
+ abort(); \
}
// Open the file and get its length.
@@ -627,5 +627,5 @@
// and bail.
u_init(&status);
MAYBE_FAIL_WITH_ICU_ERROR("u_init");
- return jniRegisterNativeMethods(env, "libcore/icu/ICU", gMethods, NELEM(gMethods));
+ jniRegisterNativeMethods(env, "libcore/icu/ICU", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_icu_NativeBreakIterator.cpp b/luni/src/main/native/libcore_icu_NativeBreakIterator.cpp
index f74822d..d93c229 100644
--- a/luni/src/main/native/libcore_icu_NativeBreakIterator.cpp
+++ b/luni/src/main/native/libcore_icu_NativeBreakIterator.cpp
@@ -220,6 +220,6 @@
NATIVE_METHOD(NativeBreakIterator, previousImpl, "(I)I"),
NATIVE_METHOD(NativeBreakIterator, setTextImpl, "(ILjava/lang/String;)V"),
};
-int register_libcore_icu_NativeBreakIterator(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/icu/NativeBreakIterator", gMethods, NELEM(gMethods));
+void register_libcore_icu_NativeBreakIterator(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/icu/NativeBreakIterator", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_icu_NativeCollation.cpp b/luni/src/main/native/libcore_icu_NativeCollation.cpp
index 26e276e..3ed49e9 100644
--- a/luni/src/main/native/libcore_icu_NativeCollation.cpp
+++ b/luni/src/main/native/libcore_icu_NativeCollation.cpp
@@ -194,6 +194,6 @@
NATIVE_METHOD(NativeCollation, setOffset, "(II)V"),
NATIVE_METHOD(NativeCollation, setText, "(ILjava/lang/String;)V"),
};
-int register_libcore_icu_NativeCollation(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/icu/NativeCollation", gMethods, NELEM(gMethods));
+void register_libcore_icu_NativeCollation(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/icu/NativeCollation", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_icu_NativeConverter.cpp b/luni/src/main/native/libcore_icu_NativeConverter.cpp
index 6a7fbc5..5b3761e 100644
--- a/luni/src/main/native/libcore_icu_NativeConverter.cpp
+++ b/luni/src/main/native/libcore_icu_NativeConverter.cpp
@@ -608,6 +608,6 @@
NATIVE_METHOD(NativeConverter, setCallbackDecode, "(JIILjava/lang/String;)I"),
NATIVE_METHOD(NativeConverter, setCallbackEncode, "(JII[B)I"),
};
-int register_libcore_icu_NativeConverter(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/icu/NativeConverter", gMethods, NELEM(gMethods));
+void register_libcore_icu_NativeConverter(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/icu/NativeConverter", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_icu_NativeDecimalFormat.cpp b/luni/src/main/native/libcore_icu_NativeDecimalFormat.cpp
index b68c822..1fe4055 100644
--- a/luni/src/main/native/libcore_icu_NativeDecimalFormat.cpp
+++ b/luni/src/main/native/libcore_icu_NativeDecimalFormat.cpp
@@ -366,6 +366,6 @@
NATIVE_METHOD(NativeDecimalFormat, setTextAttribute, "(IILjava/lang/String;)V"),
NATIVE_METHOD(NativeDecimalFormat, toPatternImpl, "(IZ)Ljava/lang/String;"),
};
-int register_libcore_icu_NativeDecimalFormat(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/icu/NativeDecimalFormat", gMethods, NELEM(gMethods));
+void register_libcore_icu_NativeDecimalFormat(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/icu/NativeDecimalFormat", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_icu_NativeIDN.cpp b/luni/src/main/native/libcore_icu_NativeIDN.cpp
index 3d0cba3..16a6e1c 100644
--- a/luni/src/main/native/libcore_icu_NativeIDN.cpp
+++ b/luni/src/main/native/libcore_icu_NativeIDN.cpp
@@ -62,6 +62,6 @@
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(NativeIDN, convertImpl, "(Ljava/lang/String;IZ)Ljava/lang/String;"),
};
-int register_libcore_icu_NativeIDN(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/icu/NativeIDN", gMethods, NELEM(gMethods));
+void register_libcore_icu_NativeIDN(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/icu/NativeIDN", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_icu_NativeNormalizer.cpp b/luni/src/main/native/libcore_icu_NativeNormalizer.cpp
index 57f31f4..58f460c 100644
--- a/luni/src/main/native/libcore_icu_NativeNormalizer.cpp
+++ b/luni/src/main/native/libcore_icu_NativeNormalizer.cpp
@@ -45,6 +45,6 @@
NATIVE_METHOD(NativeNormalizer, normalizeImpl, "(Ljava/lang/String;I)Ljava/lang/String;"),
NATIVE_METHOD(NativeNormalizer, isNormalizedImpl, "(Ljava/lang/String;I)Z"),
};
-int register_libcore_icu_NativeNormalizer(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/icu/NativeNormalizer", gMethods, NELEM(gMethods));
+void register_libcore_icu_NativeNormalizer(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/icu/NativeNormalizer", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_icu_NativePluralRules.cpp b/luni/src/main/native/libcore_icu_NativePluralRules.cpp
index 3a443d7..a7164d0 100644
--- a/luni/src/main/native/libcore_icu_NativePluralRules.cpp
+++ b/luni/src/main/native/libcore_icu_NativePluralRules.cpp
@@ -60,6 +60,6 @@
NATIVE_METHOD(NativePluralRules, forLocaleImpl, "(Ljava/lang/String;)I"),
NATIVE_METHOD(NativePluralRules, quantityForIntImpl, "(II)I"),
};
-int register_libcore_icu_NativePluralRules(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/icu/NativePluralRules", gMethods, NELEM(gMethods));
+void register_libcore_icu_NativePluralRules(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/icu/NativePluralRules", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_icu_TimeZones.cpp b/luni/src/main/native/libcore_icu_TimeZones.cpp
index 9da108d..b543238 100644
--- a/luni/src/main/native/libcore_icu_TimeZones.cpp
+++ b/luni/src/main/native/libcore_icu_TimeZones.cpp
@@ -226,6 +226,6 @@
NATIVE_METHOD(TimeZones, forCountryCode, "(Ljava/lang/String;)[Ljava/lang/String;"),
NATIVE_METHOD(TimeZones, getZoneStringsImpl, "(Ljava/lang/String;[Ljava/lang/String;)[[Ljava/lang/String;"),
};
-int register_libcore_icu_TimeZones(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/icu/TimeZones", gMethods, NELEM(gMethods));
+void register_libcore_icu_TimeZones(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/icu/TimeZones", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp b/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp
index d3fdabf..1b888be 100644
--- a/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp
+++ b/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp
@@ -30,7 +30,7 @@
NATIVE_METHOD(AsynchronousCloseMonitor, signalBlockedThreads, "(Ljava/io/FileDescriptor;)V"),
};
-int register_libcore_io_AsynchronousCloseMonitor(JNIEnv* env) {
+void register_libcore_io_AsynchronousCloseMonitor(JNIEnv* env) {
AsynchronousSocketCloseMonitor::init();
- return jniRegisterNativeMethods(env, "libcore/io/AsynchronousCloseMonitor", gMethods, NELEM(gMethods));
+ jniRegisterNativeMethods(env, "libcore/io/AsynchronousCloseMonitor", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_io_Memory.cpp b/luni/src/main/native/libcore_io_Memory.cpp
index 2200453..4f1115f 100644
--- a/luni/src/main/native/libcore_io_Memory.cpp
+++ b/luni/src/main/native/libcore_io_Memory.cpp
@@ -351,6 +351,6 @@
NATIVE_METHOD(Memory, unsafeBulkGet, "(Ljava/lang/Object;II[BIIZ)V"),
NATIVE_METHOD(Memory, unsafeBulkPut, "([BIILjava/lang/Object;IIZ)V"),
};
-int register_libcore_io_Memory(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/io/Memory", gMethods, NELEM(gMethods));
+void register_libcore_io_Memory(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/io/Memory", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_io_OsConstants.cpp b/luni/src/main/native/libcore_io_OsConstants.cpp
index 942cfce..622ce6d 100644
--- a/luni/src/main/native/libcore_io_OsConstants.cpp
+++ b/luni/src/main/native/libcore_io_OsConstants.cpp
@@ -445,6 +445,6 @@
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(OsConstants, initConstants, "()V"),
};
-int register_libcore_io_OsConstants(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/io/OsConstants", gMethods, NELEM(gMethods));
+void register_libcore_io_OsConstants(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/io/OsConstants", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_io_Posix.cpp b/luni/src/main/native/libcore_io_Posix.cpp
index 8f844b3..30ca145 100644
--- a/luni/src/main/native/libcore_io_Posix.cpp
+++ b/luni/src/main/native/libcore_io_Posix.cpp
@@ -1318,6 +1318,6 @@
NATIVE_METHOD(Posix, writeBytes, "(Ljava/io/FileDescriptor;Ljava/lang/Object;II)I"),
NATIVE_METHOD(Posix, writev, "(Ljava/io/FileDescriptor;[Ljava/lang/Object;[I[I)I"),
};
-int register_libcore_io_Posix(JNIEnv* env) {
- return jniRegisterNativeMethods(env, "libcore/io/Posix", gMethods, NELEM(gMethods));
+void register_libcore_io_Posix(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/io/Posix", gMethods, NELEM(gMethods));
}
diff --git a/luni/src/main/native/libcore_net_RawSocket.cpp b/luni/src/main/native/libcore_net_RawSocket.cpp
index 91d8ea0..4e5059f 100644
--- a/luni/src/main/native/libcore_net_RawSocket.cpp
+++ b/luni/src/main/native/libcore_net_RawSocket.cpp
@@ -204,15 +204,11 @@
}
static JNINativeMethod gRawMethods[] = {
- NATIVE_METHOD(RawSocket, create,
- "(Ljava/io/FileDescriptor;SLjava/lang/String;)V"),
- NATIVE_METHOD(RawSocket, sendPacket,
- "(Ljava/io/FileDescriptor;Ljava/lang/String;S[B[BII)I"),
- NATIVE_METHOD(RawSocket, recvPacket,
- "(Ljava/io/FileDescriptor;[BIIII)I"),
+ NATIVE_METHOD(RawSocket, create, "(Ljava/io/FileDescriptor;SLjava/lang/String;)V"),
+ NATIVE_METHOD(RawSocket, sendPacket, "(Ljava/io/FileDescriptor;Ljava/lang/String;S[B[BII)I"),
+ NATIVE_METHOD(RawSocket, recvPacket, "(Ljava/io/FileDescriptor;[BIIII)I"),
};
-int register_libcore_net_RawSocket(JNIEnv* env) {
- return jniRegisterNativeMethods(env,
- "libcore/net/RawSocket", gRawMethods, NELEM(gRawMethods));
+void register_libcore_net_RawSocket(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "libcore/net/RawSocket", gRawMethods, NELEM(gRawMethods));
}
diff --git a/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp b/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
index 3f6c1aa..d08b7d2 100644
--- a/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
+++ b/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
@@ -27,7 +27,7 @@
#include "UniquePtr.h"
#include "jni.h"
#include "cutils/log.h"
-#include "cutils/jstring.h" // for strcpylen8to16
+#include "unicode/unistr.h"
#include <string.h>
#include <expat.h>
@@ -410,26 +410,23 @@
* Copies UTF-8 characters into the buffer. Returns the number of Java chars
* which were buffered.
*
- * @param characters to copy into the buffer
- * @param length of characters to copy (in bytes)
* @returns number of UTF-16 characters which were copied
*/
-static size_t fillBuffer(ParsingContext* parsingContext, const char* characters, int length) {
+static size_t fillBuffer(ParsingContext* parsingContext, const char* utf8, int byteCount) {
JNIEnv* env = parsingContext->env;
- // Grow buffer if necessary.
- jcharArray buffer = parsingContext->ensureCapacity(length);
- if (buffer == NULL) return -1;
+ // Grow buffer if necessary (the length in bytes is always >= the length in chars).
+ jcharArray javaChars = parsingContext->ensureCapacity(byteCount);
+ if (javaChars == NULL) return -1;
- // Decode UTF-8 characters into our buffer.
- ScopedCharArrayRW nativeBuffer(env, buffer);
- if (nativeBuffer.get() == NULL) {
+ // Decode UTF-8 characters into our char[].
+ ScopedCharArrayRW chars(env, javaChars);
+ if (chars.get() == NULL) {
return -1;
}
-
- size_t utf16length;
- strcpylen8to16(nativeBuffer.get(), characters, length, &utf16length);
- return utf16length;
+ UErrorCode status = U_ZERO_ERROR;
+ UnicodeString utf16(UnicodeString::fromUTF8(StringPiece(utf8, byteCount)));
+ return utf16.extract(chars.get(), byteCount, status);
}
/**
@@ -1395,13 +1392,7 @@
NATIVE_METHOD(ExpatAttributes, getValueForQName, "(ILjava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ExpatAttributes, getValue, "(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
};
-int register_org_apache_harmony_xml_ExpatParser(JNIEnv* env) {
- int result = jniRegisterNativeMethods(env, "org/apache/harmony/xml/ExpatParser",
- parserMethods, NELEM(parserMethods));
- if (result != 0) {
- return result;
- }
-
- return jniRegisterNativeMethods(env, "org/apache/harmony/xml/ExpatAttributes",
- attributeMethods, NELEM(attributeMethods));
+void register_org_apache_harmony_xml_ExpatParser(JNIEnv* env) {
+ jniRegisterNativeMethods(env, "org/apache/harmony/xml/ExpatParser", parserMethods, NELEM(parserMethods));
+ jniRegisterNativeMethods(env, "org/apache/harmony/xml/ExpatAttributes", attributeMethods, NELEM(attributeMethods));
}
diff --git a/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp b/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
index a8bf2eb..ec9d4d6 100644
--- a/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
+++ b/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
@@ -4311,11 +4311,8 @@
NATIVE_METHOD(NativeCrypto, SSL_get_npn_negotiated_protocol, "(I)[B"),
};
-int register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(JNIEnv* env) {
+void register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(JNIEnv* env) {
JNI_TRACE("register_org_apache_harmony_xnet_provider_jsse_NativeCrypto");
// Register org.apache.harmony.xnet.provider.jsse.NativeCrypto methods
- return jniRegisterNativeMethods(env,
- "org/apache/harmony/xnet/provider/jsse/NativeCrypto",
- sNativeCryptoMethods,
- NELEM(sNativeCryptoMethods));
+ jniRegisterNativeMethods(env, "org/apache/harmony/xnet/provider/jsse/NativeCrypto", sNativeCryptoMethods, NELEM(sNativeCryptoMethods));
}
diff --git a/luni/src/main/native/sub.mk b/luni/src/main/native/sub.mk
index 9535ce6..b67348b 100644
--- a/luni/src/main/native/sub.mk
+++ b/luni/src/main/native/sub.mk
@@ -58,19 +58,9 @@
external/openssl/include \
external/zlib
-# Any shared/static libs that are listed here must also
-# be listed in libs/nativehelper/Android.mk.
-# TODO: fix this requirement
-
LOCAL_SHARED_LIBRARIES += \
- libcrypto \
- libcutils \
- libexpat \
- libicuuc \
- libicui18n \
- libssl \
- libutils \
- libz
+ liblog \
+ libnativehelper
LOCAL_STATIC_LIBRARIES += \
libfdlibm