Compare commits

...

9 Commits

Author SHA1 Message Date
Adam Sotona
a55e18baf0 8321641: ClassFile ModuleAttribute.ModuleAttributeBuilder::moduleVersion spec contains a copy-paste error
Reviewed-by: alanb
Backport-of: 3c6459e1de
2023-12-13 08:48:44 +00:00
Christian Stein
ae77bd009f 8321739: Source launcher fails with "Not a directory" error
Reviewed-by: jlahoda
Backport-of: df4ed7eff7
2023-12-12 21:07:56 +00:00
Jorn Vernee
9f0469b94a 8320886: Unsafe_SetMemory0 is not guarded
Reviewed-by: shade
Backport-of: ce4b257fa5
2023-12-12 14:26:38 +00:00
Thomas Schatzl
379a8bbb5d 8321422: Test gc/g1/pinnedobjs/TestPinnedObjectTypes.java times out after completion
Reviewed-by: ayang, iwalulya
Backport-of: 7d903964fb
2023-12-12 11:09:28 +00:00
Per Minborg
e88a022072 8321387: SegmentAllocator:allocateFrom(AddressLayout, MemorySegment) does not throw stated UnsupportedOperationException
Reviewed-by: mcimadamore
Backport-of: d13302f8b0
2023-12-11 16:43:40 +00:00
Martin Doerr
cbec97c945 8321539: Minimal build is broken by JDK-8320935
Reviewed-by: iklam
Backport-of: 5e6bfc5eaa
2023-12-09 00:04:14 +00:00
Naoto Sato
e5684da6e5 8321409: Console read line with zero out should zero out underlying buffer in JLine (redux)
Reviewed-by: alanb
Backport-of: 4ed38f5ad5
2023-12-08 18:15:10 +00:00
Jaikiran Pai
508d04f71f 8316738: java/net/httpclient/HttpClientLocalAddrTest.java failed in timeout
Reviewed-by: dfuchs
Backport-of: f577385fc8
2023-12-08 11:03:34 +00:00
Weijun Wang
7de0fb3613 8320597: RSA signature verification fails on signed data that does not encode params correctly
Reviewed-by: valeriep
Backport-of: 11e4a925be
2023-12-08 03:01:17 +00:00
26 changed files with 217 additions and 75 deletions

View File

@@ -920,6 +920,7 @@ address Assembler::locate_operand(address inst, WhichOperand which) {
case 0x11: // movups
case 0x12: // movlps
case 0x28: // movaps
case 0x29: // movaps
case 0x2E: // ucomiss
case 0x2F: // comiss
case 0x54: // andps
@@ -969,7 +970,7 @@ address Assembler::locate_operand(address inst, WhichOperand which) {
assert(which == call32_operand, "jcc has no disp32 or imm");
return ip;
default:
ShouldNotReachHere();
fatal("not handled: 0x0F%2X", 0xFF & *(ip-1));
}
break;

View File

@@ -52,7 +52,7 @@ public:
static void initialize() NOT_CDS_RETURN;
static void check_system_property(const char* key, const char* value) NOT_CDS_RETURN;
static void check_unsupported_dumping_properties() NOT_CDS_RETURN;
static bool check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) NOT_CDS_RETURN_(false);
static bool check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);
// Basic CDS features
static bool is_dumping_archive() { return is_dumping_static_archive() || is_dumping_dynamic_archive(); }

View File

@@ -390,7 +390,10 @@ UNSAFE_ENTRY_SCOPED(void, Unsafe_SetMemory0(JNIEnv *env, jobject unsafe, jobject
oop base = JNIHandles::resolve(obj);
void* p = index_oop_from_field_offset_long(base, offset);
Copy::fill_to_memory_atomic(p, sz, value);
{
GuardUnsafeAccess guard(thread);
Copy::fill_to_memory_atomic(p, sz, value);
}
} UNSAFE_END
UNSAFE_ENTRY_SCOPED(void, Unsafe_CopyMemory0(JNIEnv *env, jobject unsafe, jobject srcObj, jlong srcOffset, jobject dstObj, jlong dstOffset, jlong size)) {

View File

@@ -202,7 +202,7 @@ public sealed interface ModuleAttribute
}
/**
* Sets the module flags
* Sets the module version
* @param version the module version
* @return this builder
*/

View File

@@ -631,6 +631,9 @@ public sealed interface MemoryLayout
* <li>The accessed memory segment must be
* {@link MemorySegment#isAccessibleBy(Thread) accessible} from the thread
* performing the access operation, or a {@link WrongThreadException} is thrown.</li>
* <li>For write operations, the accessed memory segment must not be
* {@link MemorySegment#isReadOnly() read only}, or an
* {@link IllegalArgumentException} is thrown.</li>
* <li>The {@linkplain MemorySegment#scope() scope} associated with the accessed
* segment must be {@linkplain MemorySegment.Scope#isAlive() alive}, or an
* {@link IllegalStateException} is thrown.</li>

View File

@@ -869,7 +869,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* this segment is not {@linkplain Scope#isAlive() alive}
* @throws WrongThreadException if this method is called from a thread {@code T},
* such that {@code isAccessibleBy(T) == false}
* @throws UnsupportedOperationException if this segment is
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
MemorySegment fill(byte value);
@@ -894,7 +894,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* {@code src} is not {@linkplain Scope#isAlive() alive}
* @throws WrongThreadException if this method is called from a thread {@code T},
* such that {@code src.isAccessibleBy(T) == false}
* @throws UnsupportedOperationException if this segment is
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
* @return this segment
*/
@@ -1269,6 +1269,8 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* this segment is not {@linkplain Scope#isAlive() alive}
* @throws WrongThreadException if this method is called from a thread {@code T},
* such that {@code isAccessibleBy(T) == false}
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void setString(long offset, String str);
@@ -1306,6 +1308,8 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* such that {@code isAccessibleBy(T) == false}
* @throws IllegalArgumentException if {@code charset} is not a
* {@linkplain StandardCharsets standard charset}
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void setString(long offset, String str, Charset charset);
@@ -1493,7 +1497,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* @throws IndexOutOfBoundsException if {@code dstOffset > dstSegment.byteSize() - bytes}
* @throws IndexOutOfBoundsException if either {@code srcOffset},
* {@code dstOffset} or {@code bytes} are {@code < 0}
* @throws UnsupportedOperationException if {@code dstSegment} is
* @throws IllegalArgumentException if {@code dstSegment} is
* {@linkplain #isReadOnly() read-only}
*/
@ForceInline
@@ -1552,7 +1556,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* {@code dstSegment} is not {@linkplain Scope#isAlive() alive}
* @throws WrongThreadException if this method is called from a thread {@code T},
* such that {@code dstSegment.isAccessibleBy(T) == false}
* @throws UnsupportedOperationException if {@code dstSegment} is {@linkplain #isReadOnly() read-only}
* @throws IllegalArgumentException if {@code dstSegment} is {@linkplain #isReadOnly() read-only}
* @throws IndexOutOfBoundsException if {@code elementCount * srcLayout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code elementCount * dtsLayout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code srcOffset > srcSegment.byteSize() - (elementCount * srcLayout.byteSize())}
@@ -1605,7 +1609,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a>
* in the provided layout
* @throws IndexOutOfBoundsException if {@code offset > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void set(ValueLayout.OfByte layout, long offset, byte value);
@@ -1643,7 +1647,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a>
* in the provided layout
* @throws IndexOutOfBoundsException if {@code offset > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void set(ValueLayout.OfBoolean layout, long offset, boolean value);
@@ -1681,7 +1685,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a>
* in the provided layout
* @throws IndexOutOfBoundsException if {@code offset > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void set(ValueLayout.OfChar layout, long offset, char value);
@@ -1719,7 +1723,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a>
* in the provided layout
* @throws IndexOutOfBoundsException if {@code offset > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void set(ValueLayout.OfShort layout, long offset, short value);
@@ -1757,7 +1761,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a>
* in the provided layout
* @throws IndexOutOfBoundsException if {@code offset > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void set(ValueLayout.OfInt layout, long offset, int value);
@@ -1795,7 +1799,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a>
* in the provided layout
* @throws IndexOutOfBoundsException if {@code offset > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void set(ValueLayout.OfFloat layout, long offset, float value);
@@ -1833,7 +1837,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a>
* in the provided layout
* @throws IndexOutOfBoundsException if {@code offset > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void set(ValueLayout.OfLong layout, long offset, long value);
@@ -1871,7 +1875,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a>
* in the provided layout
* @throws IndexOutOfBoundsException if {@code offset > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void set(ValueLayout.OfDouble layout, long offset, double value);
@@ -1921,8 +1925,10 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* @throws IndexOutOfBoundsException if {@code offset > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is
* {@linkplain #isReadOnly() read-only}
* @throws UnsupportedOperationException if {@code value} is not a
* @throws IllegalArgumentException if {@code value} is not a
* {@linkplain #isNative() native} segment
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void set(AddressLayout layout, long offset, MemorySegment value);
@@ -2055,7 +2061,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* @throws IllegalArgumentException if {@code layout.byteAlignment() > layout.byteSize()}
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize() > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is {@linkplain #isReadOnly() read-only}
* @throws IllegalArgumentException if this segment is {@linkplain #isReadOnly() read-only}
*/
void setAtIndex(ValueLayout.OfByte layout, long index, byte value);
@@ -2078,7 +2084,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* @throws IllegalArgumentException if {@code layout.byteAlignment() > layout.byteSize()}
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize() > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is {@linkplain #isReadOnly() read-only}
* @throws IllegalArgumentException if this segment is {@linkplain #isReadOnly() read-only}
*/
void setAtIndex(ValueLayout.OfBoolean layout, long index, boolean value);
@@ -2101,7 +2107,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* @throws IllegalArgumentException if {@code layout.byteAlignment() > layout.byteSize()}
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize() > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is {@linkplain #isReadOnly() read-only}
* @throws IllegalArgumentException if this segment is {@linkplain #isReadOnly() read-only}
*/
void setAtIndex(ValueLayout.OfShort layout, long index, short value);
@@ -2146,7 +2152,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* @throws IllegalArgumentException if {@code layout.byteAlignment() > layout.byteSize()}
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize() > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is {@linkplain #isReadOnly() read-only}
* @throws IllegalArgumentException if this segment is {@linkplain #isReadOnly() read-only}
*/
void setAtIndex(ValueLayout.OfInt layout, long index, int value);
@@ -2191,7 +2197,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* @throws IllegalArgumentException if {@code layout.byteAlignment() > layout.byteSize()}
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize() > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is {@linkplain #isReadOnly() read-only}
* @throws IllegalArgumentException if this segment is {@linkplain #isReadOnly() read-only}
*/
void setAtIndex(ValueLayout.OfFloat layout, long index, float value);
@@ -2236,7 +2242,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* @throws IllegalArgumentException if {@code layout.byteAlignment() > layout.byteSize()}
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize() > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is {@linkplain #isReadOnly() read-only}
* @throws IllegalArgumentException if this segment is {@linkplain #isReadOnly() read-only}
*/
void setAtIndex(ValueLayout.OfLong layout, long index, long value);
@@ -2281,7 +2287,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* @throws IllegalArgumentException if {@code layout.byteAlignment() > layout.byteSize()}
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize() > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is {@linkplain #isReadOnly() read-only}
* @throws IllegalArgumentException if this segment is {@linkplain #isReadOnly() read-only}
*/
void setAtIndex(ValueLayout.OfDouble layout, long index, double value);
@@ -2336,7 +2342,9 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code index * layout.byteSize() > byteSize() - layout.byteSize()}
* @throws UnsupportedOperationException if this segment is {@linkplain #isReadOnly() read-only}
* @throws UnsupportedOperationException if {@code value} is not a {@linkplain #isNative() native} segment
* @throws IllegalArgumentException if {@code value} is not a {@linkplain #isNative() native} segment
* @throws IllegalArgumentException if this segment is
* {@linkplain #isReadOnly() read-only}
*/
void setAtIndex(AddressLayout layout, long index, MemorySegment value);
@@ -2460,7 +2468,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a>
* in the source element layout
* @throws IllegalArgumentException if {@code dstLayout.byteAlignment() > dstLayout.byteSize()}
* @throws UnsupportedOperationException if {@code dstSegment} is {@linkplain #isReadOnly() read-only}
* @throws IllegalArgumentException if {@code dstSegment} is {@linkplain #isReadOnly() read-only}
* @throws IndexOutOfBoundsException if {@code elementCount * dstLayout.byteSize()} overflows
* @throws IndexOutOfBoundsException if {@code dstOffset > dstSegment.byteSize() - (elementCount * dstLayout.byteSize())}
* @throws IndexOutOfBoundsException if {@code srcIndex > srcArray.length - elementCount}

View File

@@ -350,7 +350,7 @@ public interface SegmentAllocator {
*
* @param layout the layout of the block of memory to be allocated
* @param value the value to be set in the newly allocated memory segment
* @throws UnsupportedOperationException if {@code value} is not
* @throws IllegalArgumentException if {@code value} is not
* a {@linkplain MemorySegment#isNative() native} segment
*/
default MemorySegment allocateFrom(AddressLayout layout, MemorySegment value) {
@@ -670,9 +670,11 @@ public interface SegmentAllocator {
*
* @param segment the segment from which the returned allocator should slice from
* @return a new slicing allocator
* @throws IllegalArgumentException if the {@code segment} is
* {@linkplain MemorySegment#isReadOnly() read-only}
*/
static SegmentAllocator slicingAllocator(MemorySegment segment) {
Objects.requireNonNull(segment);
assertWritable(segment);
return new SlicingAllocator(segment);
}
@@ -700,9 +702,19 @@ public interface SegmentAllocator {
* @param segment the memory segment to be recycled by the returned allocator
* @return an allocator that recycles an existing segment upon each new
* allocation request
* @throws IllegalArgumentException if the {@code segment} is
* {@linkplain MemorySegment#isReadOnly() read-only}
*/
static SegmentAllocator prefixAllocator(MemorySegment segment) {
return (AbstractMemorySegmentImpl)Objects.requireNonNull(segment);
assertWritable(segment);
return (AbstractMemorySegmentImpl)segment;
}
private static void assertWritable(MemorySegment segment) {
// Implicit null check
if (segment.isReadOnly()) {
throw new IllegalArgumentException("read-only segment");
}
}
@ForceInline

View File

@@ -361,7 +361,7 @@ public abstract sealed class AbstractMemorySegmentImpl
@ForceInline
public void checkAccess(long offset, long length, boolean readOnly) {
if (!readOnly && this.readOnly) {
throw new UnsupportedOperationException("Attempt to write a read-only segment");
throw new IllegalArgumentException("Attempt to write a read-only segment");
}
checkBounds(offset, length);
}

View File

@@ -217,8 +217,17 @@ abstract class RSASignature extends SignatureSpi {
byte[] decrypted = RSACore.rsa(sigBytes, publicKey);
byte[] digest = getDigestValue();
byte[] encoded = RSAUtil.encodeSignature(digestOID, digest);
byte[] padded = padding.pad(encoded);
if (MessageDigest.isEqual(padded, decrypted)) {
return true;
}
// Some vendors might omit the NULL params in digest algorithm
// identifier. Try again.
encoded = RSAUtil.encodeSignatureWithoutNULL(digestOID, digest);
padded = padding.pad(encoded);
return MessageDigest.isEqual(padded, decrypted);
} catch (javax.crypto.BadPaddingException e) {
return false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, 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
@@ -180,28 +180,15 @@ public class RSAUtil {
}
/**
* Decode the signature data. Verify that the object identifier matches
* and return the message digest.
* Encode the digest without the NULL params, return the to-be-signed data.
* This is only used by SunRsaSign.
*/
public static byte[] decodeSignature(ObjectIdentifier oid, byte[] sig)
throws IOException {
// Enforce strict DER checking for signatures
DerInputStream in = new DerInputStream(sig, 0, sig.length, false);
DerValue[] values = in.getSequence(2);
if ((values.length != 2) || (in.available() != 0)) {
throw new IOException("SEQUENCE length error");
}
AlgorithmId algId = AlgorithmId.parse(values[0]);
if (!algId.getOID().equals(oid)) {
throw new IOException("ObjectIdentifier mismatch: "
+ algId.getOID());
}
if (algId.getEncodedParams() != null) {
throw new IOException("Unexpected AlgorithmId parameters");
}
if (values[1].isConstructed()) {
throw new IOException("Unexpected constructed digest value");
}
return values[1].getOctetString();
static byte[] encodeSignatureWithoutNULL(ObjectIdentifier oid, byte[] digest) {
DerOutputStream out = new DerOutputStream();
out.write(DerValue.tag_Sequence, new DerOutputStream().putOID(oid));
out.putOctetString(digest);
DerValue result =
new DerValue(DerValue.tag_Sequence, out.toByteArray());
return result.toByteArray();
}
}

View File

@@ -177,7 +177,7 @@ final class MemoryContext {
var file = descriptor.sourceRootPath().resolve(path);
// Trivial case: no matching source file exists
if (Files.notExists(file)) return null;
if (!Files.exists(file)) return null;
// Compile source file (unit) with similar options as the program.
var opts = options.forSubsequentCompilations();

View File

@@ -114,7 +114,7 @@ public class JdkConsoleProviderImpl implements JdkConsoleProvider {
} catch (EndOfFileException eofe) {
return null;
} finally {
jline.getBuffer().zeroOut();
jline.zeroOut();
}
}

View File

@@ -750,4 +750,9 @@ public interface LineReader {
void setAutosuggestion(SuggestionType type);
SuggestionType getAutosuggestion();
// JDK specific modification
default void zeroOut() {
throw new UnsupportedOperationException();
}
}

View File

@@ -6250,4 +6250,10 @@ public class LineReaderImpl implements LineReader, Flushable
}
}
// JDK specific modification
@Override
public void zeroOut() {
buf.zeroOut();
parsedLine = null;
}
}

View File

@@ -52,6 +52,7 @@ public class TestPinnedObjectTypes {
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xbootclasspath/a:.",
"-XX:-CreateCoredumpOnCrash",
"-Xmx32M",
"-Xmn16M",
"-Xlog:gc",

View File

@@ -41,6 +41,7 @@
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.foreign.MemorySegment;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
@@ -60,6 +61,8 @@ public class InternalErrorTest {
private static final String failureMsg1 = "InternalError not thrown";
private static final String failureMsg2 = "Wrong InternalError: ";
private static final int NUM_TESTS = 4;
public static void main(String[] args) throws Throwable {
Unsafe unsafe = Unsafe.getUnsafe();
@@ -71,9 +74,9 @@ public class InternalErrorTest {
s.append("1");
}
Files.write(file.toPath(), s.toString().getBytes());
FileChannel fileChannel = new RandomAccessFile(file, "r").getChannel();
FileChannel fileChannel = new RandomAccessFile(file, "rw").getChannel();
MappedByteBuffer buffer =
fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size());
fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, fileChannel.size());
// Get address of mapped memory.
long mapAddr = 0;
@@ -86,13 +89,13 @@ public class InternalErrorTest {
}
long allocMem = unsafe.allocateMemory(4000);
for (int i = 0; i < 3; i++) {
for (int i = 0; i < NUM_TESTS; i++) {
test(buffer, unsafe, mapAddr, allocMem, i);
}
Files.write(file.toPath(), "2".getBytes());
buffer.position(buffer.position() + pageSize);
for (int i = 0; i < 3; i++) {
for (int i = 0; i < NUM_TESTS; i++) {
try {
test(buffer, unsafe, mapAddr, allocMem, i);
WhiteBox.getWhiteBox().forceSafepoint();
@@ -107,7 +110,7 @@ public class InternalErrorTest {
Method m = InternalErrorTest.class.getMethod("test", MappedByteBuffer.class, Unsafe.class, long.class, long.class, int.class);
WhiteBox.getWhiteBox().enqueueMethodForCompilation(m, 3);
for (int i = 0; i < 3; i++) {
for (int i = 0; i < NUM_TESTS; i++) {
try {
test(buffer, unsafe, mapAddr, allocMem, i);
WhiteBox.getWhiteBox().forceSafepoint();
@@ -121,7 +124,7 @@ public class InternalErrorTest {
WhiteBox.getWhiteBox().enqueueMethodForCompilation(m, 4);
for (int i = 0; i < 3; i++) {
for (int i = 0; i < NUM_TESTS; i++) {
try {
test(buffer, unsafe, mapAddr, allocMem, i);
WhiteBox.getWhiteBox().forceSafepoint();
@@ -143,13 +146,18 @@ public class InternalErrorTest {
buffer.get(new byte[8]);
break;
case 1:
// testing Unsafe.copySwapMemory, trying to access next page after truncation.
// testing Unsafe.copySwapMemory, trying to access next page after truncation.
unsafe.copySwapMemory(null, mapAddr + pageSize, new byte[4000], 16, 2000, 2);
break;
case 2:
// testing Unsafe.copySwapMemory, trying to access next page after truncation.
// testing Unsafe.copySwapMemory, trying to access next page after truncation.
unsafe.copySwapMemory(null, mapAddr + pageSize, null, allocMem, 2000, 2);
break;
case 3:
MemorySegment segment = MemorySegment.ofBuffer(buffer);
// testing Unsafe.setMemory, trying to access next page after truncation.
segment.fill((byte) 0xF0);
break;
}
}

View File

@@ -26,12 +26,9 @@
* @run testng TestArrayCopy
*/
import java.lang.foreign.MemoryLayout;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.VarHandle;
import java.nio.ByteOrder;
import java.util.ArrayList;
@@ -240,7 +237,7 @@ public class TestArrayCopy {
try {
helper.copyFromArray(srcArr, 0, SEG_LENGTH_BYTES / bytesPerElement, dstSeg, 0, ByteOrder.nativeOrder());
fail();
} catch (UnsupportedOperationException ex) {
} catch (IllegalArgumentException ex) {
//ok
}
}

View File

@@ -87,7 +87,7 @@ public class TestMemoryAccess {
if (isRO) {
throw new AssertionError(); //not ok, memory should be immutable
}
} catch (UnsupportedOperationException ex) {
} catch (IllegalArgumentException ex) {
if (!isRO) {
throw new AssertionError(); //we should not have failed!
}
@@ -121,7 +121,7 @@ public class TestMemoryAccess {
if (isRO) {
throw new AssertionError(); //not ok, memory should be immutable
}
} catch (UnsupportedOperationException ex) {
} catch (IllegalArgumentException ex) {
if (!isRO) {
throw new AssertionError(); //we should not have failed!
}
@@ -185,7 +185,7 @@ public class TestMemoryAccess {
if (isRO) {
throw new AssertionError(); //not ok, memory should be immutable
}
} catch (UnsupportedOperationException ex) {
} catch (IllegalArgumentException ex) {
if (!isRO) {
throw new AssertionError(); //we should not have failed!
}

View File

@@ -27,7 +27,6 @@
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_SEGMENT_FORCE_EXACT=true --enable-native-access=ALL-UNNAMED TestMemoryAccessInstance
*/
import java.lang.foreign.MemoryLayout;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.Arena;
import java.lang.foreign.ValueLayout;

View File

@@ -100,6 +100,16 @@ public class TestSegmentAllocators {
static final int SIZE_256M = 1024 * 1024 * 256;
@Test(expectedExceptions = IllegalArgumentException.class)
public void testReadOnlySlicingAllocator() {
SegmentAllocator.slicingAllocator(MemorySegment.ofArray(new int[0]).asReadOnly());
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testReadOnlyPrefixAllocator() {
SegmentAllocator.prefixAllocator(MemorySegment.ofArray(new int[0]).asReadOnly());
}
@Test
public void testBigAllocationInUnboundedSession() {
try (Arena arena = Arena.ofConfined()) {
@@ -160,6 +170,25 @@ public class TestSegmentAllocators {
}
}
@Test(expectedExceptions = IllegalArgumentException.class,
expectedExceptionsMessageRegExp = ".*Heap segment not allowed.*")
public void testArenaAllocateFromHeapSegment() {
try (Arena arena = Arena.ofConfined()) {
var heapSegment = MemorySegment.ofArray(new int[]{1});
arena.allocateFrom(ValueLayout.ADDRESS, heapSegment);
}
}
@Test(expectedExceptions = IllegalArgumentException.class,
expectedExceptionsMessageRegExp = ".*Heap segment not allowed.*")
public void testAllocatorAllocateFromHeapSegment() {
try (Arena arena = Arena.ofConfined()) {
SegmentAllocator allocator = SegmentAllocator.prefixAllocator(arena.allocate(16));
var heapSegment = MemorySegment.ofArray(new int[]{1});
allocator.allocateFrom(ValueLayout.ADDRESS, heapSegment);
}
}
@Test
public void testArrayAllocateDelegation() {
AtomicInteger calls = new AtomicInteger();

View File

@@ -76,7 +76,7 @@ public class TestSegmentCopy {
}
}
@Test(expectedExceptions = UnsupportedOperationException.class, dataProvider = "segmentKinds")
@Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "segmentKinds")
public void testReadOnlyCopy(SegmentKind kind1, SegmentKind kind2) {
MemorySegment s1 = kind1.makeSegment(TEST_BYTE_SIZE);
MemorySegment s2 = kind2.makeSegment(TEST_BYTE_SIZE);
@@ -84,6 +84,15 @@ public class TestSegmentCopy {
MemorySegment.copy(s1, Type.BYTE.layout, 0, s2.asReadOnly(), Type.BYTE.layout, 0, 0);
}
@Test(expectedExceptions = IllegalArgumentException.class,
expectedExceptionsMessageRegExp = ".*Attempt to write a read-only segment.*")
public void badCopy6Arg() {
try (Arena scope = Arena.ofConfined()) {
MemorySegment dest = scope.allocate(ValueLayout.JAVA_INT).asReadOnly();
MemorySegment.copy(new int[1],0, dest, ValueLayout.JAVA_INT, 0 ,1); // should throw
}
}
@Test(expectedExceptions = IndexOutOfBoundsException.class, dataProvider = "types")
public void testBadOverflow(Type type) {
if (type.layout.byteSize() > 1) {

View File

@@ -325,12 +325,18 @@ public class TestSegments {
assertEquals(segment.scope(), arena.scope());
}
@Test(dataProvider = "segmentFactories", expectedExceptions = UnsupportedOperationException.class)
@Test(dataProvider = "segmentFactories", expectedExceptions = IllegalArgumentException.class)
public void testFillIllegalAccessMode(Supplier<MemorySegment> segmentSupplier) {
MemorySegment segment = segmentSupplier.get();
segment.asReadOnly().fill((byte) 0xFF);
}
@Test(dataProvider = "segmentFactories", expectedExceptions = IllegalArgumentException.class)
public void testFromStringIllegalAccessMode(Supplier<MemorySegment> segmentSupplier) {
MemorySegment segment = segmentSupplier.get();
segment.asReadOnly().setString(0, "a");
}
@Test(dataProvider = "segmentFactories")
public void testFillThread(Supplier<MemorySegment> segmentSupplier) throws Exception {
MemorySegment segment = segmentSupplier.get();

View File

@@ -64,6 +64,7 @@ import static java.net.http.HttpClient.Version.HTTP_2;
* -Djdk.httpclient.HttpClient.log=frames,ssl,requests,responses,errors
* -Djdk.internal.httpclient.debug=true
* -Dsun.net.httpserver.idleInterval=50000
* -Djdk.tracePinnedThreads=full
* HttpClientLocalAddrTest
*
* @run testng/othervm/java.security.policy=httpclient-localaddr-security.policy

View File

@@ -0,0 +1,57 @@
/*
* Copyright (c) 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
* 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 8320597
* @summary Verify RSA signature with omitted digest params (should be encoded as NULL)
* for backward compatibility
*/
import java.security.KeyFactory;
import java.security.Signature;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
public class WithoutNULL {
public static void main(String[] args) throws Exception {
// A 1024-bit RSA public key
byte[] key = Base64.getMimeDecoder().decode("""
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrfTrEm4KvdFSpGAM7InrFEzALTKdphT9fK6Gu
eVjHtKsuCSEaULCdjhJvPpFK40ONr1JEC1Ywp1UYrfBBdKunnbDZqNZL1cFv+IzF4Yj6JO6pOeHi
1Zpur1GaQRRlYTvzmyWY/AATQDh8JfKObNnDVwXeezFODUG8h5+XL1ZXZQIDAQAB""");
// A SHA1withRSA signature on an empty input where the digestAlgorithm
// inside DigestInfo does not have a parameters field.
byte[] sig = Base64.getMimeDecoder().decode("""
D1FpiT44WEXlDfYK880bdorLO+e9qJVXZWiBgqs9dfK7lYQwyEt9dL23mbUAKm5TVEj2ZxtHkEvk
b8oaWkxk069jDTM1RhllPJZkAjeQRbw4gkg4N6wKZz9B/jdSRMNJg/b9QdRYZOHOBxsEHMbUREPV
DoCOLaxB8eIXX0EWkiE=""");
Signature s = Signature.getInstance("SHA1withRSA", "SunRsaSign");
s.initVerify(KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(key)));
if (!s.verify(sig)) {
throw new RuntimeException("Does not verify");
}
}
}

View File

@@ -23,7 +23,7 @@
/*
* @test
* @bug 8210009
* @bug 8210009 8321739
* @summary Source Launcher classloader should support getResource and getResourceAsStream
* @enablePreview
* @modules jdk.compiler
@@ -41,7 +41,7 @@ import toolbox.ToolBox;
/*
* The body of this test is in ${test.src}/src/p/q/CLTest.java,
* which is executed in single-file source-launcher mode,
* which is executed in source-launcher mode,
* in order to test the classloader used to launch such programs.
*/
public class GetResourceTest {

View File

@@ -0,0 +1 @@
A text file named `java` to simulate https://bugs.openjdk.org/browse/JDK-8321739