public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
From: "serg at vostok dot net" <gcc-bugzilla@gcc.gnu.org>
To: java-prs@gcc.gnu.org
Subject: [Bug libgcj/31939] Command line arguments are byteswapped before being passed to the program runing in custom locale.
Date: Fri, 18 May 2007 19:07:00 -0000	[thread overview]
Message-ID: <20070518190711.19364.qmail@sourceware.org> (raw)
In-Reply-To: <bug-31939-14546@http.gcc.gnu.org/bugzilla/>



------- Comment #4 from serg at vostok dot net  2007-05-18 20:07 -------
For subject 2.

The point is to find where arguments of "int main(int argc, char** argv)" are
converted into java.lang.String to be passed to "static void main(String[]
args)".




Trail:


gcc/java/jvgenmain.c: 

int main(int argc,char **argv) 
constructs a C code to call the main java method with
JvRunMain(classname,argc,argv)


libjava/prims.cc:

void JvRunMain (jclass klass, int argc, const char **argv)
simply calls
_Jv_RunMain (klass, NULL, argc, argv, false)

void _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
bool is_jar)                             
simply calls                                                                    
_Jv_RunMain (NULL, klass, name, argc, argv, is_jar)

void _Jv_RunMain (JvVMInitArgs *vm_args, jclass klass, const char *name, int
argc, const char **argv, bool is_jar)
calls
JvConvertArgv (argc - 1, argv + 1)

JArray<jstring> * JvConvertArgv (int argc, const char **argv)
copies each argument into jbyteArray bytes, then calls
new java::lang::String (bytes, 0, len)
to make a String from it with a default encoding.


libjava/java/lang/String.java:

public String(byte[] data, int offset, int count)
calls
init (data, offset, count,System.getProperty("file.encoding", "8859_1"))


libjava/java/lang/natString.cc:
void java::lang::String::init (jbyteArray bytes, jint offset, jint count,
jstring encoding)
uses
gnu::gcj::convert::BytesToUnicode::getDecoder(encoding)
to make a converter
and 
converter->read(array, outpos, avail)
to convert data

libjava/gnu/gcj/convert/BytesToUnicode.java:
class BytesToUnicode extends IOConverter 
public static BytesToUnicode getDecoder (String encoding)
uses eigther 
new Input_iconv(encoding)
or
new BytesToCharsetAdaptor(Charset.forName(encoding))

Looks like I will have to test both Input_iconv and BytesToCharsetAdaptor to
see if any of them is buggy.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31939


      parent reply	other threads:[~2007-05-18 19:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-15 16:35 [Bug libgcj/31939] New: " serg at vostok dot net
2007-05-15 17:05 ` [Bug libgcj/31939] " serg at vostok dot net
2007-05-15 17:11 ` serg at vostok dot net
2007-05-15 17:33 ` serg at vostok dot net
2007-05-18 19:07 ` serg at vostok dot net [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070518190711.19364.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=java-prs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).