mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
Merge
This commit is contained in:
commit
af64d316c0
14 changed files with 47 additions and 25 deletions
|
@ -99,7 +99,7 @@
|
||||||
#include "jvmci/jvmciCompiler.hpp"
|
#include "jvmci/jvmciCompiler.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static jint CurrentVersion = JNI_VERSION_10;
|
static jint CurrentVersion = JNI_VERSION_19;
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(USE_VECTORED_EXCEPTION_HANDLING)
|
#if defined(_WIN32) && !defined(USE_VECTORED_EXCEPTION_HANDLING)
|
||||||
extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
|
extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
|
||||||
|
|
|
@ -3549,6 +3549,7 @@ jboolean Threads::is_supported_jni_version(jint version) {
|
||||||
if (version == JNI_VERSION_1_8) return JNI_TRUE;
|
if (version == JNI_VERSION_1_8) return JNI_TRUE;
|
||||||
if (version == JNI_VERSION_9) return JNI_TRUE;
|
if (version == JNI_VERSION_9) return JNI_TRUE;
|
||||||
if (version == JNI_VERSION_10) return JNI_TRUE;
|
if (version == JNI_VERSION_10) return JNI_TRUE;
|
||||||
|
if (version == JNI_VERSION_19) return JNI_TRUE;
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ package java.lang.foreign;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import jdk.internal.foreign.Utils;
|
import jdk.internal.foreign.Utils;
|
||||||
|
import jdk.internal.vm.annotation.ForceInline;
|
||||||
import jdk.internal.vm.annotation.Stable;
|
import jdk.internal.vm.annotation.Stable;
|
||||||
|
|
||||||
abstract non-sealed class AbstractLayout implements MemoryLayout {
|
abstract non-sealed class AbstractLayout implements MemoryLayout {
|
||||||
|
@ -86,6 +87,7 @@ abstract non-sealed class AbstractLayout implements MemoryLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ForceInline
|
||||||
public long byteSize() {
|
public long byteSize() {
|
||||||
if (cachedSize == 0) {
|
if (cachedSize == 0) {
|
||||||
cachedSize = Utils.bitsToBytesOrThrow(bitSize(),
|
cachedSize = Utils.bitsToBytesOrThrow(bitSize(),
|
||||||
|
|
|
@ -41,6 +41,7 @@ import java.nio.IntBuffer;
|
||||||
import java.nio.LongBuffer;
|
import java.nio.LongBuffer;
|
||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
|
@ -51,6 +52,7 @@ import jdk.internal.access.SharedSecrets;
|
||||||
import jdk.internal.access.foreign.UnmapperProxy;
|
import jdk.internal.access.foreign.UnmapperProxy;
|
||||||
import jdk.internal.misc.ScopedMemoryAccess;
|
import jdk.internal.misc.ScopedMemoryAccess;
|
||||||
import jdk.internal.util.ArraysSupport;
|
import jdk.internal.util.ArraysSupport;
|
||||||
|
import jdk.internal.util.Preconditions;
|
||||||
import jdk.internal.vm.annotation.ForceInline;
|
import jdk.internal.vm.annotation.ForceInline;
|
||||||
|
|
||||||
import static java.lang.foreign.ValueLayout.JAVA_BYTE;
|
import static java.lang.foreign.ValueLayout.JAVA_BYTE;
|
||||||
|
@ -64,7 +66,7 @@ import static java.lang.foreign.ValueLayout.JAVA_BYTE;
|
||||||
* are defined for each memory segment kind, see {@link NativeMemorySegmentImpl}, {@link HeapMemorySegmentImpl} and
|
* are defined for each memory segment kind, see {@link NativeMemorySegmentImpl}, {@link HeapMemorySegmentImpl} and
|
||||||
* {@link MappedMemorySegmentImpl}.
|
* {@link MappedMemorySegmentImpl}.
|
||||||
*/
|
*/
|
||||||
public abstract non-sealed class AbstractMemorySegmentImpl implements MemorySegment, SegmentAllocator, Scoped {
|
public abstract non-sealed class AbstractMemorySegmentImpl implements MemorySegment, SegmentAllocator, Scoped, BiFunction<String, List<Number>, RuntimeException> {
|
||||||
|
|
||||||
private static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess();
|
private static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess();
|
||||||
|
|
||||||
|
@ -394,13 +396,20 @@ public abstract non-sealed class AbstractMemorySegmentImpl implements MemorySegm
|
||||||
@ForceInline
|
@ForceInline
|
||||||
void checkBounds(long offset, long length) {
|
void checkBounds(long offset, long length) {
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
Objects.checkIndex(offset, this.length - length + 1);
|
Preconditions.checkIndex(offset, this.length - length + 1, this);
|
||||||
} else if (length < 0 || offset < 0 ||
|
} else if (length < 0 || offset < 0 ||
|
||||||
offset > this.length - length) {
|
offset > this.length - length) {
|
||||||
throw outOfBoundException(offset, length);
|
throw outOfBoundException(offset, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RuntimeException apply(String s, List<Number> numbers) {
|
||||||
|
long offset = numbers.get(0).longValue();
|
||||||
|
long length = byteSize() - numbers.get(1).longValue() + 1;
|
||||||
|
return outOfBoundException(offset, length);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ForceInline
|
@ForceInline
|
||||||
public MemorySessionImpl sessionImpl() {
|
public MemorySessionImpl sessionImpl() {
|
||||||
|
@ -413,7 +422,7 @@ public abstract non-sealed class AbstractMemorySegmentImpl implements MemorySegm
|
||||||
}
|
}
|
||||||
|
|
||||||
private IndexOutOfBoundsException outOfBoundException(long offset, long length) {
|
private IndexOutOfBoundsException outOfBoundException(long offset, long length) {
|
||||||
return new IndexOutOfBoundsException(String.format("Out of bound access on segment %s; new offset = %d; new length = %d",
|
return new IndexOutOfBoundsException(String.format("Out of bound access on segment %s; offset = %d; length = %d",
|
||||||
this, offset, length));
|
this, offset, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1990,6 +1990,7 @@ JNI_OnUnload(JavaVM *vm, void *reserved);
|
||||||
#define JNI_VERSION_1_8 0x00010008
|
#define JNI_VERSION_1_8 0x00010008
|
||||||
#define JNI_VERSION_9 0x00090000
|
#define JNI_VERSION_9 0x00090000
|
||||||
#define JNI_VERSION_10 0x000a0000
|
#define JNI_VERSION_10 0x000a0000
|
||||||
|
#define JNI_VERSION_19 0x00130000
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -45,7 +45,7 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||||
return JNI_EVERSION; /* JNI version not supported */
|
return JNI_EVERSION; /* JNI version not supported */
|
||||||
}
|
}
|
||||||
|
|
||||||
return JNI_VERSION_10;
|
return JNI_VERSION_19;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -39,7 +39,7 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||||
return JNI_EVERSION; /* JNI version not supported */
|
return JNI_EVERSION; /* JNI version not supported */
|
||||||
}
|
}
|
||||||
|
|
||||||
return JNI_VERSION_10;
|
return JNI_VERSION_19;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -27,12 +27,12 @@
|
||||||
*/
|
*/
|
||||||
public class JniVersion {
|
public class JniVersion {
|
||||||
|
|
||||||
public static final int JNI_VERSION_10 = 0x000a0000;
|
public static final int JNI_VERSION_19 = 0x00130000;
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
System.loadLibrary("JniVersion");
|
System.loadLibrary("JniVersion");
|
||||||
int res = getJniVersion();
|
int res = getJniVersion();
|
||||||
if (res != JNI_VERSION_10) {
|
if (res != JNI_VERSION_19) {
|
||||||
throw new Exception("Unexpected value returned from getJniVersion(): 0x" + Integer.toHexString(res));
|
throw new Exception("Unexpected value returned from getJniVersion(): 0x" + Integer.toHexString(res));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,6 +154,18 @@ public class TestSegments {
|
||||||
memorySegment.get(JAVA_INT, offset);
|
memorySegment.get(JAVA_INT, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSegmentOOBMessage() {
|
||||||
|
try {
|
||||||
|
var segment = MemorySegment.allocateNative(10, MemorySession.global());
|
||||||
|
segment.getAtIndex(ValueLayout.JAVA_INT, 2);
|
||||||
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
|
assertTrue(ex.getMessage().contains("Out of bound access"));
|
||||||
|
assertTrue(ex.getMessage().contains("offset = 8"));
|
||||||
|
assertTrue(ex.getMessage().contains("length = 4"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test(dataProvider = "segmentFactories")
|
@Test(dataProvider = "segmentFactories")
|
||||||
public void testAccessModesOfFactories(Supplier<MemorySegment> segmentSupplier) {
|
public void testAccessModesOfFactories(Supplier<MemorySegment> segmentSupplier) {
|
||||||
MemorySegment segment = segmentSupplier.get();
|
MemorySegment segment = segmentSupplier.get();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
static jint count = 0;
|
static jint count = 0;
|
||||||
static jclass test_class;
|
static jclass test_class;
|
||||||
static jint current_jni_version = JNI_VERSION_10;
|
static jint current_jni_version = JNI_VERSION_19;
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
JNI_OnLoad(JavaVM *vm, void *reserved) {
|
JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
static jclass test_class;
|
static jclass test_class;
|
||||||
static jmethodID mid;
|
static jmethodID mid;
|
||||||
static jint current_jni_version = JNI_VERSION_10;
|
static jint current_jni_version = JNI_VERSION_19;
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
JNI_OnLoad(JavaVM *vm, void *reserved) {
|
JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
|
|
||||||
static jclass test_class;
|
static jclass test_class;
|
||||||
static jint current_jni_version = JNI_VERSION_10;
|
static jint current_jni_version = JNI_VERSION_19;
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
JNI_OnLoad(JavaVM *vm, void *reserved) {
|
JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public final class LauncherIconVerifier {
|
public final class LauncherIconVerifier {
|
||||||
|
@ -136,18 +135,16 @@ public final class LauncherIconVerifier {
|
||||||
|
|
||||||
private Path extractIconFromExecutable(Path outputDir, Path executable,
|
private Path extractIconFromExecutable(Path outputDir, Path executable,
|
||||||
String label) {
|
String label) {
|
||||||
Path psScript = outputDir.resolve(label + ".ps1");
|
|
||||||
Path extractedIcon = outputDir.resolve(label + ".bmp");
|
Path extractedIcon = outputDir.resolve(label + ".bmp");
|
||||||
TKit.createTextFile(psScript, List.of(
|
String script = String.join(";",
|
||||||
"[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing')",
|
"[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing')",
|
||||||
String.format(
|
String.format(
|
||||||
"[System.Drawing.Icon]::ExtractAssociatedIcon(\"%s\").ToBitmap().Save(\"%s\", [System.Drawing.Imaging.ImageFormat]::Bmp)",
|
"[System.Drawing.Icon]::ExtractAssociatedIcon('%s').ToBitmap().Save('%s', [System.Drawing.Imaging.ImageFormat]::Bmp)",
|
||||||
executable.toAbsolutePath().normalize(),
|
executable.toAbsolutePath().normalize(),
|
||||||
extractedIcon.toAbsolutePath().normalize()),
|
extractedIcon.toAbsolutePath().normalize()));
|
||||||
"exit 0"));
|
|
||||||
|
|
||||||
Executor.of("powershell", "-NoLogo", "-NoProfile", "-File",
|
Executor.of("powershell", "-NoLogo", "-NoProfile", "-Command",
|
||||||
psScript.toAbsolutePath().normalize().toString()).execute();
|
script).execute();
|
||||||
|
|
||||||
return extractedIcon;
|
return extractedIcon;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ int java_cmp(const void *a, const void *b) {
|
||||||
int v2 = *((int*)b);
|
int v2 = *((int*)b);
|
||||||
|
|
||||||
JNIEnv* env;
|
JNIEnv* env;
|
||||||
(*VM)->GetEnv(VM, (void**) &env, JNI_VERSION_10);
|
(*VM)->GetEnv(VM, (void**) &env, JNI_VERSION_19);
|
||||||
|
|
||||||
jclass qsortClass = (*env)->FindClass(env, "org/openjdk/bench/java/lang/foreign/QSort");
|
jclass qsortClass = (*env)->FindClass(env, "org/openjdk/bench/java/lang/foreign/QSort");
|
||||||
jmethodID methodId = (*env)->GetStaticMethodID(env, qsortClass, "jni_upcall_compar", "(II)I");
|
jmethodID methodId = (*env)->GetStaticMethodID(env, qsortClass, "jni_upcall_compar", "(II)I");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue