< prev index next >

src/java.base/share/native/libzip/Deflater.c

Print this page
rev 58083 : 8239351: Give more meaningful InternalError messages in Deflater.c

*** 1,7 **** /* ! * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 76,93 **** } } static void checkSetDictionaryResult(JNIEnv *env, jlong addr, jint res) { switch (res) { case Z_OK: break; case Z_STREAM_ERROR: JNU_ThrowIllegalArgumentException(env, 0); break; default: ! JNU_ThrowInternalError(env, ((z_stream *)jlong_to_ptr(addr))->msg); break; } } JNIEXPORT void JNICALL --- 76,96 ---- } } static void checkSetDictionaryResult(JNIEnv *env, jlong addr, jint res) { + const char *msg = NULL; switch (res) { case Z_OK: break; case Z_STREAM_ERROR: JNU_ThrowIllegalArgumentException(env, 0); break; default: ! msg = ((((z_stream *)jlong_to_ptr(addr))->msg != NULL) ? ((z_stream *)jlong_to_ptr(addr))->msg : ! "unknown error in checkSetDictionaryResult"); ! JNU_ThrowInternalError(env, msg); break; } } JNIEXPORT void JNICALL
*** 144,153 **** --- 147,157 ---- { z_stream *strm = jlong_to_ptr(addr); jint inputUsed = 0, outputUsed = 0; int finished = 0; int setParams = params & 1; + const char* msg = NULL; if (setParams) { switch (res) { case Z_OK: setParams = 0;
*** 155,165 **** case Z_BUF_ERROR: inputUsed = inputLen - strm->avail_in; outputUsed = outputLen - strm->avail_out; break; default: ! JNU_ThrowInternalError(env, strm->msg); return 0; } } else { switch (res) { case Z_STREAM_END: --- 159,171 ---- case Z_BUF_ERROR: inputUsed = inputLen - strm->avail_in; outputUsed = outputLen - strm->avail_out; break; default: ! msg = ((strm->msg != NULL) ? strm->msg : ! "unknown error in checkDeflateStatus, setParams case"); ! JNU_ThrowInternalError(env, msg); return 0; } } else { switch (res) { case Z_STREAM_END:
*** 169,179 **** case Z_BUF_ERROR: inputUsed = inputLen - strm->avail_in; outputUsed = outputLen - strm->avail_out; break; default: ! JNU_ThrowInternalError(env, strm->msg); return 0; } } return ((jlong)inputUsed) | (((jlong)outputUsed) << 31) | (((jlong)finished) << 62) | (((jlong)setParams) << 63); } --- 175,187 ---- case Z_BUF_ERROR: inputUsed = inputLen - strm->avail_in; outputUsed = outputLen - strm->avail_out; break; default: ! msg = ((strm->msg != NULL) ? strm->msg : ! "unknown error in checkDeflateStatus"); ! JNU_ThrowInternalError(env, msg); return 0; } } return ((jlong)inputUsed) | (((jlong)outputUsed) << 31) | (((jlong)finished) << 62) | (((jlong)setParams) << 63); }
*** 287,304 **** JNIEXPORT void JNICALL Java_java_util_zip_Deflater_reset(JNIEnv *env, jclass cls, jlong addr) { if (deflateReset((z_stream *)jlong_to_ptr(addr)) != Z_OK) { ! JNU_ThrowInternalError(env, 0); } } JNIEXPORT void JNICALL Java_java_util_zip_Deflater_end(JNIEnv *env, jclass cls, jlong addr) { if (deflateEnd((z_stream *)jlong_to_ptr(addr)) == Z_STREAM_ERROR) { ! JNU_ThrowInternalError(env, 0); } else { free((z_stream *)jlong_to_ptr(addr)); } } --- 295,312 ---- JNIEXPORT void JNICALL Java_java_util_zip_Deflater_reset(JNIEnv *env, jclass cls, jlong addr) { if (deflateReset((z_stream *)jlong_to_ptr(addr)) != Z_OK) { ! JNU_ThrowInternalError(env, "deflateReset failed"); } } JNIEXPORT void JNICALL Java_java_util_zip_Deflater_end(JNIEnv *env, jclass cls, jlong addr) { if (deflateEnd((z_stream *)jlong_to_ptr(addr)) == Z_STREAM_ERROR) { ! JNU_ThrowInternalError(env, "deflateEnd failed"); } else { free((z_stream *)jlong_to_ptr(addr)); } }
< prev index next >