diff -r 2251ba078bec -r eb7ce841ccec src/share/vm/prims/jniCheck.cpp --- a/src/share/vm/prims/jniCheck.cpp Sat Oct 24 16:18:50 2020 +0800 +++ b/src/share/vm/prims/jniCheck.cpp Sat Oct 24 16:43:47 2020 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -437,21 +437,20 @@ size_t sz; void* orig_result = check_wrapped_array(thr, fn_name, obj, carray, &sz); switch (mode) { + // As we never make copies, mode 0 and JNI_COMMIT are the same. case 0: - memcpy(orig_result, carray, sz); - GuardedMemory::free_copy(carray); - break; case JNI_COMMIT: memcpy(orig_result, carray, sz); break; case JNI_ABORT: - GuardedMemory::free_copy(carray); break; default: tty->print_cr("%s: Unrecognized mode %i releasing array " PTR_FORMAT " elements " PTR_FORMAT, fn_name, mode, p2i(obj), p2i(carray)); NativeReportJNIFatalError(thr, "Unrecognized array release mode"); } + // We always need to release the copy we made with GuardedMemory + GuardedMemory::free_copy(carray); return orig_result; }