< prev index next >

test/jdk/jdk/internal/misc/ThreadFlock/WithScopedValue.java

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

@@ -51,11 +51,11 @@
       */
      @ParameterizedTest
      @MethodSource("factories")
      void testInheritsScopedValue(ThreadFactory factory) throws Exception {
          ScopedValue<String> name = ScopedValue.newInstance();
-         String value = ScopedValue.callWhere(name, "duke", () -> {
+         String value = ScopedValue.where(name, "duke").call(() -> {
              var result = new AtomicReference<String>();
              try (var flock = ThreadFlock.open(null)) {
                  Thread thread = factory.newThread(() -> {
                      // child
                      result.set(name.get());

@@ -77,11 +77,11 @@
              ThreadFlock flock1;
              ThreadFlock flock2;
          }
          var box = new Box();
          try {
-             ScopedValue.runWhere(name, "x1", () -> {
+             ScopedValue.where(name, "x1").run(() -> {
                  box.flock1 = ThreadFlock.open(null);
                  box.flock2 = ThreadFlock.open(null);
              });
              fail();
          } catch (StructureViolationException expected) { }

@@ -95,15 +95,15 @@
       */
      @Test
      void testStructureViolation2() {
          ScopedValue<String> name = ScopedValue.newInstance();
          try (var flock1 = ThreadFlock.open("flock1")) {
-             ScopedValue.runWhere(name, "x1", () -> {
+             ScopedValue.where(name, "x1").run(() -> {
                  try (var flock2 = ThreadFlock.open("flock2")) {
-                     ScopedValue.runWhere(name, "x2", () -> {
+                     ScopedValue.where(name, "x2").run(() -> {
                          try (var flock3 = ThreadFlock.open("flock3")) {
-                             ScopedValue.runWhere(name, "x3", () -> {
+                             ScopedValue.where(name, "x3").run(() -> {
                                  var flock4 = ThreadFlock.open("flock4");
  
                                  try {
                                      flock1.close();
                                      fail();

@@ -127,15 +127,15 @@
       */
      @Test
      void testStructureViolation3() {
          ScopedValue<String> name = ScopedValue.newInstance();
          try (var flock1 = ThreadFlock.open("flock1")) {
-             ScopedValue.runWhere(name, "x1", () -> {
+             ScopedValue.where(name, "x1").run(() -> {
                  try (var flock2 = ThreadFlock.open("flock2")) {
-                     ScopedValue.runWhere(name, "x2", () -> {
+                     ScopedValue.where(name, "x2").run(() -> {
                          try (var flock3 = ThreadFlock.open("flock3")) {
-                             ScopedValue.runWhere(name, "x3", () -> {
+                             ScopedValue.where(name, "x3").run(() -> {
                                  var flock4 = ThreadFlock.open("flock4");
  
                                  try {
                                      flock2.close();
                                      fail();

@@ -159,15 +159,15 @@
       */
      @Test
      void testStructureViolation4() {
          ScopedValue<String> name = ScopedValue.newInstance();
          try (var flock1 = ThreadFlock.open("flock1")) {
-             ScopedValue.runWhere(name, "x1", () -> {
+             ScopedValue.where(name, "x1").run(() -> {
                  try (var flock2 = ThreadFlock.open("flock2")) {
-                     ScopedValue.runWhere(name, "x2", () -> {
+                     ScopedValue.where(name, "x2").run(() -> {
                          try (var flock3 = ThreadFlock.open("flock3")) {
-                             ScopedValue.runWhere(name, "x3", () -> {
+                             ScopedValue.where(name, "x3").run(() -> {
                                  var flock4 = ThreadFlock.open("flock4");
  
                                  try {
                                      flock3.close();
                                      fail();

@@ -191,11 +191,11 @@
      @ParameterizedTest
      @MethodSource("factories")
      void testStructureViolation5(ThreadFactory factory) throws Exception {
          ScopedValue<String> name = ScopedValue.newInstance();
          try (var flock = ThreadFlock.open(null)) {
-             ScopedValue.runWhere(name, "duke", () -> {
+             ScopedValue.where(name, "duke").run(() -> {
                  Thread thread = factory.newThread(() -> { });
                  assertThrows(StructureViolationException.class, () -> flock.start(thread));
              });
          }
      }

@@ -205,13 +205,13 @@
       */
      @ParameterizedTest
      @MethodSource("factories")
      void testStructureViolation6(ThreadFactory factory) throws Exception {
          ScopedValue<String> name = ScopedValue.newInstance();
-         ScopedValue.runWhere(name, "duke", () -> {
+         ScopedValue.where(name, "duke").run(() -> {
              try (var flock = ThreadFlock.open(null)) {
-                 ScopedValue.runWhere(name, "duchess", () -> {
+                 ScopedValue.where(name, "duchess").run(() -> {
                      Thread thread = factory.newThread(() -> { });
                      assertThrows(StructureViolationException.class, () -> flock.start(thread));
                  });
              }
          });
< prev index next >