From owner-freebsd-java@FreeBSD.ORG Fri Oct 4 21:42:37 2013 Return-Path: Delivered-To: java@FreeBSD.org Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by hub.freebsd.org (Postfix) with ESMTP id D3A2A22B; Fri, 4 Oct 2013 21:42:36 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Message-ID: <524F3599.4060708@FreeBSD.org> Date: Fri, 04 Oct 2013 17:39:37 -0400 From: Jung-uk Kim User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Konstantin Belousov , Sevan / Venture37 Subject: Re: JNA broken with r251668 as libc.so cant be loaded References: <524DFB7D.2000207@gmail.com> <20131004050824.GK41229@kib.kiev.ua> <524E934D.70303@gmail.com> <20131004152000.GS41229@kib.kiev.ua> <524F2FD2.3020801@FreeBSD.org> In-Reply-To: <524F2FD2.3020801@FreeBSD.org> X-Enigmail-Version: 1.5.2 Content-Type: multipart/mixed; boundary="------------050409050902070804060403" Cc: jlh@freebsd.org, java@FreeBSD.org, Jimmy Olgeni X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Oct 2013 21:42:37 -0000 This is a multi-part message in MIME format. --------------050409050902070804060403 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2013-10-04 17:14:58 -0400, Jung-uk Kim wrote: > On 2013-10-04 11:20:00 -0400, Konstantin Belousov wrote: >> On Fri, Oct 04, 2013 at 02:07:09PM +0400, Sevan / Venture37 >> wrote: >>> On 04/10/2013 09:08, Konstantin Belousov wrote: >>>> Does the source contain some workaround for Linux, already ? >>>> Linux uses script for libc.so for very long time, and should >>>> have the same issue unless code explicitely dlopen()s >>>> libc.so.6 or such. >>> >>> >>> No >>> https://svn.java.net/svn/jna~svn/trunk/jnalib/test/com/sun/jna/LibraryLoadTest.java > >>> >>> >> I do not know what should I see in the pointer you provided, and >> how it implies the answer 'No' to my question. > >> I just verified dlopen("libc.so") on some fresh Linux box, and >> the function returned expected error '/lib/libc.so: invalid ELF >> header'. > > I haven't verified it but it seems to have special case for Linux. > Please see: > > https://github.com/twall/jna/blob/master/src/com/sun/jna/NativeLibrary.java#L206 > > https://github.com/twall/jna/blob/master/src/com/sun/jna/NativeLibrary.java#L741 > https://github.com/twall/jna/blob/master/src/com/sun/jna/NativeLibrary.java#L768 Verified. > This simple patch fixed the problem for me. http://people.freebsd.org/~jkim/jna.diff Cheers, Jung-uk Kim -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (FreeBSD) iQEcBAEBAgAGBQJSTzWZAAoJEHyflib82/FGl+YIAIWWYgj5+30j648gZJgVF0G/ M2RglpJkjw4w6mdges/AskVvzZSPSQ8/dJVg0Al84Uv2ci7G+cyRivOOowJ7iIZN qrUF44OFRTMhmJMDvqA9zTqfn1VbYf+sdnxpJL8iy43wqhQqFVjXdN0UIHFTKRak plS3VKSzDorNaegyJZiEfTPeRTW/tsj9iPX1+NgJ7w1/hag7A3h3rcKZYPtSvocQ SEsNsFwVdK9lkRFPNdgJT/gocTZZJkuEN3gZ4CAncs6Z4ONfU+xgXCXXsI1jqmFH lBssPWKz8QrJC9VHWpDMMVFLNSNsQVFY15ZDPn126jHwP2mVTZNlrPcV7VNTN1E= =OszO -----END PGP SIGNATURE----- --------------050409050902070804060403 Content-Type: text/x-patch; name="jna.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jna.diff" Index: devel/jna/Makefile =================================================================== --- devel/jna/Makefile (revision 329377) +++ devel/jna/Makefile (working copy) @@ -2,6 +2,7 @@ PORTNAME= jna PORTVERSION= 4.0 +PORTREVISION= 1 CATEGORIES= devel java MASTER_SITES= GH Index: devel/jna/files/patch-src__com__sun__jna__NativeLibrary.java =================================================================== --- devel/jna/files/patch-src__com__sun__jna__NativeLibrary.java (revision 0) +++ devel/jna/files/patch-src__com__sun__jna__NativeLibrary.java (working copy) @@ -0,0 +1,29 @@ +--- src/com/sun/jna/NativeLibrary.java.orig 2013-07-04 14:42:30.000000000 -0400 ++++ src/com/sun/jna/NativeLibrary.java 2013-10-04 17:28:07.000000000 -0400 +@@ -203,7 +203,7 @@ + } + catch(UnsatisfiedLinkError e2) { e = e2; } + } +- else if (Platform.isLinux()) { ++ else if (Platform.isLinux() || Platform.isFreeBSD()) { + // + // Failed to load the library normally - try to match libfoo.so.* + // +@@ -382,7 +382,7 @@ + + // Use current process to load libraries we know are already + // loaded by the VM to ensure we get the correct version +- if ((Platform.isLinux() || Platform.isAIX()) ++ if ((Platform.isLinux() || Platform.isFreeBSD() || Platform.isAIX()) + && Platform.C_LIBRARY_NAME.equals(libraryName)) { + libraryName = null; + } +@@ -702,7 +702,7 @@ + } + return name; + } +- else if (Platform.isLinux()) { ++ else if (Platform.isLinux() || Platform.isFreeBSD()) { + if (isVersionedName(libName) || libName.endsWith(".so")) { + // A specific version was requested - use as is for search + return libName; Property changes on: devel/jna/files/patch-src__com__sun__jna__NativeLibrary.java ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property --------------050409050902070804060403--