Skip to content

Commit 858622a

Browse files
author
Daniel Mikusa
committed
Add Luna API shared library to library path for Java 9+
With Java 9, the extension directory functionality was dropped. This means the buildpack has to handle installation different for Java 8 and Java 9+. With Java 8, we add the required files to the extension directory. With Java 9, we add the required JAR file to the classpath, but this was not sufficient to load the required shared library. To fix this, we are adding the Luna API shared library to the LD_LIBRARY_PATH environment variable. The JVM uses this to locate shared libraries, so it can now find the shared library. Signed-off-by: Daniel Mikusa <[email protected]>
1 parent f4618b6 commit 858622a

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/java_buildpack/framework/luna_security_provider.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def release
6262

6363
if @droplet.java_home.java_9_or_later?
6464
@droplet.root_libraries << luna_provider_jar
65+
66+
@droplet.environment_variables.add_environment_variable(
67+
'LD_LIBRARY_PATH', "$LD_LIBRARY_PATH:#{ld_lib_path}"
68+
)
6569
else
6670
@droplet.extension_directories << ext_dir
6771
end
@@ -128,6 +132,10 @@ def lib_cklog
128132
@droplet.sandbox + 'libs/64/libcklog2.so'
129133
end
130134

135+
def ld_lib_path
136+
qualify_path(@droplet.sandbox, @droplet.root) + '/jsp/64/'
137+
end
138+
131139
def setup_ext_dir
132140
FileUtils.mkdir ext_dir
133141
[luna_provider_jar, luna_api_so].each do |file|

spec/java_buildpack/framework/luna_security_provider_spec.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,26 +219,32 @@
219219
delegate
220220
end
221221

222-
it 'adds JAR to classpath during compile in Java 9',
222+
it 'adds JAR to classpath during compile in Java 9+',
223223
cache_fixture: 'stub-luna-security-provider.tar' do
224224

225225
component.compile
226226

227227
expect(root_libraries).to include(droplet.sandbox + 'jsp/LunaProvider.jar')
228228
end
229229

230-
it 'adds JAR to classpath during release in Java 9' do
230+
it 'adds JAR to classpath during release in Java 9+' do
231231
component.release
232232

233233
expect(root_libraries).to include(droplet.sandbox + 'jsp/LunaProvider.jar')
234234
end
235235

236-
it 'adds does not add extension directory in Java 9' do
236+
it 'adds does not add extension directory in Java 9+' do
237237
component.release
238238

239239
expect(extension_directories).not_to include(droplet.sandbox + 'ext')
240240
end
241241

242+
it 'updates environment variables for Java 9+' do
243+
component.release
244+
expect(environment_variables).to include(
245+
'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/.java-buildpack/luna_security_provider/jsp/64/'
246+
)
247+
end
242248
end
243249

244250
context do

0 commit comments

Comments
 (0)