Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8248560: Specify the behaviour of the ForeignLinker returned by CSupport::getSystemLinker #327

Closed
wants to merge 8 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -28,12 +28,12 @@
/**
* Represents a type which is <em>addressable</em>. An addressable type is one which can be projected down to
* a memory address instance (see {@link #address()}). Examples of addressable types are {@link MemorySegment},
* {@link MemoryAddress}, {@link LibraryLookup.Symbol} and {@link CSupport.VaList}.
* {@link MemoryAddress}, {@link LibraryLookup.Symbol} and {@link CLinker.VaList}.
*
* @apiNote In the future, if the Java language permits, {@link Addressable}
* may become a {@code sealed} interface, which would prohibit subclassing except by
* explicitly permitted types, such as {@link MemorySegment}, {@link MemoryAddress}, {@link LibraryLookup.Symbol}
* and {@link CSupport.VaList}.
* and {@link CLinker.VaList}.
*
* @implSpec
* Implementations of this interface <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>.

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@
* <p>
* All symbol instances (see {@link LibraryLookup.Symbol}) generated by a given library lookup object contain a strong reference
* to said lookup object, therefore preventing library unloading; in turn method handle instances obtained from
* {@link ForeignLinker#downcallHandle(Addressable, MethodType, FunctionDescriptor)}) also maintain a strong reference
* {@link CLinker#downcallHandle(Addressable, MethodType, FunctionDescriptor)}) also maintain a strong reference
* to the addressable parameter used for their construction. This means that there is always a strong reachability chain
* from a native method handle to a lookup object (the one that was used to lookup the native library symbol the method handle
* refers to); this is useful to prevent situations where a native library is unloaded in the middle of a native call.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2020, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*
*/
package jdk.internal.foreign;

public enum CABI {
SysV,
Win64,
AArch64;

public static CABI current() {
String arch = System.getProperty("os.arch");
String os = System.getProperty("os.name");
if (arch.equals("amd64") || arch.equals("x86_64")) {
if (os.startsWith("Windows")) {
return Win64;
} else {
return SysV;
}
} else if (arch.equals("aarch64")) {
return AArch64;
}
throw new UnsupportedOperationException("Unsupported os or arch: " + os + ", " + arch);
}
}
Loading