Skip to content

Commit

Permalink
Merge upstream-jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Oct 31, 2023
2 parents 0f6df3b + 75ce02f commit 8ac85ea
Show file tree
Hide file tree
Showing 58 changed files with 1,137 additions and 325 deletions.
8 changes: 4 additions & 4 deletions make/langtools/tools/javacserver/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
public class Client {
private static final Log.Level LOG_LEVEL = Log.Level.INFO;

// Wait 2 seconds for response, before giving up on javac server.
private static final int CONNECTION_TIMEOUT = 2000;
private static final int MAX_CONNECT_ATTEMPTS = 3;
// Wait 4 seconds for response, before giving up on javac server.
private static final int CONNECTION_TIMEOUT = 4000;
private static final int MAX_CONNECT_ATTEMPTS = 10;
private static final int WAIT_BETWEEN_CONNECT_ATTEMPTS = 2000;

private final ClientConfiguration conf;
Expand Down Expand Up @@ -130,7 +130,7 @@ private Socket tryConnect() throws IOException, InterruptedException {
Log.error("Connection attempt failed: " + ex.getMessage());
if (attempt >= MAX_CONNECT_ATTEMPTS) {
Log.error("Giving up");
throw new IOException("Could not connect to server", ex);
throw new IOException("Could not connect to server after " + MAX_CONNECT_ATTEMPTS + " attempts with timeout " + CONNECTION_TIMEOUT, ex);
}
}
Thread.sleep(WAIT_BETWEEN_CONNECT_ATTEMPTS);
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/adlc/output_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3127,6 +3127,9 @@ static void define_fill_new_machnode(bool used, FILE *fp_cpp) {
fprintf(fp_cpp, " if( i != cisc_operand() ) \n");
fprintf(fp_cpp, " to[i] = _opnds[i]->clone();\n");
fprintf(fp_cpp, " }\n");
fprintf(fp_cpp, " // Do not increment node index counter, since node reuses my index\n");
fprintf(fp_cpp, " Compile* C = Compile::current();\n");
fprintf(fp_cpp, " C->set_unique(C->unique() - 1);\n");
fprintf(fp_cpp, "}\n");
}
fprintf(fp_cpp, "\n");
Expand Down
11 changes: 10 additions & 1 deletion src/hotspot/share/gc/shared/barrierSetNMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
// Called upon first entry after being armed
bool may_enter = bs_nm->nmethod_entry_barrier(nm);

// In case a concurrent thread disarmed the nmethod, we need to ensure the new instructions
// are made visible, by using a cross modify fence. Note that this is synchronous cross modifying
// code, where the existence of new instructions is communicated via data (the guard value).
// This cross modify fence is only needed when the nmethod entry barrier modifies the
// instructions. Not all platforms currently do that, so if this check becomes expensive,
// it can be made conditional on the nmethod_patching_type.
OrderAccess::cross_modify_fence();

// Diagnostic option to force deoptimization 1 in 3 times. It is otherwise
// a very rare event.
if (DeoptimizeNMethodBarriersALot) {
Expand Down Expand Up @@ -214,6 +222,7 @@ bool BarrierSetNMethod::nmethod_osr_entry_barrier(nmethod* nm) {

assert(nm->is_osr_method(), "Should not reach here");
log_trace(nmethod, barrier)("Running osr nmethod entry barrier: " PTR_FORMAT, p2i(nm));
bool result = nmethod_entry_barrier(nm);
OrderAccess::cross_modify_fence();
return nmethod_entry_barrier(nm);
return result;
}
6 changes: 5 additions & 1 deletion src/java.base/share/classes/java/nio/channels/Channels.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ public static Reader newReader(ReadableByteChannel ch, Charset charset) {
* The resulting stream will not otherwise be buffered. Closing the stream
* will in turn cause the channel to be closed. </p>
*
* @implNote
* The value of {@code minBufferCap} is ignored.
*
* @param ch
* The channel to which bytes will be written
*
Expand All @@ -532,7 +535,8 @@ public static Reader newReader(ReadableByteChannel ch, Charset charset) {
* @param minBufferCap
* The minimum capacity of the internal byte buffer,
* or {@code -1} if an implementation-dependent
* default capacity is to be used
* default capacity is to be used. The value of
* {@code minBufferCap} may be ignored
*
* @return A new writer
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ public enum Feature {

@JEP(number=430, title="String Templates")
STRING_TEMPLATES,
@JEP(number=443, title="Unnamed Patterns and Variables")
UNNAMED,
@JEP(number=445, title="Unnamed Classes and Instance Main Methods")
UNNAMED_CLASSES,
@JEP(number=446, title="Scoped Values", status="Preview")
Expand Down
1 change: 1 addition & 0 deletions src/java.base/share/classes/sun/security/util/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static void Help()
System.err.println("logincontext login context results");
System.err.println("jca JCA engine class debugging");
System.err.println("keystore KeyStore debugging");
System.err.println("pcsc Smartcard library debugging");
System.err.println("policy loading and granting");
System.err.println("provider security provider debugging");
System.err.println("pkcs11 PKCS11 session manager debugging");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ public interface VariableElement extends Element {
* @jls 6.1 Declarations
* @jls 14.4 Local Variable Declarations
*
* @since 21
* @since 22
*/
@PreviewFeature(feature=PreviewFeature.Feature.UNNAMED, reflective = true)
default boolean isUnnamed() { return getSimpleName().isEmpty(); }
}
4 changes: 4 additions & 0 deletions src/java.desktop/share/native/libjavajpeg/imageioJPEG.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,10 @@ imageio_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
return;
}
num_bytes += sb->remaining_skip;
// Check for overflow if remaining_skip value is too large
if (num_bytes < 0) {
return;
}
sb->remaining_skip = 0;

/* First the easy case where we are skipping <= the current contents. */
Expand Down
4 changes: 4 additions & 0 deletions src/java.desktop/share/native/libjavajpeg/jpegdecoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ sun_jpeg_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
return;
}
num_bytes += src->remaining_skip;
// Check for overflow if remaining_skip value is too large
if (num_bytes < 0) {
return;
}
src->remaining_skip = 0;
ret = (int)src->pub.bytes_in_buffer; /* this conversion is safe, because capacity of the buffer is limited by jnit */
if (ret >= num_bytes) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, Red Hat Inc. 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 @@ -46,8 +47,14 @@ class PlatformPCSC {

private static final String PROP_NAME = "sun.security.smartcardio.library";

private static final String LIB1 = "/usr/$LIBISA/libpcsclite.so";
private static final String LIB2 = "/usr/local/$LIBISA/libpcsclite.so";
// The architecture templates are for Debian-based systems: https://wiki.debian.org/Multiarch/Tuples
// 32-bit arm differs from the pattern of the rest and has to be specified explicitly
private static final String[] LIB_TEMPLATES = { "/usr/$LIBISA/libpcsclite.so",
"/usr/local/$LIBISA/libpcsclite.so",
"/usr/lib/$ARCH-linux-gnu/libpcsclite.so",
"/usr/lib/arm-linux-gnueabi/libpcsclite.so",
"/usr/lib/arm-linux-gnueabihf/libpcsclite.so" };
private static final String[] LIB_SUFFIXES = { ".1", ".0", "" };
private static final String PCSC_FRAMEWORK = "/System/Library/Frameworks/PCSC.framework/Versions/Current/PCSC";

PlatformPCSC() {
Expand All @@ -73,23 +80,38 @@ public Throwable run() {
});

// expand $LIBISA to the system specific directory name for libraries
// expand $ARCH to the Debian system architecture in use
private static String expand(String lib) {
int k = lib.indexOf("$LIBISA");
if (k == -1) {
return lib;
if (k != -1) {
String libDir;
if ("64".equals(System.getProperty("sun.arch.data.model"))) {
// assume Linux convention
libDir = "lib64";
} else {
// must be 32-bit
libDir = "lib";
}
lib = lib.replace("$LIBISA", libDir);
}
String s1 = lib.substring(0, k);
String s2 = lib.substring(k + 7);
String libDir;
if ("64".equals(System.getProperty("sun.arch.data.model"))) {
// assume Linux convention
libDir = "lib64";
} else {
// must be 32-bit
libDir = "lib";

k = lib.indexOf("$ARCH");
if (k != -1) {
String arch = System.getProperty("os.arch");
lib = lib.replace("$ARCH", getDebianArchitecture(arch));
}
String s = s1 + libDir + s2;
return s;

return lib;
}

private static String getDebianArchitecture(String jdkArch) {
return switch (jdkArch) {
case "amd64" -> "x86_64";
case "ppc" -> "powerpc";
case "ppc64" -> "powerpc64";
case "ppc64le" -> "powerpc64le";
default -> jdkArch;
};
}

private static String getLibraryName() throws IOException {
Expand All @@ -98,15 +120,18 @@ private static String getLibraryName() throws IOException {
if (lib.length() != 0) {
return lib;
}
lib = expand(LIB1);
if (new File(lib).isFile()) {
// if LIB1 exists, use that
return lib;
}
lib = expand(LIB2);
if (new File(lib).isFile()) {
// if LIB2 exists, use that
return lib;

for (String template : LIB_TEMPLATES) {
for (String suffix : LIB_SUFFIXES) {
lib = expand(template) + suffix;
if (debug != null) {
debug.println("Looking for " + lib);
}
if (new File(lib).isFile()) {
// if library exists, use that
return lib;
}
}
}

// As of macos 11, framework libraries have been removed from the file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
*
* @jls 14.30.1 Kinds of Patterns
*
* @since 21
* @since 22
*/
@PreviewFeature(feature=PreviewFeature.Feature.UNNAMED)
public interface AnyPatternTree extends PatternTree {
}
3 changes: 1 addition & 2 deletions src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ public enum Kind {
/**
* Used for instances of {@link BindingPatternTree}.
*
* @since 21
* @since 22
*/
@PreviewFeature(feature=PreviewFeature.Feature.UNNAMED)
ANY_PATTERN(AnyPatternTree.class),

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,8 @@ public interface TreeVisitor<R,P> {
* @param node the node being visited
* @param p a parameter value
* @return a result value
* @since 21
* @since 22
*/
@PreviewFeature(feature=PreviewFeature.Feature.UNNAMED)
R visitAnyPattern(AnyPatternTree node, P p);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,9 @@ public R visitStringTemplate(StringTemplateTree node, P p) {
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
* @since 21
* @since 22
*/
@Override
@PreviewFeature(feature=PreviewFeature.Feature.UNNAMED)
public R visitAnyPattern(AnyPatternTree node, P p) {
return defaultAction(node, p);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ public boolean isPreview(Feature feature) {
return switch (feature) {
case STRING_TEMPLATES -> true;
case UNNAMED_CLASSES -> true;
case UNNAMED_VARIABLES -> true;
//Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
//When real preview features will be added, this method can be implemented to return 'true'
//for those selected features, and 'false' for all the others.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public enum Feature {
STRING_TEMPLATES(JDK21, Fragments.FeatureStringTemplates, DiagKind.PLURAL),
UNNAMED_CLASSES(JDK21, Fragments.FeatureUnnamedClasses, DiagKind.PLURAL),
WARN_ON_ILLEGAL_UTF8(MIN, JDK21),
UNNAMED_VARIABLES(JDK21, Fragments.FeatureUnnamedVariables, DiagKind.PLURAL),
UNNAMED_VARIABLES(JDK22, Fragments.FeatureUnnamedVariables, DiagKind.PLURAL),
;

enum DiagKind {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,8 @@ protected Name ident(boolean allowClass, boolean asVariable) {
log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.UseOfUnderscoreNotAllowedWithBrackets);
}
} else {
if (preview.isEnabled() && Feature.UNNAMED_VARIABLES.allowedInSource(source)) {
log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.UseOfUnderscoreNotAllowed);
if (Feature.UNNAMED_VARIABLES.allowedInSource(source)) {
log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.UseOfUnderscoreNotAllowedNonVariable);
} else {
log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.UnderscoreAsIdentifier);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3204,8 +3204,12 @@ compiler.err.underscore.as.identifier=\
as of release 9, ''_'' is a keyword, and may not be used as an identifier

compiler.err.use.of.underscore.not.allowed=\
as of release 21, the underscore keyword ''_'' is only allowed to declare\n\
unnamed patterns, local variables, exception parameters or lambda parameters
underscore not allowed here\n\
as of release 9, ''_'' is a keyword, and may not be used as an identifier\n\
as of release 22, ''_'' can be used as a name in the declaration of unnamed patterns, local variables, exception parameters or lambda parameters

compiler.err.use.of.underscore.not.allowed.non.variable=\
underscore not allowed here

compiler.err.use.of.underscore.not.allowed.with.brackets=\
the underscore keyword ''_'' is not allowed to be followed by brackets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ public void visitPatternCaseLabel(JCPatternCaseLabel tree) {
}

@Override
@PreviewFeature(feature=PreviewFeature.Feature.UNNAMED)
public void visitAnyPattern(JCAnyPattern that) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ private void makeInstrumented() {
// if (!settingsMethod(eventConfiguration.settingX)) goto fail;
codeBuilder.aload(0);
getEventConfiguration(codeBuilder);
codeBuilder.checkcast(TYPE_EVENT_CONFIGURATION);
codeBuilder.ldc(index);
invokevirtual(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_EVENT_CONFIGURATION_GET_SETTING);
MethodTypeDesc mdesc = MethodTypeDesc.ofDescriptor("(" + sd.paramType().descriptorString() + ")Z");
Expand Down Expand Up @@ -712,6 +711,7 @@ private void getEventWriter(CodeBuilder codeBuilder) {
private void getEventConfiguration(CodeBuilder codeBuilder) {
if (untypedEventConfiguration) {
codeBuilder.getstatic(getEventClassDesc(), FIELD_EVENT_CONFIGURATION.name(), TYPE_OBJECT);
codeBuilder.checkcast(TYPE_EVENT_CONFIGURATION);
} else {
codeBuilder.getstatic(getEventClassDesc(), FIELD_EVENT_CONFIGURATION.name(), TYPE_EVENT_CONFIGURATION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.text.MessageFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -596,8 +597,8 @@ static void copyPredefinedRuntimeImage(Map<String, ? super Object> params,

// copy whole runtime, need to skip jmods and src.zip
final List<String> excludes = Arrays.asList("jmods", "src.zip");
IOUtils.copyRecursive(topImage,
appLayout.runtimeHomeDirectory(), excludes);
IOUtils.copyRecursive(topImage, appLayout.runtimeHomeDirectory(),
excludes, LinkOption.NOFOLLOW_LINKS);

// if module-path given - copy modules to appDir/mods
List<Path> modulePath = MODULE_PATH.fetchFrom(params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
public class TestConflictInlineCommands {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
"-Xbatch",
"-XX:CompileCommand=inline,*TestConflictInlineCommands::caller",
"-XX:CompileCommand=dontinline,*TestConflictInlineCommands::caller",
"-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly,*Launcher::main",
Expand Down
Loading

0 comments on commit 8ac85ea

Please sign in to comment.