[gcj trunk / gnu-classpath] String.format(...) undefined

Hanno Meyer-Thurow h.mth@web.de
Sat Mar 3 11:47:00 GMT 2007


On 02 Mar 2007 14:54:10 -0700
Tom Tromey <tromey@redhat.com> wrote:

> >>>>> "Hanno" == Hanno Meyer-Thurow <h.mth@web.de> writes:
> 
> Hanno> I have no idea how to get that. Are there any Java debugging
> Hanno> docs somewhere?
> 
> http://gcc.gnu.org/wiki/Debugging_tips_for_libgcj

Thanks for the link!

Anyway, I got a raw evil hack that works halfway. I bet this is the wrong
way to solve but fixes at least arraymethods in annotation of type Class
and String. The primitive type arraymethods get correct Signature but
elements are not written to the array like they should.

What should be?

Annotation arraymethods can be of type Class, String and primitive type.

What is right now?

Annotation arraymethods are always of type Object that fails with
isInstance method check. The primitive type array elements are stored
as their Java Object counterpart.

What does this evil hack do?

It tells _Jv_NewObjectArray what kind of array it should create.
Then, it checks what kind of elements are within and stores
that type of elements in the array.

What is wrong with this hack?

For example

	b_arr[i] = ((Byte*)(parseAnnotationElement(klass, pool, bytes, last)))->byteValue();

parseAnnotationElement returns the correct Object/value but then
somehow the information is mixed up and ->byteValue() returns '0'.

Though, double type elements are stored correctly in their double array.
And long type elements throw an Exception:

Exception in thread "main" java.lang.InternalError: expected pool constant 6 but got 5
   at java.lang.Class.getDeclaredAnnotations(Class.java:1359)
   at java.lang.Class.getAnnotations(Class.java:1276)
   at java.lang.Class.getAnnotation(Class.java:1255)
   at Test.main(Test.java:57)


Some testresults with Sun JDK 1.6.0 and GIJ:

$ /opt/sun-jdk-1.6.0/bin/java Test
4
7
2
c
a
c
4
7
2
true
false
true
4
7
2
4.000005
7.1234
2.9
4.0
7.0
2.0

$ /usr/lib/gcj/bin/gij Test
0
0
0


c
0
0
4
false
false
false
0
4
7
4.000005
7.1234
2.9
0.0
4.0
7.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.java
Type: text/x-java
Size: 2373 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20070303/b0fa812b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcj-4.3-anno-arraymethods.diff
Type: text/x-patch
Size: 2599 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20070303/b0fa812b/attachment-0001.bin>


More information about the Java mailing list