Skip to content

Commit

Permalink
Merge master HEAD into openj9-staging
Browse files Browse the repository at this point in the history
Signed-off-by: J9 Build <j9build@ca.ibm.com>
  • Loading branch information
j9build committed Jun 5, 2024
2 parents 2bce8e5 + 8bd2e2b commit 92d8c0a
Show file tree
Hide file tree
Showing 83 changed files with 2,432 additions and 616 deletions.
2 changes: 0 additions & 2 deletions src/java.base/share/classes/java/io/PrintStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,6 @@ private void implWrite(byte[] buf, int off, int len) throws IOException {
*
* @see #writeBytes(byte[])
* @see #write(byte[],int,int)
*
* @since 14
*/
@Override
public void write(byte[] buf) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public sealed interface ClassReader extends ConstantPool
* @param cls the entry type
* @throws ConstantPoolException if the index is out of range of the
* constant pool size, or zero, or the entry is not of the given type
* @since 24
* @since 23
*/
<T extends PoolEntry> T readEntryOrNull(int offset, Class<T> cls);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public sealed interface ConstantPool extends Iterable<PoolEntry>
* @param cls the entry type
* @throws ConstantPoolException if the index is out of range of the
* constant pool, or the entry is not of the given type
* @since 24
* @since 23
*/
<T extends PoolEntry> T entryByIndex(int index, Class<T> cls);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ private String getInternalName(Class<?> c) {
else if (c == Object[].class) return OBJARY;
else if (c == Class.class) return CLS;
else if (c == MethodHandle.class) return MH;
assert(VerifyAccess.isTypeVisible(c, Object.class)) : c.getName();
assert(VerifyAccess.ensureTypeVisible(c, Object.class)) : c.getName();

if (c == lastClass) {
return lastInternalName;
Expand Down
8 changes: 4 additions & 4 deletions src/java.base/share/classes/java/lang/invoke/MemberName.java
Original file line number Diff line number Diff line change
Expand Up @@ -806,23 +806,23 @@ void initResolved(boolean isResolved) {
assert(isResolved() == isResolved);
}

void checkForTypeAlias(Class<?> refc) {
void ensureTypeVisible(Class<?> refc) {
if (isInvocable()) {
MethodType type;
if (this.type instanceof MethodType mt)
type = mt;
else
this.type = type = getMethodType();
if (type.erase() == type) return;
if (VerifyAccess.isTypeVisible(type, refc)) return;
if (VerifyAccess.ensureTypeVisible(type, refc)) return;
throw new LinkageError("bad method type alias: "+type+" not visible from "+refc);
} else {
Class<?> type;
if (this.type instanceof Class<?> cl)
type = cl;
else
this.type = type = getFieldType();
if (VerifyAccess.isTypeVisible(type, refc)) return;
if (VerifyAccess.ensureTypeVisible(type, refc)) return;
throw new LinkageError("bad field type alias: "+type+" not visible from "+refc);
}
}
Expand Down Expand Up @@ -964,7 +964,7 @@ private MemberName resolve(byte refKind, MemberName ref, Class<?> lookupClass, i
if (m == null && speculativeResolve) {
return null;
}
m.checkForTypeAlias(m.getDeclaringClass());
m.ensureTypeVisible(m.getDeclaringClass());
m.resolution = null;
} catch (ClassNotFoundException | LinkageError ex) {
// JVM reports that the "bytecode behavior" would get an error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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 @@ -7925,6 +7925,8 @@ private static void tryFinallyChecks(MethodHandle target, MethodHandle cleanup)
* handles is not {@code int}, or if the types of
* the fallback handle and all of target handles are
* not the same.
*
* @since 17
*/
public static MethodHandle tableSwitch(MethodHandle fallback, MethodHandle... targets) {
Objects.requireNonNull(fallback);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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 @@ -50,6 +50,8 @@ public MalformedParameterizedTypeException() {
* Constructs a {@code MalformedParameterizedTypeException} with
* the given detail message.
* @param message the detail message; may be {@code null}
*
* @since 10
*/
public MalformedParameterizedTypeException(String message) {
super(message);
Expand Down
8 changes: 8 additions & 0 deletions src/java.base/share/classes/java/nio/MappedByteBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ public final MappedByteBuffer rewind() {
* {@code force()} on the returned buffer, will only act on the sub-range
* of this buffer that the returned buffer represents, namely
* {@code [position(),limit())}.
*
* @since 17
*/
@Override
public abstract MappedByteBuffer slice();
Expand All @@ -410,19 +412,25 @@ public final MappedByteBuffer rewind() {
* of this buffer that the returned buffer represents, namely
* {@code [index,index+length)}, where {@code index} and {@code length} are
* assumed to satisfy the preconditions.
*
* @since 17
*/
@Override
public abstract MappedByteBuffer slice(int index, int length);

/**
* {@inheritDoc}
*
* @since 17
*/
@Override
public abstract MappedByteBuffer duplicate();

/**
* {@inheritDoc}
* @throws ReadOnlyBufferException {@inheritDoc}
*
* @since 17
*/
@Override
public abstract MappedByteBuffer compact();
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/util/Properties.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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 @@ -185,6 +185,7 @@ public Properties() {
* accommodate this many elements
* @throws IllegalArgumentException if the initial capacity is less than
* zero.
* @since 10
*/
public Properties(int initialCapacity) {
this(null, initialCapacity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ public float nextFloat() {
* {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @implNote {@inheritDoc}
*
* @since 17
*/
@Override
public float nextFloat(float bound) {
Expand All @@ -510,6 +512,8 @@ public float nextFloat(float bound) {
* {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @implNote {@inheritDoc}
*
* @since 17
*/
@Override
public float nextFloat(float origin, float bound) {
Expand Down
2 changes: 2 additions & 0 deletions src/java.base/share/classes/java/util/zip/Deflater.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ public void setDictionary(byte[] dictionary) {
* @param dictionary the dictionary data bytes
* @see Inflater#inflate
* @see Inflater#getAdler()
*
* @since 11
*/
public void setDictionary(ByteBuffer dictionary) {
synchronized (zsRef) {
Expand Down
22 changes: 12 additions & 10 deletions src/java.base/share/classes/sun/invoke/util/VerifyAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public static boolean isModuleAccessible(Class<?> refc, Module m1, Module m2) {
* @param type the supposed type of a member or symbolic reference of refc
* @param refc the class attempting to make the reference
*/
public static boolean isTypeVisible(Class<?> type, Class<?> refc) {
public static boolean ensureTypeVisible(Class<?> type, Class<?> refc) {
if (type == refc) {
return true; // easy check
}
Expand All @@ -284,12 +284,14 @@ public static boolean isTypeVisible(Class<?> type, Class<?> refc) {
if (refcLoader == null && typeLoader != null) {
return false;
}
if (typeLoader == null && type.getName().startsWith("java.")) {
// Note: The API for actually loading classes, ClassLoader.defineClass,
// guarantees that classes with names beginning "java." cannot be aliased,
// because class loaders cannot load them directly.
return true;
}

// The API for actually loading classes, ClassLoader.defineClass,
// guarantees that classes with names beginning "java." cannot be aliased,
// because class loaders cannot load them directly. However, it is beneficial
// for JIT-compilers to ensure all signature classes are loaded.
// JVM doesn't install any loader contraints when performing MemberName resolution,
// so eagerly resolving signature classes is a way to match what JVM achieves
// with loader constraints during method resolution for invoke bytecodes.

// Do it the hard way: Look up the type name from the refc loader.
//
Expand Down Expand Up @@ -338,12 +340,12 @@ public Class<?> run() {
* @param type the supposed type of a member or symbolic reference of refc
* @param refc the class attempting to make the reference
*/
public static boolean isTypeVisible(java.lang.invoke.MethodType type, Class<?> refc) {
if (!isTypeVisible(type.returnType(), refc)) {
public static boolean ensureTypeVisible(java.lang.invoke.MethodType type, Class<?> refc) {
if (!ensureTypeVisible(type.returnType(), refc)) {
return false;
}
for (int n = 0, max = type.parameterCount(); n < max; n++) {
if (!isTypeVisible(type.parameterType(n), refc)) {
if (!ensureTypeVisible(type.parameterType(n), refc)) {
return false;
}
}
Expand Down
40 changes: 40 additions & 0 deletions src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import javax.print.attribute.standard.MediaPrintableArea;
import javax.print.attribute.standard.MediaSize;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.OutputBin;
import javax.print.attribute.standard.PageRanges;
import javax.print.attribute.standard.Sides;
import javax.print.attribute.Attribute;
Expand All @@ -70,6 +71,8 @@ public final class CPrinterJob extends RasterPrinterJob {

private String tray = null;

private String outputBin = null;

// This is the NSPrintInfo for this PrinterJob. Protect multi thread
// access to it. It is used by the pageDialog, jobDialog, and printLoop.
// This way the state of these items is shared across these calls.
Expand Down Expand Up @@ -191,6 +194,8 @@ protected void setAttributes(PrintRequestAttributeSet attributes) throws Printer
tray = customTray.getChoiceName();
}

outputBin = getOutputBinValue(attributes.get(OutputBin.class));

PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
if (isSupportedValue(pageRangesAttr, attributes)) {
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
Expand Down Expand Up @@ -658,6 +663,41 @@ private String getPrinterTray() {
return tray;
}

private String getOutputBin() {
return outputBin;
}

private void setOutputBin(String outputBinName) {

OutputBin outputBin = toOutputBin(outputBinName);
if (outputBin != null) {
attributes.add(outputBin);
}
}

private OutputBin toOutputBin(String outputBinName) {

PrintService ps = getPrintService();
if (ps == null) {
return null;
}

OutputBin[] supportedBins = (OutputBin[]) ps.getSupportedAttributeValues(OutputBin.class, null, null);
if (supportedBins == null || supportedBins.length == 0) {
return null;
}

for (OutputBin bin : supportedBins) {
if (bin instanceof CustomOutputBin customBin){
if (customBin.getChoiceName().equals(outputBinName)) {
return customBin;
}
}
}

return null;
}

private void setPrinterServiceFromNative(String printerName) {
// This is called from the native side.
PrintService[] services = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
Expand Down
18 changes: 18 additions & 0 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject d
DECLARE_METHOD(jm_setPrintToFile, sjc_CPrinterJob, "setPrintToFile", "(Z)V");
DECLARE_METHOD(jm_setDestinationFile, sjc_CPrinterJob, "setDestinationFile", "(Ljava/lang/String;)V");
DECLARE_METHOD(jm_setSides, sjc_CPrinterJob, "setSides", "(I)V");
DECLARE_METHOD(jm_setOutputBin, sjc_CPrinterJob, "setOutputBin", "(Ljava/lang/String;)V");

// get the selected printer's name, and set the appropriate PrintService on the Java side
NSString *name = [[src printer] name];
Expand Down Expand Up @@ -449,6 +450,13 @@ static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject d
(*env)->CallVoidMethod(env, dstPrinterJob, jm_setSides, sides); // AWT_THREADING Safe (known object)
CHECK_EXCEPTION();
}

NSString* outputBin = [[src printSettings] objectForKey:@"OutputBin"];
if (outputBin != nil) {
jstring outputBinName = NSStringToJavaString(env, outputBin);
(*env)->CallVoidMethod(env, dstPrinterJob, jm_setOutputBin, outputBinName);
CHECK_EXCEPTION();
}
}
}

Expand All @@ -468,6 +476,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
DECLARE_METHOD(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;");
DECLARE_METHOD(jm_getDestinationFile, sjc_CPrinterJob, "getDestinationFile", "()Ljava/lang/String;");
DECLARE_METHOD(jm_getSides, sjc_CPrinterJob, "getSides", "()I");
DECLARE_METHOD(jm_getOutputBin, sjc_CPrinterJob, "getOutputBin", "()Ljava/lang/String;");


NSMutableDictionary* printingDictionary = [dst dictionary];
Expand Down Expand Up @@ -538,6 +547,15 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
[dst updateFromPMPrintSettings];
}
}

jobject outputBin = (*env)->CallObjectMethod(env, srcPrinterJob, jm_getOutputBin);
CHECK_EXCEPTION();
if (outputBin != NULL) {
NSString *nsOutputBinStr = JavaStringToNSString(env, outputBin);
if (nsOutputBinStr != nil) {
[[dst printSettings] setObject:nsOutputBinStr forKey:@"OutputBin"];
}
}
}

/*
Expand Down
Loading

0 comments on commit 92d8c0a

Please sign in to comment.