Merge
This commit is contained in:
commit
af64d316c0
@ -99,7 +99,7 @@
|
||||
#include "jvmci/jvmciCompiler.hpp"
|
||||
#endif
|
||||
|
||||
static jint CurrentVersion = JNI_VERSION_10;
|
||||
static jint CurrentVersion = JNI_VERSION_19;
|
||||
|
||||
#if defined(_WIN32) && !defined(USE_VECTORED_EXCEPTION_HANDLING)
|
||||
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_9) return JNI_TRUE;
|
||||
if (version == JNI_VERSION_10) return JNI_TRUE;
|
||||
if (version == JNI_VERSION_19) return JNI_TRUE;
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ package java.lang.foreign;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import jdk.internal.foreign.Utils;
|
||||
import jdk.internal.vm.annotation.ForceInline;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
||||
abstract non-sealed class AbstractLayout implements MemoryLayout {
|
||||
@ -86,6 +87,7 @@ abstract non-sealed class AbstractLayout implements MemoryLayout {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public long byteSize() {
|
||||
if (cachedSize == 0) {
|
||||
cachedSize = Utils.bitsToBytesOrThrow(bitSize(),
|
||||
|
@ -41,6 +41,7 @@ import java.nio.IntBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.IntFunction;
|
||||
@ -51,6 +52,7 @@ import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.access.foreign.UnmapperProxy;
|
||||
import jdk.internal.misc.ScopedMemoryAccess;
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
import jdk.internal.util.Preconditions;
|
||||
import jdk.internal.vm.annotation.ForceInline;
|
||||
|
||||
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
|
||||
* {@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();
|
||||
|
||||
@ -394,13 +396,20 @@ public abstract non-sealed class AbstractMemorySegmentImpl implements MemorySegm
|
||||
@ForceInline
|
||||
void checkBounds(long offset, long length) {
|
||||
if (length > 0) {
|
||||
Objects.checkIndex(offset, this.length - length + 1);
|
||||
Preconditions.checkIndex(offset, this.length - length + 1, this);
|
||||
} else if (length < 0 || offset < 0 ||
|
||||
offset > this.length - 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
|
||||
@ForceInline
|
||||
public MemorySessionImpl sessionImpl() {
|
||||
@ -413,7 +422,7 @@ public abstract non-sealed class AbstractMemorySegmentImpl implements MemorySegm
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -1990,6 +1990,7 @@ JNI_OnUnload(JavaVM *vm, void *reserved);
|
||||
#define JNI_VERSION_1_8 0x00010008
|
||||
#define JNI_VERSION_9 0x00090000
|
||||
#define JNI_VERSION_10 0x000a0000
|
||||
#define JNI_VERSION_19 0x00130000
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* 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.
|
||||
*
|
||||
* 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_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_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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,12 +27,12 @@
|
||||
*/
|
||||
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 {
|
||||
System.loadLibrary("JniVersion");
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -154,6 +154,18 @@ public class TestSegments {
|
||||
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")
|
||||
public void testAccessModesOfFactories(Supplier<MemorySegment> segmentSupplier) {
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
static jint count = 0;
|
||||
static jclass test_class;
|
||||
static jint current_jni_version = JNI_VERSION_10;
|
||||
static jint current_jni_version = JNI_VERSION_19;
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
static jclass test_class;
|
||||
static jmethodID mid;
|
||||
static jint current_jni_version = JNI_VERSION_10;
|
||||
static jint current_jni_version = JNI_VERSION_19;
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,7 @@
|
||||
#include "jni.h"
|
||||
|
||||
static jclass test_class;
|
||||
static jint current_jni_version = JNI_VERSION_10;
|
||||
static jint current_jni_version = JNI_VERSION_19;
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
|
@ -28,7 +28,6 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public final class LauncherIconVerifier {
|
||||
@ -136,18 +135,16 @@ public final class LauncherIconVerifier {
|
||||
|
||||
private Path extractIconFromExecutable(Path outputDir, Path executable,
|
||||
String label) {
|
||||
Path psScript = outputDir.resolve(label + ".ps1");
|
||||
Path extractedIcon = outputDir.resolve(label + ".bmp");
|
||||
TKit.createTextFile(psScript, List.of(
|
||||
String script = String.join(";",
|
||||
"[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing')",
|
||||
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(),
|
||||
extractedIcon.toAbsolutePath().normalize()),
|
||||
"exit 0"));
|
||||
extractedIcon.toAbsolutePath().normalize()));
|
||||
|
||||
Executor.of("powershell", "-NoLogo", "-NoProfile", "-File",
|
||||
psScript.toAbsolutePath().normalize().toString()).execute();
|
||||
Executor.of("powershell", "-NoLogo", "-NoProfile", "-Command",
|
||||
script).execute();
|
||||
|
||||
return extractedIcon;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ int java_cmp(const void *a, const void *b) {
|
||||
int v2 = *((int*)b);
|
||||
|
||||
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");
|
||||
jmethodID methodId = (*env)->GetStaticMethodID(env, qsortClass, "jni_upcall_compar", "(II)I");
|
||||
|
Loading…
Reference in New Issue
Block a user