1.1 --- a/src/share/vm/prims/jniCheck.cpp Sat Oct 24 16:18:50 2020 +0800 1.2 +++ b/src/share/vm/prims/jniCheck.cpp Sat Oct 24 16:43:47 2020 +0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -437,21 +437,20 @@ 1.11 size_t sz; 1.12 void* orig_result = check_wrapped_array(thr, fn_name, obj, carray, &sz); 1.13 switch (mode) { 1.14 + // As we never make copies, mode 0 and JNI_COMMIT are the same. 1.15 case 0: 1.16 - memcpy(orig_result, carray, sz); 1.17 - GuardedMemory::free_copy(carray); 1.18 - break; 1.19 case JNI_COMMIT: 1.20 memcpy(orig_result, carray, sz); 1.21 break; 1.22 case JNI_ABORT: 1.23 - GuardedMemory::free_copy(carray); 1.24 break; 1.25 default: 1.26 tty->print_cr("%s: Unrecognized mode %i releasing array " 1.27 PTR_FORMAT " elements " PTR_FORMAT, fn_name, mode, p2i(obj), p2i(carray)); 1.28 NativeReportJNIFatalError(thr, "Unrecognized array release mode"); 1.29 } 1.30 + // We always need to release the copy we made with GuardedMemory 1.31 + GuardedMemory::free_copy(carray); 1.32 return orig_result; 1.33 } 1.34