8321429: (fc) FileChannel.lock creates a FileKey containing two long index values, they could be stored as int values
Reviewed-by: alanb
This commit is contained in:
parent
0c178beb69
commit
71800884f6
src/java.base/windows
@ -33,9 +33,9 @@ import java.io.IOException;
|
||||
*/
|
||||
public class FileKey {
|
||||
|
||||
private long dwVolumeSerialNumber;
|
||||
private long nFileIndexHigh;
|
||||
private long nFileIndexLow;
|
||||
private int dwVolumeSerialNumber;
|
||||
private int nFileIndexHigh;
|
||||
private int nFileIndexLow;
|
||||
|
||||
private FileKey() { }
|
||||
|
||||
@ -47,9 +47,10 @@ public class FileKey {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int)(dwVolumeSerialNumber ^ (dwVolumeSerialNumber >>> 32)) +
|
||||
(int)(nFileIndexHigh ^ (nFileIndexHigh >>> 32)) +
|
||||
(int)(nFileIndexLow ^ (nFileIndexLow >>> 32));
|
||||
int h = dwVolumeSerialNumber;
|
||||
h = h << 31 + nFileIndexHigh;
|
||||
h = h << 31 + nFileIndexLow;
|
||||
return h;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2023, 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
|
||||
@ -38,9 +38,9 @@ static jfieldID key_indexLow; /* id for FileKey.nFileIndexLow */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_nio_ch_FileKey_initIDs(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
CHECK_NULL(key_volumeSN = (*env)->GetFieldID(env, clazz, "dwVolumeSerialNumber", "J"));
|
||||
CHECK_NULL(key_indexHigh = (*env)->GetFieldID(env, clazz, "nFileIndexHigh", "J"));
|
||||
CHECK_NULL(key_indexLow = (*env)->GetFieldID(env, clazz, "nFileIndexLow", "J"));
|
||||
CHECK_NULL(key_volumeSN = (*env)->GetFieldID(env, clazz, "dwVolumeSerialNumber", "I"));
|
||||
CHECK_NULL(key_indexHigh = (*env)->GetFieldID(env, clazz, "nFileIndexHigh", "I"));
|
||||
CHECK_NULL(key_indexLow = (*env)->GetFieldID(env, clazz, "nFileIndexLow", "I"));
|
||||
}
|
||||
|
||||
|
||||
@ -53,9 +53,9 @@ Java_sun_nio_ch_FileKey_init(JNIEnv *env, jobject this, jobject fdo)
|
||||
|
||||
result = GetFileInformationByHandle(fileHandle, &fileInfo);
|
||||
if (result) {
|
||||
(*env)->SetLongField(env, this, key_volumeSN, fileInfo.dwVolumeSerialNumber);
|
||||
(*env)->SetLongField(env, this, key_indexHigh, fileInfo.nFileIndexHigh);
|
||||
(*env)->SetLongField(env, this, key_indexLow, fileInfo.nFileIndexLow);
|
||||
(*env)->SetIntField(env, this, key_volumeSN, fileInfo.dwVolumeSerialNumber);
|
||||
(*env)->SetIntField(env, this, key_indexHigh, fileInfo.nFileIndexHigh);
|
||||
(*env)->SetIntField(env, this, key_indexLow, fileInfo.nFileIndexLow);
|
||||
} else {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "GetFileInformationByHandle failed");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user