Skip to content

Commit 819a1fe

Browse files
author
Paul Hohensee
committed
8211400: nsk.share.gc.Memory::getArrayLength returns wrong value
Backport-of: 860d49db22cf352eaf1b3b20fff43d090f0eebc8
1 parent d46f769 commit 819a1fe

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

test/hotspot/jtreg/vmTestbase/nsk/share/gc/Memory.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -150,12 +150,9 @@ public static int getReferenceObjectSize() {
150150
* @return length of array
151151
*/
152152
public static int getArrayLength(long memory, long objectSize) {
153-
int referenceSize = getReferenceSize();
154153
int arrayExtraSize = getArrayExtraSize();
155-
return (int) Math.min(
156-
(memory - arrayExtraSize) / (objectSize + referenceSize),
157-
Integer.MAX_VALUE
158-
);
154+
return (int) Math.min((memory - arrayExtraSize) / objectSize,
155+
Integer.MAX_VALUE);
159156
}
160157

161158
/**
@@ -166,7 +163,7 @@ public static int getArrayLength(long memory, long objectSize) {
166163
* @return size of array
167164
*/
168165
public static long getArraySize(int length, long objectSize) {
169-
return getObjectExtraSize() + length * (objectSize + getReferenceSize());
166+
return getArrayExtraSize() + length * objectSize;
170167
}
171168

172169
/**

0 commit comments

Comments
 (0)