Skip to content

Commit

Permalink
Manually merge upstream: resync src/java.base/share/classes/java/util…
Browse files Browse the repository at this point in the history
…/concurrent/ForkJoinPool.java with upstream.
  • Loading branch information
synecdoche committed Oct 29, 2024
2 parents 7af18b8 + e534863 commit 0708f41
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import java.util.function.Predicate;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.LockSupport;

import jdk.internal.access.JavaLangAccess;
import jdk.internal.access.JavaUtilConcurrentFJPAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.Unsafe;
Expand Down Expand Up @@ -1133,11 +1135,7 @@ static final class DefaultForkJoinWorkerThreadFactory
implements ForkJoinWorkerThreadFactory {
public final ForkJoinWorkerThread newThread(ForkJoinPool pool) {
boolean isCommon = (pool.workerNamePrefix == null);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm == null)
return new ForkJoinWorkerThread(null, pool, true, false);
else if (isCommon)
if (isCommon && JLA.allowSecurityManager())
return newCommonWithACC(pool);
else
return newRegularWithACC(pool);
Expand All @@ -1154,6 +1152,8 @@ else if (isCommon)
@SuppressWarnings("removal")
static volatile AccessControlContext regularACC, commonACC;

private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();

@SuppressWarnings("removal")
static ForkJoinWorkerThread newRegularWithACC(ForkJoinPool pool) {
AccessControlContext acc = regularACC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
* @requires vm.flavor == "server"
* @requires vm.gc.Shenandoah
*
* @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+StressGCM
* -XX:+StressLCM -XX:+UseShenandoahGC -XX:LoopMaxUnroll=0 -XX:StressSeed=270847015 TestLoadBypassesNullCheck
* @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+StressGCM
* -XX:+StressLCM -XX:+UseShenandoahGC -XX:LoopMaxUnroll=0 TestLoadBypassesNullCheck
* @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation
* -XX:+UseShenandoahGC -XX:LoopMaxUnroll=0
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:+StressLCM -XX:StressSeed=270847015
* TestLoadBypassesNullCheck
* @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation
* -XX:+UseShenandoahGC -XX:LoopMaxUnroll=0
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:+StressLCM
* TestLoadBypassesNullCheck
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.util.ArrayList;
Expand Down Expand Up @@ -93,13 +95,15 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor {
private static final Map<String, Class<? extends Annotation>> nameToAnnotation =
Map.ofEntries(new NameToAnnotationEntry("java.lang.Override", Override.class),
new NameToAnnotationEntry("java.lang.annotation.Repeatable", Repeatable.class),
new NameToAnnotationEntry("java.lang.annotation.Retention", Target.class),
new NameToAnnotationEntry("java.lang.annotation.Target", Target.class),
new NameToAnnotationEntry("BasicAnnoTests.Test", BasicAnnoTests.Test.class),
new NameToAnnotationEntry("BasicAnnoTests.Tests",BasicAnnoTests.Tests.class),
new NameToAnnotationEntry("BasicAnnoTests.TA", BasicAnnoTests.TA.class),
new NameToAnnotationEntry("BasicAnnoTests.TB", BasicAnnoTests.TB.class),
new NameToAnnotationEntry("BasicAnnoTests.TC", BasicAnnoTests.TC.class),
new NameToAnnotationEntry("BasicAnnoTests.TCs", BasicAnnoTests.TCs.class));
new NameToAnnotationEntry("BasicAnnoTests.TCs", BasicAnnoTests.TCs.class),
new NameToAnnotationEntry("BasicAnnoTests.TD", BasicAnnoTests.TD.class));

static class NameToAnnotationEntry extends AbstractMap.SimpleEntry<String, Class<? extends Annotation>> {
public NameToAnnotationEntry(String key, Class<? extends Annotation> entry) {
Expand Down Expand Up @@ -520,6 +524,12 @@ R scan(Iterable<? extends TypeMirror> iter, P p) {
TC[] value();
}

@Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TD {
int value();
}

// Test cases

// TODO: add more cases for arrays
Expand Down Expand Up @@ -657,6 +667,10 @@ public class Inner6<T extends Object & Cloneable & @TA(17) Serializable> {}
@Test(posn=1, annoType=TA.class, expect="23")
public Set<@TA(23) ? super Object> f9;

@Test(posn=0, annoType=TA.class, expect="1")
@Test(posn=0, annoType=TD.class, expect="2")
public @TA(1) @TD(2) int f10;

// Test type use annotations on uses of type variables
@Test(posn=6, annoType = TA.class, expect = "25")
@Test(posn=6, annoType = TB.class, expect = "26")
Expand Down

0 comments on commit 0708f41

Please sign in to comment.