Hi All,
 
    I am working JJOS so that It can print correctly. But I found some bugs of some source code.  Here it is.
 
jvmbuiltins.cc -- array_copy
-------------------cut here---------------------
  for( jju32 x = pos; x < pos + length; x++ ) {
  dest_array->store(x, src_array->load( offset + x ) );
  } /* end copy loop */
 
  return JJTRUE;
} /* end arraycopy() */
-------------------cut here---------------------
Original Souce Code is using offset in the for-loop instead of pos. It can't
copy array correctly.
 
jvmbuiltins.cc -- print_string
-------------------cut here---------------------
if (*quux == constant_utf8("java/lang/String"))
{
/* java_object *jo = (java_object *)(arguments[1
]); */
java_string *js = (java_string *)foo;
if (js->myUTF8 != 0)
kprintf("%s", js->myUTF8->c_str()); // $$ Leaks.
else
kprintf("null");
break;
} /* end if a string */
else
{
/* if it's not a String */
-------------------cut here---------------------
 
Original Souce Code will not check js->myUTF8 is null or not. If it
is null,
it will makes core dump.

After Fixiing, it stills can't fix the println problem. Since JJOS is
using native java string. If the java source performs
a operation like object.toString(). It will not work.
Currently, we can use an alternative approach to print it.
 
-------------------cut here---------------------
int a = Integer.MIN_VALUE ;
String b = new Integer(a).toString();
char[] buf = b.toCharArray();
for (int count=0;count<buf.length;count++) {
System.out.print(buf[count]);
}
System.out.println("");
-------------------cut here---------------------
It can print value from value from long, int, etc. But It will not
works all the times. But at least, we can use this
approach in native printing function in JJOS.
 
Regards,
 
Hilary

Reply via email to