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 Jun 25, 2024
2 parents 8efbf2f + 37ebece commit 8295237
Show file tree
Hide file tree
Showing 19 changed files with 393 additions and 148 deletions.
4 changes: 4 additions & 0 deletions src/hotspot/share/gc/z/zDirector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ static bool rule_major_allocation_rate(const ZDirectorStats& stats) {
}

static double calculate_young_to_old_worker_ratio(const ZDirectorStats& stats) {
if (!stats._old_stats._cycle._is_time_trustable) {
return 1.0;
}

const double young_gc_time = gc_time(stats._young_stats);
const double old_gc_time = gc_time(stats._old_stats);
const size_t reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg;
Expand Down
16 changes: 9 additions & 7 deletions src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ Java_sun_awt_windows_WPageDialogPeer__1show(JNIEnv *env, jobject peer)
AwtComponent *awtParent = (parent != NULL) ? (AwtComponent *)JNI_GET_PDATA(parent) : NULL;
HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL;

jboolean doIt = JNI_FALSE;
PAGESETUPDLG setup;
memset(&setup, 0, sizeof(setup));

Expand Down Expand Up @@ -577,7 +578,7 @@ Java_sun_awt_windows_WPageDialogPeer__1show(JNIEnv *env, jobject peer)
*/
if ((setup.hDevMode == NULL) && (setup.hDevNames == NULL)) {
CLEANUP_SHOW;
return JNI_FALSE;
return doIt;
}
} else {
int measure = PSD_INTHOUSANDTHSOFINCHES;
Expand Down Expand Up @@ -605,7 +606,7 @@ Java_sun_awt_windows_WPageDialogPeer__1show(JNIEnv *env, jobject peer)
pageFormatToSetup(env, self, page, &setup, AwtPrintControl::getPrintDC(env, self));
if (env->ExceptionCheck()) {
CLEANUP_SHOW;
return JNI_FALSE;
return doIt;
}

setup.lpfnPageSetupHook = reinterpret_cast<LPPAGESETUPHOOK>(pageDlgHook);
Expand All @@ -619,7 +620,7 @@ Java_sun_awt_windows_WPageDialogPeer__1show(JNIEnv *env, jobject peer)
jobject paper = getPaper(env, page);
if (paper == NULL) {
CLEANUP_SHOW;
return JNI_FALSE;
return doIt;
}
int units = setup.Flags & PSD_INTHOUSANDTHSOFINCHES ?
MM_HIENGLISH :
Expand Down Expand Up @@ -661,7 +662,7 @@ Java_sun_awt_windows_WPageDialogPeer__1show(JNIEnv *env, jobject peer)
setPaperValues(env, paper, &paperSize, &margins, units);
if (env->ExceptionCheck()) {
CLEANUP_SHOW;
return JNI_FALSE;
return doIt;
}
/*
* Put the updated Paper instance and the orientation into
Expand All @@ -670,7 +671,7 @@ Java_sun_awt_windows_WPageDialogPeer__1show(JNIEnv *env, jobject peer)
setPaper(env, page, paper);
if (env->ExceptionCheck()) {
CLEANUP_SHOW;
return JNI_FALSE;
return doIt;
}
setPageFormatOrientation(env, page, orientation);
if (env->ExceptionCheck()) {
Expand All @@ -684,12 +685,13 @@ Java_sun_awt_windows_WPageDialogPeer__1show(JNIEnv *env, jobject peer)
jboolean err = setPrintPaperSize(env, self, devmode->dmPaperSize);
if (err) {
CLEANUP_SHOW;
return JNI_FALSE;
return doIt;
}
}
}
::GlobalUnlock(setup.hDevMode);
}
doIt = JNI_TRUE;
}

AwtDialog::CheckUninstallModalHook();
Expand All @@ -708,7 +710,7 @@ Java_sun_awt_windows_WPageDialogPeer__1show(JNIEnv *env, jobject peer)

CLEANUP_SHOW;

return JNI_TRUE;
return doIt;

CATCH_BAD_ALLOC_RET(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ public void visitClassDef(JCClassDecl tree) {
Optional.ofNullable(env.info.attributionMode.isSpeculative ?
argumentAttr.withLocalCacheContext() : null);
boolean ctorProloguePrev = env.info.ctorPrologue;
env.info.ctorPrologue = false;
try {
// Local and anonymous classes have not been entered yet, so we need to
// do it now.
Expand Down Expand Up @@ -994,7 +995,7 @@ public void visitMethodDef(JCMethodDecl tree) {
Lint lint = env.info.lint.augment(m);
Lint prevLint = chk.setLint(lint);
boolean ctorProloguePrev = env.info.ctorPrologue;
Assert.check(!env.info.ctorPrologue);
env.info.ctorPrologue = false;
MethodSymbol prevMethod = chk.setMethod(m);
try {
deferredLintHandler.flush(tree.pos(), lint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ public Env<AttrContext> classEnv(JCClassDecl tree, Env<AttrContext> env) {
localEnv.info.lint = null; // leave this to be filled in by Attr,
// when annotations have been processed
localEnv.info.isAnonymousDiamond = TreeInfo.isDiamond(env.tree);
localEnv.info.ctorPrologue = false;
return localEnv;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
Expand Down Expand Up @@ -208,7 +208,7 @@ public void write(Attribute<?> a, CodeAttribute lr) {
indent(+1);
first = false;
}
for (var flag : info.flags()) {
for (var flag : maskToAccessFlagsReportUnknown(access_flags, AccessFlag.Location.INNER_CLASS)) {
if (flag.sourceModifier() && (flag != AccessFlag.ABSTRACT
|| !info.has(AccessFlag.INTERFACE))) {
print(Modifier.toString(flag.mask()) + " ");
Expand Down
42 changes: 41 additions & 1 deletion src/jdk.jdeps/share/classes/com/sun/tools/javap/BasicWriter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
Expand All @@ -26,6 +26,12 @@
package com.sun.tools.javap;

import java.io.PrintWriter;
import java.lang.classfile.AccessFlags;
import java.lang.reflect.AccessFlag;
import java.lang.reflect.Modifier;
import java.util.EnumMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;

/*
Expand All @@ -38,6 +44,26 @@
* deletion without notice.</b>
*/
public class BasicWriter {
private static final Map<AccessFlag.Location, Integer> LOCATION_MASKS;

static {
var map = new EnumMap<AccessFlag.Location, Integer>(AccessFlag.Location.class);
for (var loc : AccessFlag.Location.values()) {
map.put(loc, 0);
}

for (var flag : AccessFlag.values()) {
for (var loc : flag.locations()) {
map.compute(loc, (_, v) -> v | flag.mask());
}
}

// Peculiarities from AccessFlag.maskToAccessFlag
map.compute(AccessFlag.Location.METHOD, (_, v) -> v | Modifier.STRICT);

LOCATION_MASKS = map;
}

protected BasicWriter(Context context) {
lineWriter = LineWriter.instance(context);
out = context.get(PrintWriter.class);
Expand All @@ -46,6 +72,20 @@ protected BasicWriter(Context context) {
throw new AssertionError();
}

protected Set<AccessFlag> flagsReportUnknown(AccessFlags flags) {
return maskToAccessFlagsReportUnknown(flags.flagsMask(), flags.location());
}

protected Set<AccessFlag> maskToAccessFlagsReportUnknown(int mask, AccessFlag.Location location) {
try {
return AccessFlag.maskToAccessFlags(mask, location);
} catch (IllegalArgumentException ex) {
mask &= LOCATION_MASKS.get(location);
report("Access Flags: " + ex.getMessage());
return AccessFlag.maskToAccessFlags(mask, location);
}
}

protected void print(String s) {
lineWriter.print(s);
}
Expand Down
70 changes: 13 additions & 57 deletions src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ protected void writeField(FieldModel f) {
return;

var flags = AccessFlags.ofField(f.flags().flagsMask());
writeModifiers(flags.flags().stream().filter(fl -> fl.sourceModifier())
writeModifiers(flagsReportUnknown(flags).stream().filter(fl -> fl.sourceModifier())
.map(fl -> Modifier.toString(fl.mask())).toList());
print(() -> sigPrinter.print(
f.findAttribute(Attributes.signature())
Expand Down Expand Up @@ -446,7 +446,7 @@ protected void writeField(FieldModel f) {

if (options.verbose)
writeList(String.format("flags: (0x%04x) ", flags.flagsMask()),
flags.flags().stream().map(fl -> "ACC_" + fl.name()).toList(),
flagsReportUnknown(flags).stream().map(fl -> "ACC_" + fl.name()).toList(),
"\n");

if (options.showAllAttrs) {
Expand Down Expand Up @@ -478,7 +478,7 @@ protected void writeMethod(MethodModel m) {
int flags = m.flags().flagsMask();

var modifiers = new ArrayList<String>();
for (var f : AccessFlags.ofMethod(flags).flags())
for (var f : flagsReportUnknown(m.flags()))
if (f.sourceModifier()) modifiers.add(Modifier.toString(f.mask()));

String name = "???";
Expand Down Expand Up @@ -561,7 +561,7 @@ protected void writeMethod(MethodModel m) {
StringBuilder sb = new StringBuilder();
String sep = "";
sb.append(String.format("flags: (0x%04x) ", flags));
for (var f : AccessFlags.ofMethod(flags).flags()) {
for (var f : flagsReportUnknown(m.flags())) {
sb.append(sep).append("ACC_").append(f.name());
sep = ", ";
}
Expand Down Expand Up @@ -794,17 +794,9 @@ else switch (c) {
}
}

private static Set<String> getClassModifiers(int mask) {
return getModifiers(AccessFlags.ofClass((mask & ACC_INTERFACE) != 0
? mask & ~ACC_ABSTRACT : mask).flags());
}

private static Set<String> getMethodModifiers(int mask) {
return getModifiers(AccessFlags.ofMethod(mask).flags());
}

private static Set<String> getFieldModifiers(int mask) {
return getModifiers(AccessFlags.ofField(mask).flags());
private Set<String> getClassModifiers(int mask) {
return getModifiers(flagsReportUnknown(AccessFlags.ofClass((mask & ACC_INTERFACE) != 0
? mask & ~ACC_ABSTRACT : mask)));
}

private static Set<String> getModifiers(Set<java.lang.reflect.AccessFlag> flags) {
Expand All @@ -814,16 +806,16 @@ private static Set<String> getModifiers(Set<java.lang.reflect.AccessFlag> flags)
return s;
}

private static Set<String> getClassFlags(int mask) {
return getFlags(mask, AccessFlags.ofClass(mask).flags());
private Set<String> getClassFlags(int mask) {
return getFlags(mask, flagsReportUnknown(AccessFlags.ofClass(mask)));
}

private static Set<String> getMethodFlags(int mask) {
return getFlags(mask, AccessFlags.ofMethod(mask).flags());
private Set<String> getMethodFlags(int mask) {
return getFlags(mask, flagsReportUnknown(AccessFlags.ofMethod(mask)));
}

private static Set<String> getFieldFlags(int mask) {
return getFlags(mask, AccessFlags.ofField(mask).flags());
private Set<String> getFieldFlags(int mask) {
return getFlags(mask, flagsReportUnknown(AccessFlags.ofField(mask)));
}

private static Set<String> getFlags(int mask, Set<java.lang.reflect.AccessFlag> flags) {
Expand All @@ -840,42 +832,6 @@ private static Set<String> getFlags(int mask, Set<java.lang.reflect.AccessFlag>
return s;
}

public static enum AccessFlag {
ACC_PUBLIC (ClassFile.ACC_PUBLIC, "public", true, true, true, true ),
ACC_PRIVATE (ClassFile.ACC_PRIVATE, "private", false, true, true, true ),
ACC_PROTECTED (ClassFile.ACC_PROTECTED, "protected", false, true, true, true ),
ACC_STATIC (ClassFile.ACC_STATIC, "static", false, true, true, true ),
ACC_FINAL (ClassFile.ACC_FINAL, "final", true, true, true, true ),
ACC_SUPER (ClassFile.ACC_SUPER, null, true, false, false, false),
ACC_SYNCHRONIZED(ClassFile.ACC_SYNCHRONIZED, "synchronized", false, false, false, true ),
ACC_VOLATILE (ClassFile.ACC_VOLATILE, "volatile", false, false, true, false),
ACC_BRIDGE (ClassFile.ACC_BRIDGE, null, false, false, false, true ),
ACC_TRANSIENT (ClassFile.ACC_TRANSIENT, "transient", false, false, true, false),
ACC_VARARGS (ClassFile.ACC_VARARGS, null, false, false, false, true ),
ACC_NATIVE (ClassFile.ACC_NATIVE, "native", false, false, false, true ),
ACC_INTERFACE (ClassFile.ACC_INTERFACE, null, true, true, false, false),
ACC_ABSTRACT (ClassFile.ACC_ABSTRACT, "abstract", true, true, false, true ),
ACC_STRICT (ClassFile.ACC_STRICT, "strictfp", false, false, false, true ),
ACC_SYNTHETIC (ClassFile.ACC_SYNTHETIC, null, true, true, true, true ),
ACC_ANNOTATION (ClassFile.ACC_ANNOTATION, null, true, true, false, false),
ACC_ENUM (ClassFile.ACC_ENUM, null, true, true, true, false),
ACC_MODULE (ClassFile.ACC_MODULE, null, true, false, false, false);

public final int flag;
public final String modifier;
public final boolean isClass, isInnerClass, isField, isMethod;

AccessFlag(int flag, String modifier, boolean isClass,
boolean isInnerClass, boolean isField, boolean isMethod) {
this.flag = flag;
this.modifier = modifier;
this.isClass = isClass;
this.isInnerClass = isInnerClass;
this.isField = isField;
this.isMethod = isMethod;
}
}

private final Options options;
private final AttributeWriter attrWriter;
private final CodeWriter codeWriter;
Expand Down
58 changes: 58 additions & 0 deletions test/jdk/java/awt/print/PrinterJob/PageDialogCancelTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8334366
* @key headful printer
* @summary Verifies original pageobject is returned unmodified
* on cancelling pagedialog
* @requires (os.family == "windows")
* @run main PageDialogCancelTest
*/

import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;

public class PageDialogCancelTest {

public static void main(String[] args) throws Exception {
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat oldFormat = new PageFormat();
Robot robot = new Robot();
Thread t1 = new Thread(() -> {
robot.delay(2000);
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
robot.waitForIdle();
});
t1.start();
PageFormat newFormat = pj.pageDialog(oldFormat);
if (!newFormat.equals(oldFormat)) {
throw new RuntimeException("Original PageFormat not returned on cancelling PageDialog");
}
}
}

Loading

0 comments on commit 8295237

Please sign in to comment.