Skip to content

Commit

Permalink
8211400: nsk.share.gc.Memory::getArrayLength returns wrong value
Browse files Browse the repository at this point in the history
  • Loading branch information
rsunderbabu committed Sep 29, 2024
1 parent 73ebb84 commit eb3dcde
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions test/hotspot/jtreg/vmTestbase/nsk/share/gc/Memory.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -150,12 +150,9 @@ public static int getReferenceObjectSize() {
* @return length of array
*/
public static int getArrayLength(long memory, long objectSize) {
int referenceSize = getReferenceSize();
int arrayExtraSize = getArrayExtraSize();
return (int) Math.min(
(memory - arrayExtraSize) / (objectSize + referenceSize),
Integer.MAX_VALUE
);
return (int) Math.min((memory - arrayExtraSize) / objectSize,
Integer.MAX_VALUE);
}

/**
Expand All @@ -166,7 +163,7 @@ public static int getArrayLength(long memory, long objectSize) {
* @return size of array
*/
public static long getArraySize(int length, long objectSize) {
return getObjectExtraSize() + length * (objectSize + getReferenceSize());
return getObjectExtraSize() + length * objectSize;
}

/**
Expand Down

0 comments on commit eb3dcde

Please sign in to comment.