GlueGen v2.6.0-rc-20250706
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
31/** Low level secure dynamic linker access. */
32public interface DynamicLinker {
33 public static final boolean DEBUG = NativeLibrary.DEBUG;
34 public static final boolean DEBUG_LOOKUP = NativeLibrary.DEBUG_LOOKUP;
35
36 /**
37 * @throws SecurityException if user is not granted global access
38 */
39 public void claimAllLinkPermission() throws SecurityException;
40
41 /**
42 * @throws SecurityException if user is not granted global access
43 */
44 public void releaseAllLinkPermission() throws SecurityException;
45
46 /**
47 * If a {@link SecurityManager} is installed, user needs link permissions
48 * for the named library.
49 * <p>
50 * Opens the named library, allowing system wide access for other <i>users</i>.
51 * </p>
52 *
53 * @param pathname the full pathname for the library to open
54 * @param debug set to true to enable debugging
55 * @return the library handle, maybe 0 if not found.
56 * @throws SecurityException if user is not granted access for the named library.
57 */
58 public long openLibraryGlobal(String pathname, boolean debug) throws SecurityException;
59
60 /**
61 * If a {@link SecurityManager} is installed, user needs link permissions
62 * for the named library.
63 * <p>
64 * Opens the named library, restricting access to this process.
65 * </p>
66 *
67 * @param pathname the full pathname for the library to open
68 * @param debug set to true to enable debugging
69 * @return the library handle, maybe 0 if not found.
70 * @throws SecurityException if user is not granted access for the named library.
71 */
72 public long openLibraryLocal(String pathname, boolean debug) throws SecurityException;
73
74 /**
75 * Security checks are implicit by previous call of
76 * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}
77 * retrieving the <code>librarHandle</code>.
78 *
79 * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}.
80 * @param symbolName optional symbol name for an OS which requires the symbol's address to retrieve the path of the containing library
81 * @return the library pathname if found and supported by OS or {@code null}.
82 * @throws IllegalArgumentException in case case <code>libraryHandle</code> is unknown.
83 * @throws SecurityException if user is not granted access for the given library handle
84 */
85 public String lookupLibraryPathname(long libraryHandle, String symbolName) throws SecurityException;
86
87 /**
88 * If a {@link SecurityManager} is installed, user needs link permissions
89 * for <b>all</b> libraries, i.e. for <code>new RuntimePermission("loadLibrary.*");</code>!
90 *
91 * @param symbolName global symbol name to lookup up system wide.
92 * @return the library handle, maybe 0 if not found.
93 * @throws SecurityException if user is not granted access for all libraries.
94 */
95 public long lookupSymbolGlobal(String symbolName) throws SecurityException;
96
97 /**
98 * Security checks are implicit by previous call of
99 * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}
100 * retrieving the <code>librarHandle</code>.
101 *
102 * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}.
103 * @param symbolName global symbol name to lookup up system wide.
104 * @return the library handle, maybe 0 if not found.
105 * @throws IllegalArgumentException in case case <code>libraryHandle</code> is unknown.
106 * @throws SecurityException if user is not granted access for the given library handle
107 */
108 public long lookupSymbol(long libraryHandle, String symbolName) throws SecurityException, IllegalArgumentException;
109
110 /**
111 * Security checks are implicit by previous call of
112 * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}
113 * retrieving the <code>librarHandle</code>.
114 *
115 * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}.
116 * @param debug set to true to enable debugging
117 * @throws IllegalArgumentException in case case <code>libraryHandle</code> is unknown.
118 * @throws SecurityException if user is not granted access for the given library handle
119 */
120 public void closeLibrary(long libraryHandle, boolean debug) throws SecurityException, IllegalArgumentException;
121
122 /**
123 * Returns a string containing the last error.
124 * Maybe called for debuging purposed if any method fails.
125 * @return error string, maybe null. A null or non-null value has no semantics.
126 */
127 public String getLastError();
128}
Provides low-level, relatively platform-independent access to shared ("native") libraries.
Low level secure dynamic linker access.
long openLibraryLocal(String pathname, 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(String pathname, 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...