File: subclipse-load-nativelib-from-single-bundle.patch

package info (click to toggle)
svnclientadapter 1.10.3-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,568 kB
  • ctags: 2,864
  • sloc: java: 15,865; xml: 181; sh: 38; makefile: 14
file content (131 lines) | stat: -rw-r--r-- 5,245 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
From: Jakub Adam <jakub.adam@ktknet.cz>
Date: Tue, 4 Oct 2011 22:38:45 +0200
Subject: subclipse-load-nativelib-from-single-bundle

We should avoid calling System.loadLibrary() for JavaHL native binaries in this
package. Eclipse has a limitation that one JNI library can't be loaded by multiple
bundles at once.

If we load libsvnjavahl-1.so at JhlClientAdapterFactory.isAvailable(), another
attempt that is performed upon instantiating of SVNClient from JavaHL bundle
causes that UnsatisfiedLinkError is thrown. I removed the code that checks
availability of native library from JhlClientAdapterFactory, as it mostly
duplicates functionality of org.tigris.subversion.javahl.NativeResources. Now
there is only single place where JNI library is loaded and the above described
problem does not apply to us.

Original binary distribution of Subclipse doesn't have this problem because
upstream bundles SvnClientAdapter and JavaHL together with some Subclipse
specific code into a single Eclipse plugin. It showed only after I removed the
repeating code and tried to use libraries already present in Debian instead.
---
 .../javahl/JhlClientAdapterFactory.java            | 95 +++++-----------------
 1 file changed, 21 insertions(+), 74 deletions(-)

diff --git a/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlClientAdapterFactory.java b/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlClientAdapterFactory.java
index d8d0c41..ddb5e9f 100644
--- a/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlClientAdapterFactory.java
+++ b/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlClientAdapterFactory.java
@@ -118,81 +118,28 @@ public class JhlClientAdapterFactory extends SVNClientAdapterFactory {
     		}
     		//workaround to solve Subclipse ISSUE #83
     		available = false;
-    		try {
-    			/*
-    			 * see if the user has specified the fully qualified path to the native
-    			 * library
-    			 */
-    			try
-    			{
-    				String specifiedLibraryName =
-    					System.getProperty("subversion.native.library");
-    				if(specifiedLibraryName != null) {
-    					System.load(specifiedLibraryName);
-    					available = true;
-    				}
-    			}
-    			catch(UnsatisfiedLinkError ex)
-    			{
-    				javaHLErrors.append(ex.getMessage()).append("\n");
-    			}
-    			if (!available) {
-    				/*
-    				 * first try to load the library by the new name.
-    				 * if that fails, try to load the library by the old name.
-    				 */
-    				try
-    				{
-    					System.loadLibrary("libsvnjavahl-1");
-    				}
-    				catch(UnsatisfiedLinkError ex)
-    				{
-    					javaHLErrors.append(ex.getMessage() + "\n");
-    					try
-    					{
-    						System.loadLibrary("svnjavahl-1");
-    					}
-    					catch (UnsatisfiedLinkError e)
-    					{
-    						javaHLErrors.append(e.getMessage()).append("\n");
-    						System.loadLibrary("svnjavahl");
-    					}
-    				}
 
-    				available = true;
-    			}
-    		} catch (Exception e) {
-    			available = false;
-    			javaHLErrors.append(e.getMessage()).append("\n");
-    		} catch (UnsatisfiedLinkError e) {
-    			available = false;
-    			javaHLErrors.append(e.getMessage()).append("\n");
-    		} finally {
-    			availabilityCached = true;
-    		}
-    		if (!available) {
-    			String libraryPath = System.getProperty("java.library.path");
-    			if (libraryPath != null)
-    				javaHLErrors.append("java.library.path = " + libraryPath);
-    			// System.out.println(javaHLErrors.toString());
-    		} else {
-    			// At this point, the library appears to be available, but
-    			// it could be too old version of JavaHL library.  We have to try
-    			// to get the version of the library to be sure.
-    			try {
-	                ISVNClient svnClient = new SVNClient();
-    				Version version = svnClient.getVersion();
-    				if (version.getMajor() == 1 && version.getMinor() == 8)
-    					available = true;
-    				else {
-    					available = false;
-    					javaHLErrors = new StringBuffer("Incompatible JavaHL library loaded.  Subversion 1.8.x required.");
-    				}
-    			} catch (UnsatisfiedLinkError e) {
-    				available = false;
-    				javaHLErrors = new StringBuffer("Incompatible JavaHL library loaded.  1.8.x or later required.");
-    			}
-    		}
+			// At this point, the library appears to be available, but
+			// it could be too old version of JavaHL library.  We have to try
+			// to get the version of the library to be sure.
+			try {
+				ISVNClient svnClient = new SVNClient();
+				Version version = svnClient.getVersion();
+				if (version.getMajor() == 1 && version.getMinor() == 8)
+					available = true;
+				else {
+					available = false;
+					javaHLErrors = new StringBuffer("Incompatible JavaHL library loaded.  Subversion 1.8.x required.");
+				}
+			} catch (UnsatisfiedLinkError e) {
+				available = false;
+				javaHLErrors = new StringBuffer(e.getMessage());
+			} catch (LinkageError e) {
+				available = false;
+				javaHLErrors = new StringBuffer("Incompatible JavaHL library loaded.  1.8.x or later required.");
+			} finally {
+				availabilityCached = true;
+			}
     	}
 
     	return available;