< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/cacheObject/CheckIntegerCacheApp.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2018, 2026, 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
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

@@ -25,10 +25,13 @@
  //
  // Help test archived box cache consistency.
  //
  // args[0]: the expected maximum value expected to be archived
  //
+ 
+ import jdk.internal.misc.PreviewFeatures;
+ 
  public class CheckIntegerCacheApp {
      public static void main(String[] args) throws Exception {
          if (args.length != 1) {
              throw new RuntimeException(
                      "FAILED. Incorrect argument length: " + args.length);

@@ -74,11 +77,19 @@
          if (Integer.valueOf(high) != Integer.valueOf(high)) {
              throw new RuntimeException(
                      "FAILED. Value expected to be retrieved from cache: " + high);
          }
  
-         if (Integer.valueOf(high + 1) == Integer.valueOf(high + 1)) {
-             throw new RuntimeException(
-                     "FAILED. Value not expected to be retrieved from cache: " + high);
+         // In preview mode the Integer is a value class and the Integer cache is disabled
+         if (!PreviewFeatures.isEnabled()) {
+             if (Integer.valueOf(high + 1) == Integer.valueOf(high + 1)) {
+                 throw new RuntimeException(
+                         "FAILED. Value not expected to be retrieved from cache: " + high);
+             }
+         } else {
+             if (Integer.valueOf(high + 1) != Integer.valueOf(high + 1)) {
+                 throw new RuntimeException(
+                         "FAILED. Values must be equal in preview mode: " + high);
+             }
          }
      }
  }
< prev index next >