GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
DynamicLinker.java
Go to the documentation of this file.
1/**
2 * Copyright 2013-2023 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.common.os;
30
31import com.jogamp.common.os.NativeLibrary.LibPath;
32
33/** Low level secure dynamic linker access. */
34public interface DynamicLinker {
35 public static final boolean DEBUG = NativeLibrary.DEBUG;
36 public static final boolean DEBUG_LOOKUP = NativeLibrary.DEBUG_LOOKUP;
37
38 /**
39 * @throws SecurityException if user is not granted global access
40 */
41 public void claimAllLinkPermission() throws SecurityException;
42
43 /**
44 * @throws SecurityException if user is not granted global access
45 */
46 public void releaseAllLinkPermission() throws SecurityException;
47
48 /**
49 * If a {@link SecurityManager} is installed, user needs link permissions
50 * for the named library.
51 * <p>
52 * Opens the named library, allowing system wide access for other <i>users</i>.
53 * </p>
54 *
55 * @param libpath the LibPath for the library to open
56 * @param debug set to true to enable debugging
57 * @return the library handle, maybe 0 if not found.
58 * @throws SecurityException if user is not granted access for the named library.
59 */
60 public long openLibraryGlobal(LibPath libpath, boolean debug) throws SecurityException;
61
62 /**
63 * If a {@link SecurityManager} is installed, user needs link permissions
64 * for the named library.
65 * <p>
66 * Opens the named library, restricting access to this process.
67 * </p>
68 *
69 * @param libpath the LibPath for the library to open
70 * @param debug set to true to enable debugging
71 * @return the library handle, maybe 0 if not found.
72 * @throws SecurityException if user is not granted access for the named library.
73 */
74 public long openLibraryLocal(LibPath libpath, boolean debug) throws SecurityException;
75
76 /**
77 * Security checks are implicit by previous call of
78 * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}
79 * retrieving the <code>librarHandle</code>.
80 *
81 * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}.
82 * @param symbolName optional symbol name for an OS which requires the symbol's address to retrieve the path of the containing library
83 * @return the library pathname if found and supported by OS or {@code null}.
84 * @throws IllegalArgumentException in case case <code>libraryHandle</code> is unknown.
85 * @throws SecurityException if user is not granted access for the given library handle
86 */
87 public String lookupLibraryPathname(long libraryHandle, String symbolName) throws SecurityException;
88
89 /**
90 * If a {@link SecurityManager} is installed, user needs link permissions
91 * for <b>all</b> libraries, i.e. for <code>new RuntimePermission("loadLibrary.*");</code>!
92 *
93 * @param symbolName global symbol name to lookup up system wide.
94 * @return the library handle, maybe 0 if not found.
95 * @throws SecurityException if user is not granted access for all libraries.
96 */
97 public long lookupSymbolGlobal(String symbolName) throws SecurityException;
98
99 /**
100 * Security checks are implicit by previous call of
101 * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}
102 * retrieving the <code>librarHandle</code>.
103 *
104 * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}.
105 * @param symbolName global symbol name to lookup up system wide.
106 * @return the library handle, maybe 0 if not found.
107 * @throws IllegalArgumentException in case case <code>libraryHandle</code> is unknown.
108 * @throws SecurityException if user is not granted access for the given library handle
109 */
110 public long lookupSymbol(long libraryHandle, String symbolName) throws SecurityException, IllegalArgumentException;
111
112 /**
113 * Security checks are implicit by previous call of
114 * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}
115 * retrieving the <code>librarHandle</code>.
116 *
117 * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}.
118 * @param debug set to true to enable debugging
119 * @throws IllegalArgumentException in case case <code>libraryHandle</code> is unknown.
120 * @throws SecurityException if user is not granted access for the given library handle
121 */
122 public void closeLibrary(long libraryHandle, boolean debug) throws SecurityException, IllegalArgumentException;
123
124 /**
125 * Returns a string containing the last error.
126 * Maybe called for debuging purposed if any method fails.
127 * @return error string, maybe null. A null or non-null value has no semantics.
128 */
129 public String getLastError();
130}
Native Library Path Specification.
Provides low-level, relatively platform-independent access to shared ("native") libraries.
Low level secure dynamic linker access.
long openLibraryLocal(LibPath libpath, boolean debug)
If a SecurityManager is installed, user needs link permissions for the named library.
long lookupSymbolGlobal(String symbolName)
If a SecurityManager is installed, user needs link permissions for all libraries, i....
String getLastError()
Returns a string containing the last error.
void closeLibrary(long libraryHandle, boolean debug)
Security checks are implicit by previous call of openLibraryLocal(String, boolean) or openLibraryGlob...
String lookupLibraryPathname(long libraryHandle, String symbolName)
Security checks are implicit by previous call of openLibraryLocal(String, boolean) or openLibraryGlob...
long openLibraryGlobal(LibPath libpath, boolean debug)
If a SecurityManager is installed, user needs link permissions for the named library.
long lookupSymbol(long libraryHandle, String symbolName)
Security checks are implicit by previous call of openLibraryLocal(String, boolean) or openLibraryGlob...