Skip to content

Commit

Permalink
Merge master HEAD into openj9-staging
Browse files Browse the repository at this point in the history
  • Loading branch information
j9build committed Apr 5, 2022
2 parents 57d463d + 18086f8 commit b044b72
Show file tree
Hide file tree
Showing 190 changed files with 3,046 additions and 1,387 deletions.
9 changes: 6 additions & 3 deletions make/Global.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, 2022, 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 @@ -53,14 +53,17 @@ help:
$(info $(_) make docs-jdk-api # Create just JDK javadocs)
$(info $(_) make bootcycle-images # Build images twice, second time with newly built JDK)
$(info $(_) make install # Install the generated images locally)
$(info $(_) make reconfigure # Rerun configure with the same arguments as last time)
$(info $(_) make help # Give some help on using make)
$(info $(_) make check # Run basic testing (currently tier1))
$(info $(_) make test-<test> # Run test, e.g. test-tier1)
$(info $(_) make test TEST=<t> # Run test(s) given by TEST specification)
$(info $(_) make exploded-test TEST=<t> # Run test(s) on the exploded image instead of)
$(info $(_) # the full jdk image)
$(info )
$(info Targets for troubleshooting)
$(info $(_) make help # Give some help on using make)
$(info $(_) make doctor # Diagnose build environment problems)
$(info $(_) make reconfigure # Rerun configure with the same arguments as last time)
$(info )
$(info Targets for cleaning)
$(info $(_) make clean # Remove all files generated by make, but not those)
$(info $(_) # generated by configure)
Expand Down
12 changes: 7 additions & 5 deletions src/java.base/share/classes/java/io/ObjectInput.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2022, 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 @@ -62,8 +62,9 @@ public Object readObject()
* Reads into an array of bytes. This method will
* block until some input is available.
* @param b the buffer into which the data is read
* @return the actual number of bytes read, -1 is
* returned when the end of the stream is reached.
* @return the total number of bytes read into the buffer, or
* {@code -1} if there is no more data because the end of
* the stream has been reached.
* @throws IOException If an I/O error has occurred.
*/
public int read(byte[] b) throws IOException;
Expand All @@ -74,8 +75,9 @@ public Object readObject()
* @param b the buffer into which the data is read
* @param off the start offset of the data
* @param len the maximum number of bytes read
* @return the actual number of bytes read, -1 is
* returned when the end of the stream is reached.
* @return the total number of bytes read into the buffer, or
* {@code -1} if there is no more data because the end of
* the stream has been reached.
* @throws IOException If an I/O error has occurred.
*/
public int read(byte[] b, int off, int len) throws IOException;
Expand Down
5 changes: 3 additions & 2 deletions src/java.base/share/classes/java/io/ObjectInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -1154,8 +1154,9 @@ public int read() throws IOException {
* @param buf the buffer into which the data is read
* @param off the start offset in the destination array {@code buf}
* @param len the maximum number of bytes read
* @return the actual number of bytes read, -1 is returned when the end of
* the stream is reached.
* @return the total number of bytes read into the buffer, or
* {@code -1} if there is no more data because the end of
* the stream has been reached.
* @throws NullPointerException if {@code buf} is {@code null}.
* @throws IndexOutOfBoundsException if {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
Expand Down
6 changes: 4 additions & 2 deletions src/java.base/share/classes/java/io/SequenceInputStream.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2022, 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 @@ -177,7 +177,9 @@ public int read() throws IOException {
* @param off the start offset in array {@code b}
* at which the data is written.
* @param len the maximum number of bytes read.
* @return int the number of bytes read.
* @return the total number of bytes read into the buffer, or
* {@code -1} if there is no more data because the end of
* the last contained stream has been reached.
* @throws NullPointerException If {@code b} is {@code null}.
* @throws IndexOutOfBoundsException If {@code off} is negative,
* {@code len} is negative, or {@code len} is
Expand Down
2 changes: 2 additions & 0 deletions src/java.base/share/classes/java/lang/Math.java
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ public static double pow(double a, double b) {
* @see java.lang.Integer#MAX_VALUE
* @see java.lang.Integer#MIN_VALUE
*/
@IntrinsicCandidate
public static int round(float a) {
int intBits = Float.floatToRawIntBits(a);
int biasedExp = (intBits & FloatConsts.EXP_BIT_MASK)
Expand Down Expand Up @@ -802,6 +803,7 @@ public static int round(float a) {
* @see java.lang.Long#MAX_VALUE
* @see java.lang.Long#MIN_VALUE
*/
@IntrinsicCandidate
public static long round(double a) {
long longBits = Double.doubleToRawLongBits(a);
long biasedExp = (longBits & DoubleConsts.EXP_BIT_MASK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

package jdk.internal.org.objectweb.asm;

/**
Expand Down Expand Up @@ -98,19 +99,15 @@ public AnnotationVisitor(final int api) {
* @param annotationVisitor the annotation visitor to which this visitor must delegate method
* calls. May be {@literal null}.
*/
@SuppressWarnings("deprecation")
public AnnotationVisitor(final int api, final AnnotationVisitor annotationVisitor) {
if (api != Opcodes.ASM8
if (api != Opcodes.ASM9
&& api != Opcodes.ASM8
&& api != Opcodes.ASM7
&& api != Opcodes.ASM6
&& api != Opcodes.ASM5
&& api != Opcodes.ASM4
&& api != Opcodes.ASM9_EXPERIMENTAL) {
&& api != Opcodes.ASM4) {
throw new IllegalArgumentException("Unsupported api " + api);
}
if (api == Opcodes.ASM9_EXPERIMENTAL) {
Constants.checkAsmExperimental(this);
}
this.api = api;
this.av = annotationVisitor;
}
Expand Down Expand Up @@ -162,9 +159,9 @@ public AnnotationVisitor visitAnnotation(final String name, final String descrip
}

/**
* Visits an array value of the annotation. Note that arrays of primitive types (such as byte,
* Visits an array value of the annotation. Note that arrays of primitive values (such as byte,
* boolean, short, char, int, long, float or double) can be passed as value to {@link #visit
* visit}. This is what {@link ClassReader} does.
* visit}. This is what {@link ClassReader} does for non empty arrays of primitive values.
*
* @param name the value name.
* @return a visitor to visit the actual array value elements, or {@literal null} if this visitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

package jdk.internal.org.objectweb.asm;

/**
Expand Down Expand Up @@ -143,7 +144,7 @@ final class AnnotationWriter extends AnnotationVisitor {
final boolean useNamedValues,
final ByteVector annotation,
final AnnotationWriter previousAnnotation) {
super(/* latest api = */ Opcodes.ASM8);
super(/* latest api = */ Opcodes.ASM9);
this.symbolTable = symbolTable;
this.useNamedValues = useNamedValues;
this.annotation = annotation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

package jdk.internal.org.objectweb.asm;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

package jdk.internal.org.objectweb.asm;

/**
Expand Down Expand Up @@ -390,3 +391,4 @@ private void enlarge(final int size) {
data = newData;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

package jdk.internal.org.objectweb.asm;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -119,6 +120,9 @@ public class ClassReader {
*/
static final int EXPAND_ASM_INSNS = 256;

/** The maximum size of array to allocate. */
private static final int MAX_BUFFER_SIZE = 1024 * 1024;

/** The size of the temporary byte array used to read class input streams chunk by chunk. */
private static final int INPUT_STREAM_DATA_CHUNK_SIZE = 4096;

Expand All @@ -132,6 +136,9 @@ public class ClassReader {
// DontCheck(MemberName): can't be renamed (for backward binary compatibility).
public final byte[] b;

/** The offset in bytes of the ClassFile's access_flags field. */
public final int header;

/**
* A byte array containing the JVMS ClassFile structure to be parsed. <i>The content of this array
* must not be modified. This field is intended for {@link Attribute} sub classes, and is normally
Expand Down Expand Up @@ -178,9 +185,6 @@ public class ClassReader {
*/
private final int maxStringLength;

/** The offset in bytes of the ClassFile's access_flags field. */
public final int header;

// -----------------------------------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -341,13 +345,19 @@ private static byte[] readStream(final InputStream inputStream, final boolean cl
if (inputStream == null) {
throw new IOException("Class not found");
}
int bufferSize = calculateBufferSize(inputStream);
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
byte[] data = new byte[INPUT_STREAM_DATA_CHUNK_SIZE];
byte[] data = new byte[bufferSize];
int bytesRead;
while ((bytesRead = inputStream.read(data, 0, data.length)) != -1) {
int readCount = 0;
while ((bytesRead = inputStream.read(data, 0, bufferSize)) != -1) {
outputStream.write(data, 0, bytesRead);
readCount++;
}
outputStream.flush();
if (readCount == 1) {
return data;
}
return outputStream.toByteArray();
} finally {
if (close) {
Expand All @@ -356,6 +366,20 @@ private static byte[] readStream(final InputStream inputStream, final boolean cl
}
}

private static int calculateBufferSize(final InputStream inputStream) throws IOException {
int expectedLength = inputStream.available();
/*
* Some implementations can return 0 while holding available data
* (e.g. new FileInputStream("/proc/a_file"))
* Also in some pathological cases a very small number might be returned,
* and in this case we use default size
*/
if (expectedLength < 256) {
return INPUT_STREAM_DATA_CHUNK_SIZE;
}
return Math.min(expectedLength, MAX_BUFFER_SIZE);
}

// -----------------------------------------------------------------------------------------------
// Accessors
// -----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -446,7 +470,6 @@ public void accept(final ClassVisitor classVisitor, final int parsingOptions) {
* @param parsingOptions the options to use to parse this class. One or more of {@link
* #SKIP_CODE}, {@link #SKIP_DEBUG}, {@link #SKIP_FRAMES} or {@link #EXPAND_FRAMES}.
*/
@SuppressWarnings("deprecation")
public void accept(
final ClassVisitor classVisitor,
final Attribute[] attributePrototypes,
Expand Down Expand Up @@ -710,11 +733,11 @@ public void accept(
// Visit the PermittedSubclasses attribute.
if (permittedSubclassesOffset != 0) {
int numberOfPermittedSubclasses = readUnsignedShort(permittedSubclassesOffset);
int currentPermittedSubclassOffset = permittedSubclassesOffset + 2;
int currentPermittedSubclassesOffset = permittedSubclassesOffset + 2;
while (numberOfPermittedSubclasses-- > 0) {
classVisitor.visitPermittedSubclassExperimental(
readClass(currentPermittedSubclassOffset, charBuffer));
currentPermittedSubclassOffset += 2;
classVisitor.visitPermittedSubclass(
readClass(currentPermittedSubclassesOffset, charBuffer));
currentPermittedSubclassesOffset += 2;
}
}

Expand Down Expand Up @@ -3005,7 +3028,7 @@ private int readElementValues(
// Parse the array_value array.
while (numElementValuePairs-- > 0) {
currentOffset =
readElementValue(annotationVisitor, currentOffset, /* named = */ null, charBuffer);
readElementValue(annotationVisitor, currentOffset, /* elementName= */ null, charBuffer);
}
}
if (annotationVisitor != null) {
Expand Down Expand Up @@ -3483,25 +3506,24 @@ final int getFirstAttributeOffset() {
private int[] readBootstrapMethodsAttribute(final int maxStringLength) {
char[] charBuffer = new char[maxStringLength];
int currentAttributeOffset = getFirstAttributeOffset();
int[] currentBootstrapMethodOffsets = null;
for (int i = readUnsignedShort(currentAttributeOffset - 2); i > 0; --i) {
// Read the attribute_info's attribute_name and attribute_length fields.
String attributeName = readUTF8(currentAttributeOffset, charBuffer);
int attributeLength = readInt(currentAttributeOffset + 2);
currentAttributeOffset += 6;
if (Constants.BOOTSTRAP_METHODS.equals(attributeName)) {
// Read the num_bootstrap_methods field and create an array of this size.
currentBootstrapMethodOffsets = new int[readUnsignedShort(currentAttributeOffset)];
int[] result = new int[readUnsignedShort(currentAttributeOffset)];
// Compute and store the offset of each 'bootstrap_methods' array field entry.
int currentBootstrapMethodOffset = currentAttributeOffset + 2;
for (int j = 0; j < currentBootstrapMethodOffsets.length; ++j) {
currentBootstrapMethodOffsets[j] = currentBootstrapMethodOffset;
for (int j = 0; j < result.length; ++j) {
result[j] = currentBootstrapMethodOffset;
// Skip the bootstrap_method_ref and num_bootstrap_arguments fields (2 bytes each),
// as well as the bootstrap_arguments array field (of size num_bootstrap_arguments * 2).
currentBootstrapMethodOffset +=
4 + readUnsignedShort(currentBootstrapMethodOffset + 2) * 2;
}
return currentBootstrapMethodOffsets;
return result;
}
currentAttributeOffset += attributeLength;
}
Expand Down Expand Up @@ -3860,3 +3882,4 @@ public Object readConst(final int constantPoolEntryIndex, final char[] charBuffe
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

package jdk.internal.org.objectweb.asm;

/**
Expand Down Expand Up @@ -100,3 +101,4 @@ public int getConstantPoolCount() {
return constantPoolCount;
}
}

Loading

0 comments on commit b044b72

Please sign in to comment.