OpenJDK b33 and IcedTea

Andrew John Hughes gnu_andrew at member.fsf.org
Tue Aug 26 13:22:21 UTC 2008


2008/8/26 Mark Wielaard <mark at klomp.org>:
> 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 http://fuseyism.com/hg/icedtea.
>>
>> 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/CausedFocusEvent.java \
>>       sun/awt/motif/MEmbedCanvasPeer.java
>>
>> +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.
>

So do I.  I think this should really go upstream.

>> 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.
>

Me neither.  The proof will be in the openjdk as opposed to openjdk-ecj build
which won't have this patch applied (it being part of openjdk-ecj.patch).
We of course have to get that far first :)

>> 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).
>

I think the simplest solution is to patch the c file in openjdk-ecj.patch.  This
also solves the issue mentioned in your other mail.  Substituting the
_00024 with
_ is more tricky because in the other inner class
header,ClassLoader.NativeLibrary,
 _00024 does appear and is used by the .c file.  I wonder if there is
some implicit rule difference
between constant and method name generation?  Seems like it's worth
looking through
the javah source code.

> Cheers,
>
> Mark
>
>

Cheers,
-- 
Andrew :-)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net

PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint: F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8



More information about the build-dev mailing list