Re: is awt/swing supposed to work ?

441 views
Skip to first unread message

Joel Dice

unread,
Mar 27, 2013, 10:08:03 AM3/27/13
to av...@googlegroups.com
On Wed, 27 Mar 2013, the....@gmail.com wrote:

> The missing library hints me that Avian doesn't support awt or at least on
> OSX, is it true ?

I've only tried AWT/Swing on Linux so far, so I'm not surprised if it
doesn't work on OS X or Windows. It shouldn't be too hard to make it
work, though; we just need to find where libawt.dylib is located and make
sure the VM's library path includes that directory. There might be other
changes needed, too, but that's where I would start.

Joel Dice

unread,
Mar 27, 2013, 1:39:46 PM3/27/13
to av...@googlegroups.com
On Wed, 27 Mar 2013, the....@gmail.com wrote:

> ok, how do I add a library to the VM path ?

You'll want to add the directory to the path created in the MyClasspath
constructor in classpath-openjdk.cpp. I'm kind of surprised the VM isn't
already finding libawt.dylib and libosx.dylib, though, since those are
both present in $JAVA_HOME/jre/lib on my system. Maybe dlopen can find
them but can't load them for some reason; you might want to try rebuilding
with Verbose = true in posix.cpp, which will print any error messages from
dlopen.

Joel Dice

unread,
Mar 27, 2013, 3:26:21 PM3/27/13
to av...@googlegroups.com
On Wed, 27 Mar 2013, the....@gmail.com wrote:

> well, I don't have $JAVA_HOME set, I'm trying to make a bundle out of Avian,
> without any dependency.Is it not possible to bundle libs in avian ?

Ah, then you must be doing an openjdk-src build. You've got two options
to make that work with Swing/AWT -- one is to track down all the .c files
needed to build libawt.dylib (and maybe libosx.dylib and whatever else is
needed) and add them to openjdk-src.mk. The other option is to add those
dylibs to your embedded jars and extract them onto the filesystem at
runtime and load them before they're needed.

Scott Duensing

unread,
Mar 28, 2013, 12:59:03 PM3/28/13
to av...@googlegroups.com, the....@gmail.com
Best of luck!  The closer Avian is to an everything-compiled-into-one-big-blob Java runtime, the happier I am!  :-)

Scott



On Wednesday, March 27, 2013 2:41:32 PM UTC-5, the....@gmail.com wrote:
ok, I'll try that and hopefully push it to git (no warranty though)

Joel Dice

unread,
Mar 28, 2013, 6:08:35 PM3/28/13
to av...@googlegroups.com, the....@gmail.com
On Thu, 28 Mar 2013, the....@gmail.com wrote:

> about big blobs,�I don't feel like I have the skills to add those .m files
> to compile time, I'm a Java guy with poor C skills :-/

Yeah, it's a pain to do even when you know what you're doing :)

> However, I thought that maybe we could pack the compiled .dylib (maybe even
> .so and .dll lets not be racist) inside avian and load them dynamically ?
> like modify Classloader.java and/or the underlying lib-loading magic to keep
> a static list of libs to be loaded from inside ?

Yes, that's basically what I was suggesting. I recommend doing what SWT
does: embed the libraries in the jar (e.g. classpath.jar) and extract them
from that jar at runtime using Class.getResourceAsStream, then load them
using System.load:

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT%20PI/common_j2se/org/eclipse/swt/internal/Library.java

Scott Duensing

unread,
Mar 28, 2013, 8:01:13 PM3/28/13
to av...@googlegroups.com, the....@gmail.com
Technically, I don't care how it works.  :-)  What I'm personally after is a self-contained jMonkeyEngine runtime.  This technique gives me something new to play with.  :-)  Thanks!



On Thursday, March 28, 2013 5:08:35 PM UTC-5, Joel Dice wrote:
On Thu, 28 Mar 2013, the....@gmail.com wrote:

> about big blobs,�I don't feel like I have the skills to add those .m files

the....@gmail.com

unread,
Jul 28, 2013, 10:38:34 AM7/28/13
to av...@googlegroups.com, the....@gmail.com

I had some time to work on that issue:
I re-built avian and openjdk up to date and tried a very simple test case.
However, when I try to run it, it simply fails:

MacBookAirMax:Logetel max$ avian -jar ~/Desktop/av.jar /Users/max/Desktop/libawt.dylib 
the file you passed exists
java/lang/UnsatisfiedLinkError: library not found: /Users/max/Desktop/libawt.dylib
  at java/lang/ClassLoader.loadLibrary (native)
  at java/lang/Runtime.load0 (line 792)
  at java/lang/System.load (line 1059)
  at avtest/AvianTest.main (line 17)

(the libawt.dylib file is fresh from the open-jdk compilation)
What do you think ?

AvianTest.java
Reply all
Reply to author
Forward
0 new messages