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

Handle AccessControlException for system property in NativeMethods class #34

Merged
merged 1 commit into from
May 26, 2023
Merged
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
18 changes: 12 additions & 6 deletions src/main/java/com/ibm/as400/access/NativeMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package com.ibm.as400.access;

import java.security.AccessControlException;

// The NativeMethods class is used to call the native methods for the IBM Toolbox for Java Native Classes.
public class NativeMethods
{
Expand Down Expand Up @@ -49,17 +51,21 @@ public class NativeMethods

}
if (Trace.traceOn_) Trace.log(Trace.DIAGNOSTIC, "Loading Native non-PASE methods "); //@pase1

String alternateLibrary = System.getProperty("com.ibm.as400.access.native.library");
if (alternateLibrary != null) {
nativeLibraryQyjspart = "/QSYS.LIB/"+alternateLibrary+".LIB/QYJSPART.SRVPGM";
if (Trace.traceOn_) Trace.log(Trace.DIAGNOSTIC, "QYJSPART as "+nativeLibraryQyjspart);
try{
String alternateLibrary = System.getProperty("com.ibm.as400.access.native.library");
if (alternateLibrary != null) {
nativeLibraryQyjspart = "/QSYS.LIB/"+alternateLibrary+".LIB/QYJSPART.SRVPGM";
if (Trace.traceOn_) Trace.log(Trace.DIAGNOSTIC, "QYJSPART as "+nativeLibraryQyjspart);
}
} catch(AccessControlException e)
{
Trace.log(Trace.DIAGNOSTIC, "Error checking property for custom native library:", e);
}
try{
System.load(nativeLibraryQyjspart ); //if j9, then socket functions in this lib are overridden
} catch(Throwable e)
{
Trace.log(Trace.ERROR, "Error loading QYJSPART service program:", e); //may be that it is already loaded in multiple .war classloader
Trace.log(Trace.ERROR, "Error loading QYJSPART service program:", e); //may be that it is already loaded in multiple .war classloader
}
}

Expand Down