This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[ecj] Patch: FYI: fix reading of string annotations
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 17 Oct 2006 13:59:58 -0600
- Subject: [ecj] Patch: FYI: fix reading of string annotations
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcj-eclipse branch.
Despite what the online documentation says, java compilers generate
utf8 constant references and not string references for 'string'
annotation values.
This patch updates jcf-dump and gij to follow.
Tom
Index: libjava/ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/lang/natClass.cc (parseAnnotationElement): Expect a utf8
constant in the "string" case.
* defineclass.cc (handleAnnotationElement): Expect a utf8 constant
in the "string" case.
Index: gcc/java/ChangeLog
from Tom Tromey <tromey@redhat.com>
* jcf-dump.c (print_element_value): Expect a utf8 constant in the
"string" case.
Index: gcc/java/jcf-dump.c
===================================================================
--- gcc/java/jcf-dump.c (revision 117511)
+++ gcc/java/jcf-dump.c (working copy)
@@ -499,8 +499,10 @@
case 's':
{
uint16 cindex = JCF_readu2 (jcf);
+ /* Despite what the JVM spec says, compilers generate a Utf8
+ constant here, not a String. */
print_constant_terse_with_index (stream, jcf, cindex,
- CONSTANT_String);
+ CONSTANT_Utf8);
}
break;
Index: libjava/java/lang/natClass.cc
===================================================================
--- libjava/java/lang/natClass.cc (revision 117705)
+++ libjava/java/lang/natClass.cc (working copy)
@@ -1142,7 +1142,9 @@
case 's':
{
int cindex = read_u2 (bytes, last);
- check_constant (pool, cindex, JV_CONSTANT_String);
+ // Despite what the JVM spec says, compilers generate a Utf8
+ // constant here, not a String.
+ check_constant (pool, cindex, JV_CONSTANT_Utf8);
result = _Jv_Linker::resolve_pool_entry (klass, cindex).string;
}
break;
Index: libjava/defineclass.cc
===================================================================
--- libjava/defineclass.cc (revision 117705)
+++ libjava/defineclass.cc (working copy)
@@ -526,8 +526,10 @@
case 's':
{
int index = read2u();
- check_tag (index, JV_CONSTANT_String);
- prepare_pool_entry (index, JV_CONSTANT_String);
+ // Despite what the JVM spec says, compilers generate a Utf8
+ // constant here, not a String.
+ check_tag (index, JV_CONSTANT_Utf8);
+ prepare_pool_entry (index, JV_CONSTANT_Utf8);
}
break;