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 57c714a..abea818 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 89fc4b5..bed9eb7 100644 (file)
@@ -33,6 +33,7 @@ import java.util.Map;
 public class OcRepresentation {
 
     static {
+        System.loadLibrary("oc");
         System.loadLibrary("ocstack-jni");
     }
 
index 80a3235..b078061 100644 (file)
@@ -30,6 +30,7 @@ import java.util.List;
 public class OcResourceResponse {
 
     static {
+        System.loadLibrary("oc");
         System.loadLibrary("ocstack-jni");
     }
 
index ed20f20..af4464e 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 310ac42..5cad309 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 66b50dc..b00b93e 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 35e4077..57bee1a 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'])