[kaffe] libraries/javalib/vmspecific/java/lang/reflect/

Andrew John Hughes gnu_andrew at member.fsf.org
Wed Apr 30 16:33:19 PDT 2008


On 30/04/2008, Ito Kazumitsu <kaz at maczuka.gcd.org> wrote:
> Hi,
>
>  libraries/javalib/vmspecific/java/lang/reflect/Field.java has these lines.
>
>   public String toString()
>   {
>     // 64 is a reasonable buffer initial size for field
>     StringBuilder sb = new StringBuilder(64);
>     Modifier.toString(getModifiers(), sb).append(' ');
>     sb.append(ClassHelper.getUserName(getType())).append(' ');
>     sb.append(getDeclaringClass().getName()).append('.');
>     sb.append(getName());
>     return sb.toString();
>   }
>
>   public String toGenericString()
>   {
>     StringBuilder sb = new StringBuilder(64);
>     Modifier.toString(getModifiers(), sb).append(' ');
>     sb.append(getGenericType()).append(' ');
>     sb.append(getDeclaringClass().getName()).append('.');
>     sb.append(getName());
>     return sb.toString();
>   }
>
>  But GNU Classpath has already replaced Modifier.toString(int, StringBuilder)
>  by Modifier.toString(int, CPStringBuilder).  So Kaffe cannot be built with
>  the current GNU Classpath.
>
>  This problem may be solved by either of the following:
>
>   (1) Wait for the release of the new version of GNU Classpath.
>       Modify Kaffe's methods so that they use CPStringBuilder.
>       Declare that Kaffe requires the new version of GNU Classpath.
>
>   (2) Modify GNU Classpath so that it supports the old method call
>       Modifier.toString(int, StringBuilder).
>
>  (2) is easy, but I do not think it is acceptable for GNU Classpath
>  people.
>
>  _______________________________________________
>  kaffe mailing list
>  kaffe at kaffe.org
>  http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
>

I mailed about this sometime ago on the Classpath list and posted a
temporary patch for Kaffe (basically the one you describe).

However, that's just a quick hack so Kaffe can still be built with the
CVS version of Classpath.  The true fix is to move to using
VMField/Method/Constructor.  At present, the problem is that Kaffe
duplicates a lot of Classpath code verbatim, like these methods.
There's no real reason for Kaffe to have these methods.

If you want to support both old and new Classpath, the best approach
would be to add a compile-time check on the version of Classpath being
compiled against, looking for VMField.  If it's there, Kaffe should
use VMField/Constructor/Method.  If not, use the older
Constructor/Field/Method implementations.
-- 
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 kaffe mailing list