22
22
* or visit www.oracle.com if you need additional information or have any
23
23
* questions.
24
24
*/
25
+ /*
26
+ * ===========================================================================
27
+ * (c) Copyright IBM Corp. 2024, 2024 All Rights Reserved
28
+ * ===========================================================================
29
+ */
25
30
package jdk .tools .jlink .internal .plugins ;
26
31
27
32
import java .io .InputStream ;
@@ -104,9 +109,7 @@ public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
104
109
stripBin );
105
110
in .transformAndCopy ((resource ) -> {
106
111
ResourcePoolEntry res = resource ;
107
- if ((resource .type () == ResourcePoolEntry .Type .NATIVE_LIB &&
108
- resource .path ().endsWith (SHARED_LIBS_EXT )) ||
109
- resource .type () == ResourcePoolEntry .Type .NATIVE_CMD ) {
112
+ if (shouldStrip (resource )) {
110
113
Optional <StrippedDebugInfoBinary > strippedBin = builder .build (resource );
111
114
if (strippedBin .isPresent ()) {
112
115
StrippedDebugInfoBinary sb = strippedBin .get ();
@@ -131,6 +134,35 @@ public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
131
134
return out .build ();
132
135
}
133
136
137
+ /**
138
+ * Method to determine if a particular resource should be stripped.
139
+ *
140
+ * Particular paths are added here to handle libraries within the openjceplus module.
141
+ * The FIPS certified library located in the C/icc directory is sensitive to
142
+ * any modifications to the native library. Performing any modifications to the library
143
+ * in any way, causes the FIPS library to fail to load due to a self verification check made.
144
+ *
145
+ * @param resource the resource to examine for stripping eligibility
146
+ * @return return true if stripping should be done on a particular resource, false otherwise
147
+ */
148
+ private static boolean shouldStrip (ResourcePoolEntry resource ) {
149
+ switch (resource .type ()) {
150
+ case NATIVE_CMD :
151
+ return true ;
152
+ case NATIVE_LIB :
153
+ String path = resource .path ();
154
+ if (path .endsWith (SHARED_LIBS_EXT )) {
155
+ if (!(resource .moduleName ().equals ("openjceplus" ) && path .contains ("/C/icc/" ))) {
156
+ return true ;
157
+ }
158
+ }
159
+ break ;
160
+ default :
161
+ break ;
162
+ }
163
+ return false ;
164
+ }
165
+
134
166
private void logError (ResourcePoolEntry resource , String msgKey ) {
135
167
String msg = getMessage (msgKey ,
136
168
NAME ,
0 commit comments