Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r1483 - trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/javahl

subclipse
Discussion topic

Back to topic list

svn commit: r1483 - trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/javahl

Author markphip
Full name Mark Phippard
Date 2005-07-26 18:20:26 PDT
Message Author: markphip
Date: Tue Jul 26 18:20:26 2005
New Revision: 1483

Modified:
   trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/javahl/Jh​lClientAdapter.java
Log:
Improve reporting of errors when JavaHL library fails to load.

The JavaHL load process actually tries to load several libraries, so I did not want to just
report every error. A user looking at the console might think JavaHL failed to load, when it
actually was successful. So what I did was maintain a StringBuffer of all of the error messages
encountered along the way. If, at the end, the library was not loaded succcessfully, then I output
all of the errors. Also, since the errors typically involve the path, I also output the value of
java.library.path. On my Mac, the error message looks like this:

Failed to load JavaHL Library.
These are the errors that were encountered:
no libsvnjavahl-1 in java.library.path
no svnjavahl-1 in java.library.path
no svnjavahl in java.library.path
java.library.path = .:/Library/Java/Exte​nsions:/System/Libra​ry/Java/Extensions:/​usr/lib/java


Modified: trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/javahl/Jh​lClientAdapter.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/sv​nClientAdapter/src/m​ain/org/tigris/subve​rsion/svnclientadapt​er/javahl/JhlClientA​dapter.java?view=dif​f&rev=1483&p​1=trunk/svnClientAda​pter/src/main/org/ti​gris/subversion/svnc​lientadapter/javahl/​JhlClientAdapter.jav​a&r1=1482&p2​=trunk/svnClientAdap​ter/src/main/org/tig​ris/subversion/svncl​ientadapter/javahl/J​hlClientAdapter.java​&r2=1483
====================​====================​====================​==================
--- trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/javahl/Jh​lClientAdapter.java (original)
+++ trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/javahl/Jh​lClientAdapter.java Tue Jul 26 18:20:26 2005
@@ -80,6 +80,7 @@
      * @return
      */
     public static boolean isAvailable() {
+ StringBuffer javaHLErrors = new StringBuffer("Failed to load JavaHL Library.\nThese are the errors that were encountered:\n");
         if (!availabilityCached) {
                 // if library is already loaded, it will not be reloaded
     
@@ -92,71 +93,115 @@
                     try {
                         System.loadLibrary("libapr");
                     } catch (Exception e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     } catch (UnsatisfiedLinkError e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     }
                     try {
                         System.loadLibrary("​libapriconv");
                     } catch (Exception e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     } catch (UnsatisfiedLinkError e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     }
                     try {
                         System.loadLibrary("libeay32");
                     } catch (Exception e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     } catch (UnsatisfiedLinkError e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     }
                     try {
                         System.loadLibrary("libdb43");
                     } catch (Exception e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     } catch (UnsatisfiedLinkError e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     }
                     try {
                         System.loadLibrary("ssleay32");
                     } catch (Exception e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     } catch (UnsatisfiedLinkError e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     }
                     try {
                         System.loadLibrary("​libaprutil");
                     } catch (Exception e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     } catch (UnsatisfiedLinkError e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     }
                     try {
                         System.loadLibrary("​intl3_svn");
                     } catch (Exception e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     } catch (UnsatisfiedLinkError e) {
+ javaHLErrors.append(​e.getMessage() + "\n");
                     }
                 }
                 //workaround to solve Subclipse ISSUE #83
-
+ available = false;
             try {
- /*
- * 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)
- {
- try
- {
- System.loadLibrary("​svnjavahl-1");
- }
- catch (UnsatisfiedLinkError e)
- {
- System.loadLibrary("​svnjavahl");
- }
- }
+ /*
+ * see if the user has specified the fully qualified path to the native
+ * library
+ */
+ try
+ {
+ String specifiedLibraryName =
+ System.getProperty("​subversion.native.li​brary");
+ if(specifiedLibraryName != null) {
+ System.load(specifie​dLibraryName);
+ available = true;
+ }
+ }
+ catch(UnsatisfiedLinkError ex)
+ {
+ javaHLErrors.append(​ex.getMessage() + "\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() + "\n");
+ System.loadLibrary("​svnjavahl");
+ }
+ }
                 
                 available = true;
+ }
             } catch (Exception e) {
                 available = false;
+ javaHLErrors.append(​e.getMessage() + "\n");
             } catch (UnsatisfiedLinkError e) {
                 available = false;
+ javaHLErrors.append(​e.getMessage() + "\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(j​avaHLErrors.toString​());
+ }
+
         return available;
     }

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r1483 - trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/javahl markphip Mark Phippard 2005-07-26 18:20:26 PDT
Messages per page: