OpenJDK b33 and IcedTea

Mark Wielaard mark at
Tue Aug 26 09:50:58 UTC 2008

Hi Andrew,

On Tue, 2008-08-26 at 00:46 +0100, Andrew John Hughes wrote:
> >  I'm currently stuck on this strange issue whereby
> >  sun_java2d_opengl_OGLContext_OGLContextCaps.h is not being generated.
> >  Has anyone else seen this? To try for yourself, you can get a b33
> >  IcedTea from
> Further on this, with Mark's help via IRC, I made the following
> additions to icedtea-ecj.patch:
> +++ openjdk-ecj/jdk/make/common/Rules.gmk	2008-08-26 00:30:58.000000000 +0100
> - +-		$(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner))
> +		$(CLASSES.export)
> +	$(foreach innerclass,$(subst $$,\$$,$(EXPORTED_inner)), \
> +	  $(JAVAH_CMD) \
> +	    -o $(CLASSHDRDIR)/$(subst .,_,$(subst \$$,_,$(innerclass))).h \
> +	    $(innerclass))
> +++ openjdk-ecj/jdk/make/sun/awt/FILES_export_unix.gmk	2008-08-25
> 3:13:37.000000000 +0100
> @@ -223,3 +223,5 @@
>  	sun/awt/ \
>  	sun/awt/motif/
> +EXPORTED_inner = \
> +    sun.java2d.opengl.OGLContext$$OGLContextCaps
> The first change generally gets round the ambiguity in the naming of
> header files generated from inner classes by explicitly specifying an
> output file name for members of EXPORTED_inner.  By default, gjavah
> keeps the $ in the filename, while javah replaces it with _ -- neither
> behaviour is formally specified.

I like this change. Traditionally the various javah commands (gcjh,
kaffeh, gjavah) didn't use the same default output name. So adding an
explicit -o makes this much more robust.

> The second more specific change adds
> sun.java2d.opengl.OGLContext$OGLContextCaps to EXPORTED_inner as it
> doesn't seem to be added and thus generated at all, even with the
> wrong output name.

This one seems correct, although I cannot see how it worked before.

> There's still an issue; the build can now find the header but javah
> and gjavah appear to name them differently:
> ../../../src/share/native/sun/java2d/opengl/OGLContext.c:855: error:
> 'sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_TEXNONSQUARE'
> undeclared (first use in this function)
> gjavah only generates a subset and encodes them wrongly:
> #define sun_java2d_opengl_OGLContext_00024OGLContextCaps_CAPS_STORED_ALPHA 2L

I believe gjavah is correct here.
The class name is "OGLContext$GLContextCaps". Which contains according
to the jni C translation rules contains the escape sequence _0XXXX where
the XXXX is 0024 for the unicode character $.

I don't know how the openjdk javah gets the single underscore. If you
wanted to encode it as OGLContext_GLContextCaps (as the default output
name hints is what javah prefers), then the underscore would translate
to _1, giving "OGLContext_1GLContextCaps".

This is all a bit unfortunate since the .c source code does use these
constants literally. Easiest solution for now seems a simple sed
invocation on the resulting .h file that turns a the sequence '_00024'
into a single underscore '_'. A better recommendation might be to not
mix inner classes and native methods since the results don't seem to be
very consistent across implementations (of javah).



More information about the build-dev mailing list