jdk15/javaws on amd64

Greg Lewis glewis at eyesbeyond.com
Wed Mar 19 05:57:34 UTC 2008


G'day Peter,

On Wed, Mar 19, 2008 at 08:41:06AM +1100, Peter Jeremy wrote:
> On Tue, Mar 18, 2008 at 05:15:25PM +1100, Peter Jeremy wrote:
> >I've done some poking at it with both some printf()s and gdb and it
> >appears to be a gcc bug - in fact, I'm surprised it works at all...
> >
> >The relevant function is GetBootClassPath():
> >char* GetBootClassPath(void) {
> >  static char bootclasspath[MAXPATHLEN];
> >#ifdef _DEBUG
> >  sprintf(bootclasspath, "%s%c%s%c%s%c%s", 
> >                sysGetJarLib(), FILE_SEPARATOR, "javaws_g.jar",
> >                PATH_SEPARATOR, sysGetJarLib(), FILE_SEPARATOR, "deploy_g.jar");
> >#else
> >  sprintf(bootclasspath, "%s%c%s%c%s%c%s", 
> >                sysGetJarLib(), FILE_SEPARATOR, "javaws.jar",
> >                PATH_SEPARATOR, sysGetJarLib(), FILE_SEPARATOR, "deploy.jar");
> >#endif
> >  return bootclasspath;
> >}
> 
> I've done a bit more investigating and the problem is that
> sysGetJarLib() returns char*, and this is assumed by the above code.
> But there is no prototype in scope for the above code so gcc assumes
> that sysGetJarLib() returns int and passes it to sprintf as an int.
> 
> Looking further, there is no prototype for sysGetJarLib() anywhere in
> the source code - or, for that matter many of the other functions in
> deploy/src/javaws/share/native/system.c that also return char*.
> 
> This code can't work correctly on any platform where
> sizeof(int) != sizeof(void*) so I'm not quite sure how Sun make it
> work on Sun SPARC...

I've had javaws work on amd64 for 1.5, so my guess would be that earlier
versions of gcc have just been more lenient here.  It wasn't enabled for
amd64 without trying it :).

Also, its quite possible that it wasn't working on Solaris/Sparc64 since
we're the first OS to include the browser plugin and javaws on a 64 bit
platform.

> I'm currently trying to rebuild Java with -Wall to see how many of
> these sorts of bugs exist.  In the meantime, I would suggest that
> java is broken on any 64-bit architecture.

I suspect the number is very few in the main code which is solidly tested
on 64 bit platforms.  HotSpot is compiled with -Werror and much of the
rest of the main code is compiled with -Wall.  The plugin and javaws are
a different matter though and if there are lurking bugs of this type they
are most likely there.  As above, we're the first ones to enable them on
amd64, so its quite possible some bugs were missed in porting as the
plugin in particular took a lot of work to get working on a 64 bit
platform.

-- 
Greg Lewis                          Email   : glewis at eyesbeyond.com
Eyes Beyond                         Web     : http://www.eyesbeyond.com
Information Technology              FreeBSD : glewis at FreeBSD.org


More information about the freebsd-java mailing list