Skip to content

Commit

Permalink
Merge branch 'master' into JDK-8312626
Browse files Browse the repository at this point in the history
  • Loading branch information
jianglizhou committed Jul 27, 2023
2 parents 223c3a7 + a9d21c6 commit 887760f
Show file tree
Hide file tree
Showing 30 changed files with 895 additions and 480 deletions.
3 changes: 2 additions & 1 deletion src/hotspot/cpu/aarch64/assembler_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ class Address {
if (offset % vl == 0) {
// Convert address offset into sve imm offset (MUL VL).
int64_t sve_offset = offset / vl;
if (((-(1 << (shift - 1))) <= sve_offset) && (sve_offset < (1 << (shift - 1)))) {
int32_t range = 1 << (shift - 1);
if ((-range <= sve_offset) && (sve_offset < range)) {
// sve_offset can be encoded
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/mutexLocker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ void mutex_init() {

MUTEX_DEFN(MarkStackFreeList_lock , PaddedMutex , nosafepoint);
MUTEX_DEFN(MarkStackChunkList_lock , PaddedMutex , nosafepoint);

MUTEX_DEFN(MonitoringSupport_lock , PaddedMutex , service-1); // used for serviceability monitoring support
}
MUTEX_DEFN(MonitoringSupport_lock , PaddedMutex , service-1); // used for serviceability monitoring support

MUTEX_DEFN(StringDedup_lock , PaddedMonitor, nosafepoint);
MUTEX_DEFN(StringDedupIntern_lock , PaddedMutex , nosafepoint);
MUTEX_DEFN(RawMonitor_lock , PaddedMutex , nosafepoint-1);
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/services/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2116,6 +2116,7 @@ JVM_ENTRY(jlong, jmm_GetTotalThreadAllocatedMemory(JNIEnv *env))
}

{
assert(MonitoringSupport_lock != nullptr, "Must be");
MutexLocker ml(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
if (result < high_water_result) {
// Encountered (2) above, or result wrapped to a negative value. In
Expand Down
6 changes: 4 additions & 2 deletions src/java.base/share/classes/java/nio/channels/Channels.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ public void close() throws IOException {
* Constructs a channel that reads bytes from the given stream.
*
* <p> The resulting channel will not be buffered; it will simply redirect
* its I/O operations to the given stream. Closing the channel will in
* turn cause the stream to be closed. </p>
* its I/O operations to the given stream. Reading from the resulting
* channel will read from the input stream and thus block until input is
* available or end of file is reached. Closing the channel will in turn
* cause the stream to be closed. </p>
*
* @param in
* The stream from which bytes are to be read
Expand Down
20 changes: 17 additions & 3 deletions src/java.base/share/classes/java/text/MessageFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,19 @@ public MessageFormat(String pattern) {
* Patterns and their interpretation are specified in the
* <a href="#patterns">class description</a>.
*
* @implSpec The default implementation throws a
* {@code NullPointerException} if {@code locale} is {@code null}
* either during the creation of the {@code MessageFormat} object or later
* when {@code format()} is called by a {@code MessageFormat}
* instance with a null locale and the implementation utilizes a
* locale-dependent subformat.
*
* @param pattern the pattern for this message format
* @param locale the locale for this message format
* @throws IllegalArgumentException if the pattern is invalid
* @throws NullPointerException if {@code pattern} is
* {@code null}
* {@code null} or {@code locale} is {@code null} and the
* implementation uses a locale-dependent subformat.
* @since 1.4
*/
public MessageFormat(String pattern, Locale locale) {
Expand Down Expand Up @@ -844,7 +852,10 @@ public Format[] getFormats() {
* @throws IllegalArgumentException if an argument in the
* {@code arguments} array is not of the type
* expected by the format element(s) that use it.
* @throws NullPointerException if {@code result} is {@code null}
* @throws NullPointerException if {@code result} is {@code null} or
* if the {@code MessageFormat} instance that calls this method
* has locale set to null, and the implementation
* uses a locale-dependent subformat.
*/
public final StringBuffer format(Object[] arguments, StringBuffer result,
FieldPosition pos)
Expand Down Expand Up @@ -890,7 +901,10 @@ public static String format(String pattern, Object ... arguments) {
* @throws IllegalArgumentException if an argument in the
* {@code arguments} array is not of the type
* expected by the format element(s) that use it.
* @throws NullPointerException if {@code result} is {@code null}
* @throws NullPointerException if {@code result} is {@code null} or
* if the {@code MessageFormat} instance that calls this method
* has locale set to null, and the implementation
* uses a locale-dependent subformat.
*/
public final StringBuffer format(Object arguments, StringBuffer result,
FieldPosition pos)
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/sun/security/util/DerValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,8 @@ public boolean equals(Object o) {
@Override
public String toString() {
return String.format("DerValue(%02x, %s, %d, %d)",
0xff & tag, buffer, start, end);
0xff & tag, HexFormat.of().withUpperCase().formatHex(buffer),
start, end);
}

/**
Expand Down
13 changes: 10 additions & 3 deletions src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
Original file line number Diff line number Diff line change
Expand Up @@ -1683,11 +1683,16 @@ private void handleSwitch(JCTree switchTree,
boolean stringSwitch = types.isSameType(seltype, syms.stringType);
boolean errorEnumSwitch = TreeInfo.isErrorEnumSwitch(selector, cases);
boolean intSwitch = types.isAssignable(seltype, syms.intType);
boolean errorPrimitiveSwitch = seltype.isPrimitive() && !intSwitch;
boolean patternSwitch;
if (!enumSwitch && !stringSwitch && !errorEnumSwitch && !intSwitch) {
if (!enumSwitch && !stringSwitch && !errorEnumSwitch &&
!intSwitch && !errorPrimitiveSwitch) {
preview.checkSourceLevel(selector.pos(), Feature.PATTERN_SWITCH);
patternSwitch = true;
} else {
if (errorPrimitiveSwitch) {
log.error(selector.pos(), Errors.SelectorTypeNotAllowed(seltype));
}
patternSwitch = cases.stream()
.flatMap(c -> c.labels.stream())
.anyMatch(l -> l.hasTag(PATTERNCASELABEL) ||
Expand Down Expand Up @@ -1770,7 +1775,7 @@ private void handleSwitch(JCTree switchTree,
} else if (!constants.add(s)) {
log.error(label.pos(), Errors.DuplicateCaseLabel);
}
} else if (!stringSwitch && !intSwitch) {
} else if (!stringSwitch && !intSwitch && !errorPrimitiveSwitch) {
log.error(label.pos(), Errors.ConstantLabelNotCompatible(pattype, seltype));
} else if (!constants.add(pattype.constValue())) {
log.error(c.pos(), Errors.DuplicateCaseLabel);
Expand All @@ -1793,7 +1798,9 @@ private void handleSwitch(JCTree switchTree,
if (!primaryType.hasTag(TYPEVAR)) {
primaryType = chk.checkClassOrArrayType(pat.pos(), primaryType);
}
checkCastablePattern(pat.pos(), seltype, primaryType);
if (!errorPrimitiveSwitch) {
checkCastablePattern(pat.pos(), seltype, primaryType);
}
Type patternType = types.erasure(primaryType);
JCExpression guard = c.guard;
if (guardBindings == null && guard != null) {
Expand Down
11 changes: 11 additions & 0 deletions src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
Original file line number Diff line number Diff line change
Expand Up @@ -5213,6 +5213,17 @@ public Void visitTypeAsEnum(TypeElement e,
}
}
}

// Also perform checks on any class bodies of enum constants, see JLS 8.9.1.
case ENUM_CONSTANT -> {
var field = (VarSymbol)enclosed;
JCVariableDecl decl = (JCVariableDecl) TreeInfo.declarationFor(field, p);
if (decl.init instanceof JCNewClass nc && nc.def != null) {
ClassSymbol enumConstantType = nc.def.sym;
visitTypeAsEnum(enumConstantType, p);
}
}

}});
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1569,8 +1569,15 @@ public void visitSelect(JCFieldAccess tree) {
public void visitVarDef(JCVariableDecl tree) {
TranslationContext<?> context = context();
if (context != null && context instanceof LambdaTranslationContext lambdaContext) {
if (frameStack.head.tree.hasTag(LAMBDA)) {
lambdaContext.addSymbol(tree.sym, LOCAL_VAR);
for (Frame frame : frameStack) {
if (frame.tree.hasTag(VARDEF)) {
//skip variable frames inside a lambda:
continue;
} else if (frame.tree.hasTag(LAMBDA)) {
lambdaContext.addSymbol(tree.sym, LOCAL_VAR);
} else {
break;
}
}
// Check for type variables (including as type arguments).
// If they occur within class nested in a lambda, mark for erasure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,10 @@ compiler.err.cannot.assign.not.declared.guard=\
compiler.err.constant.label.not.compatible=\
constant label of type {0} is not compatible with switch selector type {1}

# 0: type
compiler.err.selector.type.not.allowed=\
selector type {0} is not allowed

compiler.err.flows.through.to.pattern=\
illegal fall-through to a pattern

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import javax.lang.model.element.QualifiedNameable;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.ArrayType;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.SimpleAnnotationValueVisitor9;
Expand Down Expand Up @@ -90,6 +91,7 @@
import jdk.javadoc.internal.doclets.formats.html.markup.Script;
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
import jdk.javadoc.internal.doclets.formats.html.markup.Text;
import jdk.javadoc.internal.doclets.formats.html.markup.TextBuilder;
import jdk.javadoc.internal.doclets.formats.html.taglets.Taglet;
import jdk.javadoc.internal.doclets.formats.html.taglets.TagletWriter;
import jdk.javadoc.internal.doclets.toolkit.Messages;
Expand Down Expand Up @@ -1868,23 +1870,24 @@ private Content annotationValueToContent(AnnotationValue annotationValue) {
return new SimpleAnnotationValueVisitor9<Content, Void>() {

@Override
public Content visitType(TypeMirror t, Void p) {
public Content visitType(TypeMirror type, Void p) {
return new SimpleTypeVisitor9<Content, Void>() {
@Override
public Content visitDeclared(DeclaredType t, Void p) {
HtmlLinkInfo linkInfo = new HtmlLinkInfo(configuration,
HtmlLinkInfo.Kind.PLAIN, t);
String name = utils.isIncluded(t.asElement())
? t.asElement().getSimpleName().toString()
: utils.getFullyQualifiedName(t.asElement());
linkInfo.label(name + utils.getDimension(t) + ".class");
return getLink(linkInfo);
}
@Override
protected Content defaultAction(TypeMirror e, Void p) {
return Text.of(t + utils.getDimension(t) + ".class");
public Content visitArray(ArrayType t, Void p) {
// render declared base component type as link
return visit(t.getComponentType()).add("[]");
}
}.visit(t);
@Override
protected Content defaultAction(TypeMirror t, Void p) {
return new TextBuilder(t.toString());
}
}.visit(type).add(".class");
}

@Override
Expand Down
15 changes: 10 additions & 5 deletions src/jdk.jpackage/share/native/common/app.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -35,7 +35,7 @@
namespace {
const std::string* theLastErrorMsg = 0;

NopLogAppender nopLogAppender;
char nopLogAppenderMemory[sizeof(NopLogAppender)] = {};

class StandardLogAppender : public LogAppender {
public:
Expand All @@ -46,7 +46,9 @@ class StandardLogAppender : public LogAppender {
<< ": " << v.message
<< std::endl;
}
} standardLogAppender;
};

char standardLogAppenderMemory[sizeof(StandardLogAppender)] = {};

class LastErrorLogAppender : public LogAppender {
public:
Expand Down Expand Up @@ -114,10 +116,13 @@ bool isWithLogging() {

int launch(const std::nothrow_t&,
LauncherFunc func, LogAppender* lastErrorLogAppender) {
// The log appender is set for the lifetime of the application.
// Use in-place new to avoid accessing destroyed instance
// when the shared object destructor logs something.
if (isWithLogging()) {
Logger::defaultLogger().setAppender(standardLogAppender);
Logger::defaultLogger().setAppender(*new (standardLogAppenderMemory) StandardLogAppender());
} else {
Logger::defaultLogger().setAppender(nopLogAppender);
Logger::defaultLogger().setAppender(*new (nopLogAppenderMemory) NopLogAppender());
}

LOG_TRACE_FUNCTION();
Expand Down
3 changes: 1 addition & 2 deletions test/hotspot/jtreg/serviceability/attach/ShMemLongName.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
Expand Down Expand Up @@ -95,7 +95,6 @@ private static void log(String s) {
private static ProcessBuilder getTarget(String shmemName) throws IOException {
log("starting target with shmem name: '" + shmemName + "'...");
return ProcessTools.createJavaProcessBuilder(
"-Xdebug",
"-Xrunjdwp:transport=" + transport + ",server=y,suspend=n,address=" + shmemName,
"ShMemLongName$Target");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void run(CommandExecutor executor) {
if (Platform.isMusl()) {
output.shouldContain("Not available");
} else {
output.shouldMatch("Trim native heap: RSS\\+Swap: \\d+[BKMG]->\\d+[BKMG] \\(-\\d+[BKMG]\\)");
output.shouldMatch("Trim native heap: RSS\\+Swap: \\d+[BKMG]->\\d+[BKMG] \\([+-]\\d+[BKMG]\\)");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
Expand Down Expand Up @@ -92,7 +92,6 @@ private static Process startDebuggee(String[] jdiArgs, String transport, String
Collections.addAll(cmd, Utils.prependTestJavaOpts(
"-cp",
Utils.TEST_CLASS_PATH,
"-Xdebug",
"-agentlib:jdwp=transport=" + transport + ",server=y,suspend=" + suspend,
"-Dmy.little.cookie=" + ProcessHandle.current().pid(),
debuggeeClass.getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,6 @@ public String[] makeCommandLineArgs(String classToExecute, String transportAddre
args.add(classPath);
*/

args.add("-Xdebug");

String server;
if (argumentHandler.isAttachingConnector()) {
server = "y";
Expand Down
2 changes: 2 additions & 0 deletions test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java 8151492 generic-
java/lang/invoke/LFCaching/LFGarbageCollectedTest.java 8078602 generic-all
java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-x64
java/lang/invoke/RicochetTest.java 8251969 generic-all
java/lang/invoke/MethodHandleProxies/BasicTest.java 8312482 linux-all
java/lang/invoke/MethodHandleProxies/WrapperHiddenClassTest.java 8312482 linux-all

############################################################################

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@
*/

/*
* @test
* @bug 6173675 8231209 8304074
* @test id=G1
* @bug 6173675 8231209 8304074 8313081
* @summary Basic test of ThreadMXBean.getThreadAllocatedBytes
* @author Paul Hohensee
* @requires vm.gc.G1
* @run main/othervm -XX:+UseG1GC ThreadAllocatedMemory
*/

/*
* @test id=Serial
* @bug 6173675 8231209 8304074 8313081
* @summary Basic test of ThreadMXBean.getThreadAllocatedBytes
* @requires vm.gc.Serial
* @run main/othervm -XX:+UseSerialGC ThreadAllocatedMemory
*/

import java.lang.management.*;
Expand Down
Loading

0 comments on commit 887760f

Please sign in to comment.