I'm checking this in.
I used Classpath's javah to regenerate all the files in include/ and
then did a diff. This found a few buglets in the JNI support. Fix
appended.
I'm not checking in the updated include files... but I suppose we
ought to at some point. Currently the only differences are some very
minor whitespace (ours prints a newline where gcjh did not) and
ordering (which I suspect are due to changes in the .java files not
followed by a header file regen).
Also, I think GtkDragSourceContextPeer.h is misnamed. I don't see how
it would be rebuilt by the current rules.
Finally, I commented out the pesky assert we talked about earlier.
Tom
2006-08-09 Tom Tromey <[EMAIL PROTECTED]>
* tools/gnu/classpath/tools/javah/JniHelper.java (getName): Properly
handle arrays.
* tools/gnu/classpath/tools/javah/JniIncludePrinter.java
(writeFields): Print "L" after int constant. Don't mangle the field
name. Only print int/long fields.
Index: tools/gnu/classpath/tools/javah/JniHelper.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/javah/JniHelper.java,v
retrieving revision 1.1
diff -u -r1.1 JniHelper.java
--- tools/gnu/classpath/tools/javah/JniHelper.java 28 Jul 2006 15:22:29
-0000 1.1
+++ tools/gnu/classpath/tools/javah/JniHelper.java 9 Aug 2006 17:12:09
-0000
@@ -69,12 +69,12 @@
{
Type elt = type.getElementType();
int eltSort = elt.getSort();
- if (eltSort != Type.OBJECT && eltSort != Type.ARRAY)
+ if (type.getDimensions() == 1 && eltSort != Type.OBJECT)
return getName(classpath, elt) + "Array";
- return "jarray";
+ return "jobjectArray";
}
- assert type.getSort() == Type.OBJECT;
+ // assert type.getSort() == Type.OBJECT;
String className = type.getClassName();
// FIXME: is this correct?
if (className.equals("java/lang/Class")
Index: tools/gnu/classpath/tools/javah/JniIncludePrinter.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/javah/JniIncludePrinter.java,v
retrieving revision 1.1
diff -u -r1.1 JniIncludePrinter.java
--- tools/gnu/classpath/tools/javah/JniIncludePrinter.java 28 Jul 2006
15:22:29 -0000 1.1
+++ tools/gnu/classpath/tools/javah/JniIncludePrinter.java 9 Aug 2006
17:12:09 -0000
@@ -67,16 +67,23 @@
{
FieldNode field = (FieldNode) i.next();
if (! Modifier.isStatic(field.access)
- || ! Modifier.isFinal(field.access) || field.value == null)
+ || ! Modifier.isFinal(field.access))
continue;
- String name = (JniHelper.mangle(klass.name) + "_" +
JniHelper.mangle(field.name));
+ if (! (field.value instanceof Integer)
+ && ! (field.value instanceof Long))
+ continue;
+
+ // Note that we don't want to mangle the field name.
+ String name = (JniHelper.mangle(klass.name) + "_" + field.name);
out.print("#undef ");
out.println(name);
out.print("#define ");
out.print(name);
out.print(" ");
out.print(field.value);
- if (field.value instanceof Long)
+ if (field.value instanceof Integer)
+ out.print("L");
+ else if (field.value instanceof Long)
out.print("LL");
out.println();
wroteAny = true;