Skip to content

Commit

Permalink
Merge pull request #902 from JasonFengJ9/mergestaging
Browse files Browse the repository at this point in the history
Merge master HEAD into openj9-staging
  • Loading branch information
keithc-ca authored Dec 4, 2024

Verified

This commit was signed with the committer’s verified signature.
dmihalcik-virtru Dave Mihalcik
2 parents a80745d + 40c1830 commit 3e7a1fe
Showing 112 changed files with 2,293 additions and 1,436 deletions.
Original file line number Diff line number Diff line change
@@ -33,8 +33,6 @@
import jdk.internal.reflect.Reflection;
import jdk.internal.reflect.CallerSensitive;

import sun.security.action.GetPropertyAction;

/*[IF CRIU_SUPPORT]*/
import openj9.internal.criu.InternalCRIUSupport;
/*[ENDIF] CRIU_SUPPORT */
@@ -65,10 +63,10 @@ public class NativeCrypto {
private static final Cleaner ECKeyCleaner = CleanerFactory.cleaner();

private static final boolean useNativeCrypto = Boolean.parseBoolean(
GetPropertyAction.privilegedGetProperty("jdk.nativeCrypto", "true"));
System.getProperty("jdk.nativeCrypto", "true"));

private static final boolean traceEnabled = Boolean.parseBoolean(
GetPropertyAction.privilegedGetProperty("jdk.nativeCryptoTrace", "false"));
System.getProperty("jdk.nativeCryptoTrace", "false"));

private static final class InstanceHolder {
private static final NativeCrypto instance = new NativeCrypto();
@@ -160,7 +158,7 @@ public static final boolean isAlgorithmEnabled(String property, String name) {
boolean useNativeAlgorithm = false;
if (useNativeCrypto) {
useNativeAlgorithm = Boolean.parseBoolean(
GetPropertyAction.privilegedGetProperty(property, "true"));
System.getProperty(property, "true"));
}
/*
* User wants to use the native crypto implementation. Ensure that the native crypto library is enabled.
Original file line number Diff line number Diff line change
@@ -345,9 +345,10 @@ private static void getProfileID(Properties props) {
}
String defaultMatch = null;
boolean profileExists = false;
String profilePrefix = potentialProfileID + '.';
for (Object keyObject : props.keySet()) {
if (keyObject instanceof String key) {
if (key.startsWith(potentialProfileID)) {
if (key.startsWith(profilePrefix)) {
profileExists = true;
if (key.endsWith(".desc.default")) {
// Check if property is set to true.
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@
import java.security.interfaces.*;

import javax.crypto.BadPaddingException;
import sun.security.action.GetPropertyAction;
import jdk.crypto.jniprovider.NativeCrypto;

import sun.security.jca.JCAUtil;
22 changes: 22 additions & 0 deletions closed/test/jdk/openj9/internal/security/TestProperties.java
Original file line number Diff line number Diff line change
@@ -43,6 +43,15 @@

public class TestProperties {

private static Stream<Arguments> patternMatches_expectedExitValue0() {
return Stream.of(
// 1 - Test property - Same beginnings of the profile name without version.
Arguments.of("Test-Profile-SameStartWithoutVersion",
System.getProperty("test.src") + "/property-java.security",
"(?s)(?=.*Sun)(?=.*\\bSunJCE\\b)(?=.*SunJSSE)")
);
}

private static Stream<Arguments> patternMatches_expectedExitValue1() {
return Stream.of(
// 1 - Test profile - base profile misspell properties.
@@ -155,6 +164,19 @@ private static Stream<Arguments> patternMatches_expectedExitValue1() {
);
}

@ParameterizedTest
@MethodSource("patternMatches_expectedExitValue0")
public void shouldContain_expectedExitValue0(String customprofile, String securityPropertyFile, String expected) throws Exception {
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava(
"-Dsemeru.fips=true",
"-Dsemeru.customprofile=" + customprofile,
"-Djava.security.properties=" + securityPropertyFile,
"TestProperties"
);
outputAnalyzer.reportDiagnosticSummary();
outputAnalyzer.shouldHaveExitValue(0).shouldMatch(expected);
}

@ParameterizedTest
@MethodSource("patternMatches_expectedExitValue1")
public void shouldContain_expectedExitValue1(String customprofile, String securityPropertyFile, String expected) throws Exception {
36 changes: 36 additions & 0 deletions closed/test/jdk/openj9/internal/security/property-java.security
Original file line number Diff line number Diff line change
@@ -525,3 +525,39 @@ RestrictedSecurity.Test-Profile-ConstraintChanged_3.Base.jce.provider.1 = com.s

RestrictedSecurity.Test-Profile-ConstraintChanged_3.Base.securerandom.provider = OpenJCEPlusFIPS
RestrictedSecurity.Test-Profile-ConstraintChanged_3.Base.securerandom.algorithm = SHA512DRBG

#
# Test-Profile-SameStartWithoutVersion
# Test property - Same beginnings of the profile name without version
#
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.name = Test-Profile-SameStartWithoutVersion
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.default = true
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.fips = true
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.hash = SHA256:2c893d75043da09c3dba8d8b24cb71dc1c7ceac5fb8bf362a35847418a933a06
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.number = Certificate #XXX
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.policy = https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.sunsetDate = 2026-09-21
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.fips.mode = 140-3

RestrictedSecurity.Test-Profile-SameStartWithoutVersion.jce.provider.1 = sun.security.provider.Sun
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.jce.provider.2 = com.sun.crypto.provider.SunJCE
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.jce.provider.3 = sun.security.ssl.SunJSSE

RestrictedSecurity.Test-Profile-SameStartWithoutVersion.securerandom.provider = OpenJCEPlusFIPS
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.securerandom.algorithm = SHA512DRBG

RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.name = Test-Profile-SameStartWithoutVersionPart
RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.default = true
RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.fips = true
RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.hash = SHA256:2c893d75043da09c3dba8d8b24cb71dc1c7ceac5fb8bf362a35847418a933a06
RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.number = Certificate #XXX
RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.policy = https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/
RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.sunsetDate = 2026-09-21
RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.fips.mode = 140-3

RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.jce.provider.1 = sun.security.provider.Sun
RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.jce.provider.2 = com.sun.crypto.provider.SunJCE
RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.jce.provider.3 = sun.security.ssl.SunJSSE

RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.securerandom.provider = OpenJCEPlusFIPS
RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.securerandom.algorithm = SHA512DRBG
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@

import jdk.crypto.jniprovider.NativeCrypto;
import jdk.internal.util.StaticProperty;
import sun.security.action.GetPropertyAction;

/*
* The "SunJCE" Cryptographic Service Provider.
3 changes: 1 addition & 2 deletions src/java.base/share/classes/java/lang/ScopedValue.java
Original file line number Diff line number Diff line change
@@ -38,7 +38,6 @@
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.annotation.Hidden;
import jdk.internal.vm.ScopedValueContainer;
import sun.security.action.GetPropertyAction;

/**
* A value that may be safely and efficiently shared to methods without using method
@@ -740,7 +739,7 @@ private static final class Cache {

static {
final String propertyName = "java.lang.ScopedValue.cacheSize";
var sizeString = GetPropertyAction.privilegedGetProperty(propertyName, "16");
var sizeString = System.getProperty(propertyName, "16");
var cacheSize = Integer.valueOf(sizeString);
if (cacheSize < 2 || cacheSize > MAX_CACHE_SIZE) {
cacheSize = MAX_CACHE_SIZE;
10 changes: 2 additions & 8 deletions src/java.base/share/classes/java/lang/StackStreamFactory.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@@ -45,7 +45,6 @@
import java.util.stream.StreamSupport;
import jdk.internal.vm.Continuation;
import jdk.internal.vm.ContinuationScope;
import sun.security.action.GetPropertyAction;

import static java.lang.StackStreamFactory.WalkerState.*;

@@ -82,13 +81,8 @@ private StackStreamFactory() {}
@Native private static final int SHOW_HIDDEN_FRAMES = 0x20; // LambdaForms are hidden by the VM
@Native private static final int FILL_LIVE_STACK_FRAMES = 0x100;

/*
* For Throwable to use StackWalker, set useNewThrowable to true.
* Performance work and extensive testing is needed to replace the
* VM built-in backtrace filled in Throwable with the StackWalker.
*/
static final boolean isDebug =
"true".equals(GetPropertyAction.privilegedGetProperty("stackwalk.debug"));
"true".equals(System.getProperty("stackwalk.debug"));

static <T> StackFrameTraverser<T>
makeStackTraverser(StackWalker walker, Function<? super Stream<StackFrame>, ? extends T> function)
5 changes: 5 additions & 0 deletions src/java.base/share/classes/java/lang/System.java
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@
import java.util.ResourceBundle;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Supplier;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;
@@ -2304,6 +2305,10 @@ public Executor virtualThreadDefaultScheduler() {
return VirtualThread.defaultScheduler();
}

public Stream<ScheduledExecutorService> virtualThreadDelayedTaskSchedulers() {
return VirtualThread.delayedTaskSchedulers();
}

public StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
ContinuationScope contScope,
Continuation continuation) {
3 changes: 1 addition & 2 deletions src/java.base/share/classes/java/lang/ThreadLocal.java
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@

import jdk.internal.misc.CarrierThreadLocal;
import jdk.internal.misc.TerminatingThreadLocal;
import sun.security.action.GetPropertyAction;

/**
* This class provides thread-local variables. These variables differ from
@@ -804,7 +803,7 @@ private void expungeStaleEntries() {
* a stack trace should be printed when a virtual thread sets a thread local.
*/
private static boolean traceVirtualThreadLocals() {
String propValue = GetPropertyAction.privilegedGetProperty("jdk.traceVirtualThreadLocals");
String propValue = System.getProperty("jdk.traceVirtualThreadLocals");
return (propValue != null)
&& (propValue.isEmpty() || Boolean.parseBoolean(propValue));
}
10 changes: 9 additions & 1 deletion src/java.base/share/classes/java/lang/VirtualThread.java
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
*/
package java.lang;

import java.util.Arrays;
import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
@@ -37,12 +38,12 @@
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.ForkJoinWorkerThread;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import jdk.internal.event.VirtualThreadEndEvent;
import jdk.internal.event.VirtualThreadStartEvent;
import jdk.internal.event.VirtualThreadSubmitFailedEvent;
@@ -197,6 +198,13 @@ static Executor defaultScheduler() {
return DEFAULT_SCHEDULER;
}

/**
* Returns a stream of the delayed task schedulers used to support timed operations.
*/
static Stream<ScheduledExecutorService> delayedTaskSchedulers() {
return Arrays.stream(DELAYED_TASK_SCHEDULERS);
}

/**
* Returns the continuation scope used for virtual threads.
*/
Original file line number Diff line number Diff line change
@@ -456,9 +456,11 @@ default ClassDesc classSymbol() {
*
* @apiNote
* {@code TAG_}-prefixed constants in this class, such as {@link #TAG_INT},
* describe the possible return values of this method.
* describe the possible return values of this method. The return type is
* {@code int} for consistency with union indicator items in other union
* structures in the {@code class} file format.
*/
char tag();
int tag();

/**
* {@return an enum value for an element-value pair}
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ public sealed interface PoolEntry
* {@code TAG_}-prefixed constants in this class, such as {@link #TAG_UTF8},
* describe the possible return values of this method.
*/
byte tag();
int tag();

/**
* {@return the index within the constant pool corresponding to this entry}
2 changes: 0 additions & 2 deletions src/java.base/share/classes/java/lang/foreign/Linker.java
Original file line number Diff line number Diff line change
@@ -852,8 +852,6 @@ static Option firstVariadicArg(int index) {
* // use errno
* }
* }
* <p>
* This linker option can not be combined with {@link #critical}.
*
* @param capturedState the names of the values to save
* @throws IllegalArgumentException if at least one of the provided
Original file line number Diff line number Diff line change
@@ -248,7 +248,7 @@ private byte[] classFileSetup(Consumer<? super ClassBuilder> config) {
return ClassFile.of().build(classEntry, pool, new Consumer<>() {
@Override
public void accept(ClassBuilder clb) {
clb.withFlags(ACC_ABSTRACT | ACC_SUPER)
clb.withFlags(ACC_FINAL | ACC_SUPER)
.withSuperclass(INVOKER_SUPER_DESC)
.with(SourceFileAttribute.of(clb.constantPool().utf8Entry(SOURCE_PREFIX + name)));
config.accept(clb);
Original file line number Diff line number Diff line change
@@ -34,11 +34,9 @@
import jdk.internal.misc.VM;
import jdk.internal.ref.CleanerFactory;
import sun.invoke.util.Wrapper;
import sun.security.action.GetPropertyAction;

import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Field;
import java.util.Properties;

import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleStatics.TRACE_METHOD_LINKAGE;
3 changes: 3 additions & 0 deletions src/java.base/share/classes/java/net/IDN.java
Original file line number Diff line number Diff line change
@@ -66,6 +66,9 @@
* Applications are responsible for taking adequate security measures when using
* international domain names.
*
* <p>Unless otherwise specified, passing a {@code null} argument to any method
* in this class will cause a {@link NullPointerException} to be thrown.
*
* @spec https://www.rfc-editor.org/info/rfc1122
* RFC 1122: Requirements for Internet Hosts - Communication Layers
* @spec https://www.rfc-editor.org/info/rfc1123
7 changes: 3 additions & 4 deletions src/java.base/share/classes/java/net/InterfaceAddress.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2021, 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
@@ -42,10 +42,9 @@ public class InterfaceAddress {
private short maskLength = 0;

/*
* Package private constructor. Can't be built directly, instances are
* obtained through the NetworkInterface class.
* This constructor is called via JNI in NetworkInterface.c
*/
InterfaceAddress() {
private InterfaceAddress() {
}

/**
Loading

0 comments on commit 3e7a1fe

Please sign in to comment.