IOT-2678 Change Java back to dynamic linking
authorGeorge Nash <george.nash@intel.com>
Wed, 20 Sep 2017 19:32:12 +0000 (12:32 -0700)
committerRick Bell <richard.s.bell@intel.com>
Thu, 21 Sep 2017 16:46:40 +0000 (16:46 +0000)
Java was changed to use static linking for most of
the libraries. This was done to enable building Java
on Windows which does not contain the same dynamic
libraries as are avalible to Linux and Android.

See IOT-2405

Unfortanatly this change caused an issue in the Android
serivces. It caused multiple instances of the IoTivity
stack to be included in different libraries used by
the Android services.

This reverts the key elements of IOT-2405 without
reverting the entier change.

Relates-to: https://gerrit.iotivity.org/gerrit/21061
This is being done till we can figure out how to
enable the build on windows so it does not cause
multiple copies of the oc stack.

Windows java will no longer build if this commit
is accepted. However, Android is considered a
higher priority OS when it comes to the Java
language.

Bug: https://jira.iotivity.org/browse/IOT-2678
Bug: https://jira.iotivity.org/browse/IOT-2405
Change-Id: I54e9e65b00a199151395542d9e4629cef4efe516
Signed-off-by: George Nash <george.nash@intel.com>
java/SConscript
java/common/src/main/java/org/iotivity/base/OcRepresentation.java
java/common/src/main/java/org/iotivity/base/OcResourceResponse.java
java/iotivity-android/src/main/java/org/iotivity/base/OcPlatform.java
java/iotivity-android/src/main/java/org/iotivity/ca/CaInterface.java
java/iotivity-java/src/main/java/org/iotivity/base/OcPlatform.java
java/jni/SConscript

index 57c714a60d09c8dcb6756494fc60a2f8b728a502..abea8185394d7ae5bb29c0003c19f706741cad78 100644 (file)
@@ -122,6 +122,8 @@ def ensure_libs(target, source, env):
                                 env.get('BUILD_DIR') + 'ocstack-jni.dll']
     else:
         return target, [source, env.get('BUILD_DIR') + 'libca-interface.so',
+                                env.get('BUILD_DIR') + 'liboc.so',
+                                env.get('BUILD_DIR') + 'liboc_logger.so',
                                 env.get('BUILD_DIR') + 'libocstack-jni.so']
 
 def find_scons_java_version(env):
index 89fc4b541db78c6aca06618223623467df25e3cc..bed9eb797322cc01fb7d3b2eecbdce3952a244bf 100644 (file)
@@ -33,6 +33,7 @@ import java.util.Map;
 public class OcRepresentation {
 
     static {
+        System.loadLibrary("oc");
         System.loadLibrary("ocstack-jni");
     }
 
index 80a323503433b0467321e26a6db7d6aa95a8c19f..b078061baea7ddf15a1a4ba18743587c6a1fbf67 100644 (file)
@@ -30,6 +30,7 @@ import java.util.List;
 public class OcResourceResponse {
 
     static {
+        System.loadLibrary("oc");
         System.loadLibrary("ocstack-jni");
     }
 
index ed20f200164c2837b89fa27b9f95f4e770a36b58..af4464e57d843d59321e48d5de5965aa53063070 100644 (file)
@@ -37,6 +37,10 @@ public final class OcPlatform {
 
     static {
         System.loadLibrary("gnustl_shared");
+        System.loadLibrary("connectivity_abstraction");
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("octbstack");
+        System.loadLibrary("oc");
         if (0 != BuildConfig.SECURED)
         {
             System.loadLibrary("ocprovision");
index 310ac420a8d759789c212fa5ffd418082101a244..5cad30900ea97daa03dc3357723c89e226b90813 100644 (file)
@@ -30,6 +30,7 @@ import org.iotivity.base.OcConnectivityType;
 
 public class CaInterface {
     static {
+        System.loadLibrary("connectivity_abstraction");
         System.loadLibrary("ca-interface");
     }
     private static volatile boolean isConnectionManagerInitialized = false;
index 66b50dc6eb6f9d0c3e9265f37f91c6b69293c18e..b00b93ece088370aaf591a4333a2f236bed05840 100644 (file)
@@ -36,6 +36,9 @@ import java.util.List;
 public final class OcPlatform {
 
     static {
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("octbstack");
+        System.loadLibrary("oc");
         System.loadLibrary("ocstack-jni");
     }
 
index 35e40771ef5ea803f7b239dcc9d0c9ceef2f860d..57bee1ac584083bd34a9f893bd73276dfd4df129 100644 (file)
@@ -89,44 +89,22 @@ else:
     jni_env.AppendUnique(CCFLAGS=['/wd4047', '/wd4022', '/wd4505',])
 jni_env.AppendUnique(LIBPATH=['#/exlibs/sqlite3'])
 jni_env.AppendUnique(RPATH=[env.get('BUILD_DIR')])
-# make sure we link with the static oc library. This is important since Windows does not build a shared library for the oc library
-# The oc library can not be imported into the Java on all of the platfroms so must be statically linked to make Java code work on
-# all platforms.
 jni_env.PrependUnique(LIBS=[
     'resource_directory',
-    'oc_logger_internal',
-    'coap',
-    'octbstack_internal',
-    'ocsrm',
-    'routingmanager'
+    'oc',
+    'octbstack',
+    'oc_logger',
+    'connectivity_abstraction'
 ])
 
-if target_os not in ['windows', 'winrt']:
-    jni_env.PrependUnique(LIBS=[
-        jni_env['LIBPREFIX'] + 'connectivity_abstraction' + jni_env['LIBSUFFIX'],
-        'oc_internal'
-    ])
-else:
-    jni_env.PrependUnique(LIBS=[
-        'connectivity_abstraction_internal',
-        'oc',
-        'mbedcrypto',
-        'resource_directory_internal',
-        'sqlite3'
-    ])
-
 if env.get('SECURED') == '1':
     jni_env.AppendUnique(CPPDEFINES=['__WITH_TLS__'])
-    jni_env.PrependUnique(LIBS=['mbedtls', 'mbedx509', 'ocprovision'])
-    if target_os not in ['windows', 'winrt']:
-        jni_env.PrependUnique(LIBS=['ocpmapi'])
-    else:
-        jni_env.PrependUnique(LIBS=['ocpmapi_internal',])
-    jni_env.AppendUnique(CPPPATH=['#resource/csdk/security/include/internal',
-                                  '#extlibs/cjson'])
+    jni_env.PrependUnique(LIBS=['mbedtls', 'ocprovision', 'ocpmapi'])
+    jni_env.AppendUnique(CPPPATH=['#/resource/csdk/security/include/internal',
+                                  '#/extlibs/cjson'
+    ])
     if env.get('WITH_CLOUD') == '1':
-        jni_env.AppendUnique(
-            CPPPATH=['#resource/csdk/security/provisioning/include/cloud'])
+        jni_env.AppendUnique(CPPPATH=['#/resource/csdk/security/provisioning/include/cloud'])
 
 if target_os == 'android':
     jni_env.AppendUnique(CXXFLAGS=['-frtti', '-fexceptions'])