diff options
5 files changed, 20 insertions, 92 deletions
diff --git a/archive/src/main/native/java_util_zip_Adler32.c b/archive/src/main/native/java_util_zip_Adler32.c index 1b02a11..0fcf549 100644 --- a/archive/src/main/native/java_util_zip_Adler32.c +++ b/archive/src/main/native/java_util_zip_Adler32.c @@ -25,16 +25,11 @@ Java_java_util_zip_Adler32_updateImpl (JNIEnv * env, jobject recv, jbyteArray buf, int off, int len, jlong crc) { - jbyte *b; - jboolean isCopy; - jlong result; - - b = (*env)->GetPrimitiveArrayCritical (env, buf, &isCopy); + jbyte* b = (*env)->GetPrimitiveArrayCritical (env, buf, NULL); if (b == NULL) { - throwNewOutOfMemoryError(env, ""); return 0; } - result = (jlong) adler32 ((uLong) crc, (Bytef *) (b + off), (uInt) len); + jlong result = (jlong) adler32 ((uLong) crc, (Bytef *) (b + off), (uInt) len); (*env)->ReleasePrimitiveArrayCritical (env, buf, b, JNI_ABORT); return result; diff --git a/archive/src/main/native/java_util_zip_CRC32.c b/archive/src/main/native/java_util_zip_CRC32.c index cee25e5..fe50fca 100644 --- a/archive/src/main/native/java_util_zip_CRC32.c +++ b/archive/src/main/native/java_util_zip_CRC32.c @@ -25,15 +25,11 @@ Java_java_util_zip_CRC32_updateImpl (JNIEnv * env, jobject recv, jbyteArray buf, int off, int len, jlong crc) { - jbyte *b; - jlong result; - - b = ((*env)->GetPrimitiveArrayCritical (env, buf, 0)); + jbyte* b = ((*env)->GetPrimitiveArrayCritical (env, buf, 0)); if (b == NULL) { - throwNewOutOfMemoryError(env, ""); return -1; } - result = crc32 ((uLong) crc, (Bytef *) (b + off), (uInt) len); + jlong result = crc32 ((uLong) crc, (Bytef *) (b + off), (uInt) len); ((*env)->ReleasePrimitiveArrayCritical (env, buf, b, JNI_ABORT)); return result; } diff --git a/luni/src/main/native/org_apache_harmony_luni_platform_OSFileSystem.cpp b/luni/src/main/native/org_apache_harmony_luni_platform_OSFileSystem.cpp index 38f3d36..6a9ab9d 100644 --- a/luni/src/main/native/org_apache_harmony_luni_platform_OSFileSystem.cpp +++ b/luni/src/main/native/org_apache_harmony_luni_platform_OSFileSystem.cpp @@ -337,16 +337,12 @@ static jlong harmony_io_writeDirectImpl(JNIEnv * env, jobject thiz, jint fd, static jlong harmony_io_readImpl(JNIEnv * env, jobject thiz, jint fd, jbyteArray byteArray, jint offset, jint nbytes) { - jboolean isCopy; - jbyte *bytes; - jlong result; - if (nbytes == 0) { return 0; } - bytes = env->GetByteArrayElements(byteArray, &isCopy); - + jbyte* bytes = env->GetByteArrayElements(byteArray, NULL); + jlong result; for (;;) { result = read(fd, (void *) (bytes + offset), (int) nbytes); @@ -374,7 +370,7 @@ static jlong harmony_io_readImpl(JNIEnv * env, jobject thiz, jint fd, jniThrowException(env, "java/io/InterruptedIOException", "Read timed out"); } else { - jniThrowException(env, "java/io/IOException", strerror(errno)); + jniThrowException(env, "java/io/IOException", strerror(errno)); } } @@ -389,10 +385,8 @@ static jlong harmony_io_readImpl(JNIEnv * env, jobject thiz, jint fd, static jlong harmony_io_writeImpl(JNIEnv * env, jobject thiz, jint fd, jbyteArray byteArray, jint offset, jint nbytes) { - jboolean isCopy; - jbyte *bytes = env->GetByteArrayElements(byteArray, &isCopy); + jbyte* bytes = env->GetByteArrayElements(byteArray, NULL); jlong result; - for (;;) { result = write(fd, (const char *) bytes + offset, (int) nbytes); @@ -416,7 +410,7 @@ static jlong harmony_io_writeImpl(JNIEnv * env, jobject thiz, jint fd, jniThrowException(env, "java/io/InterruptedIOException", "Write timed out"); } else { - jniThrowException(env, "java/io/IOException", strerror(errno)); + jniThrowException(env, "java/io/IOException", strerror(errno)); } } @@ -562,11 +556,13 @@ static jint harmony_io_truncateImpl(JNIEnv * env, jobject thiz, jint fd, static jint harmony_io_openImpl(JNIEnv * env, jobject obj, jbyteArray path, jint jflags) { + if (path == NULL) { + jniThrowException(env, "java/lang/NullPointerException", NULL); + return -1; + } + int flags = 0; int mode = 0; - jint * portFD; - jsize length; - char pathCopy[HyMaxPath]; // BEGIN android-changed // don't want default permissions to allow global access. @@ -596,19 +592,14 @@ static jint harmony_io_openImpl(JNIEnv * env, jobject obj, jbyteArray path, flags = EsTranslateOpenFlags(flags); - length = env->GetArrayLength (path); + jsize length = env->GetArrayLength (path); length = length < HyMaxPath - 1 ? length : HyMaxPath - 1; + char pathCopy[HyMaxPath]; env->GetByteArrayRegion (path, 0, length, (jbyte *)pathCopy); pathCopy[length] = '\0'; convertToPlatform (pathCopy); int cc; - - if(pathCopy == NULL) { - jniThrowException(env, "java/lang/NullPointerException", NULL); - return -1; - } - do { cc = open(pathCopy, flags, mode); } while(cc < 0 && errno == EINTR); @@ -731,44 +722,7 @@ static jint harmony_io_ioctlAvailable(JNIEnv *env, jobject thiz, jint fd) { */ static jlong harmony_io_ttyReadImpl(JNIEnv *env, jobject thiz, jbyteArray byteArray, jint offset, jint nbytes) { - - jboolean isCopy; - jbyte *bytes = env->GetByteArrayElements(byteArray, &isCopy); - jlong result; - - for(;;) { - - result = (jlong) read(STDIN_FILENO, (char *)(bytes + offset), (int) nbytes); - - if ((result != -1) || (errno != EINTR)) { - break; - } - - /* - * If we didn't break above, that means that the read() call - * returned due to EINTR. We shield Java code from this - * possibility by trying again. Note that this is different - * from EAGAIN, which should result in this code throwing - * an InterruptedIOException. - */ - } - - env->ReleaseByteArrayElements(byteArray, bytes, 0); - - if (result == 0) { - return -1; - } - - if (result == -1) { - if (errno == EAGAIN) { - jniThrowException(env, "java/io/InterruptedIOException", - "Read timed out"); - } else { - jniThrowException(env, "java/io/IOException", strerror(errno)); - } - } - - return result; + return harmony_io_readImpl(env, thiz, STDIN_FILENO, byteArray, offset, nbytes); } /* diff --git a/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp b/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp index 02e18e9..8cd9e0f 100644 --- a/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp +++ b/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp @@ -2624,8 +2624,7 @@ static jint osNetworkSystem_receiveStreamImpl(JNIEnv* env, jclass clazz, int spaceAvailable = env->GetArrayLength(data) - offset; int localCount = count < spaceAvailable? count : spaceAvailable; - jboolean isCopy; - jbyte *body = env->GetByteArrayElements(data, &isCopy); + jbyte* body = env->GetByteArrayElements(data, NULL); // set timeout struct timeval tv; @@ -2668,8 +2667,7 @@ static jint osNetworkSystem_sendStreamImpl(JNIEnv* env, jclass clazz, int handle = 0; int result = 0, sent = 0; - jboolean isCopy; - jbyte *message = env->GetByteArrayElements(data, &isCopy); + jbyte *message = env->GetByteArrayElements(data, NULL); // Cap write length to available buf size int spaceAvailable = env->GetArrayLength(data) - offset; @@ -2826,7 +2824,6 @@ static jint osNetworkSystem_selectImpl(JNIEnv* env, jclass clazz, jobject gotFD; fd_set *fdset_read,*fdset_write; int handle; - jboolean isCopy ; jint *flagArray; int val; unsigned int time_sec = (unsigned int)timeout/1000; @@ -2885,7 +2882,7 @@ static jint osNetworkSystem_selectImpl(JNIEnv* env, jclass clazz, if (0 < result) { /*output the result to a int array*/ - flagArray = env->GetIntArrayElements(outFlags, &isCopy); + flagArray = env->GetIntArrayElements(outFlags, NULL); for (val=0; val<countReadC; val++) { gotFD = env->GetObjectArrayElement(readFDArray,val); diff --git a/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl.cpp b/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl.cpp index c79bfdf..324dacf 100644 --- a/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl.cpp +++ b/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl.cpp @@ -47,20 +47,6 @@ static SSL_SESSION *getSslSessionPointer(JNIEnv* env, jobject object) { } /** - * Throws java.io.IOexception with the provided message. - */ -static void throwIOExceptionStr(JNIEnv* env, const char* message) -{ - jclass exClass = env->FindClass("java/io/IOException"); - - if (exClass == NULL) { - LOGE("Unable to find class java/io/IOException"); - } else { - env->ThrowNew(exClass, message); - } -} - -/** * Gets the peer certificate in the chain and fills a byte array with the * information therein. */ |