public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* a question about directory structure of libjava
@ 2011-01-20  8:50 majia gm
  2011-01-20  9:08 ` Bryce McKinlay
  0 siblings, 1 reply; 4+ messages in thread
From: majia gm @ 2011-01-20  8:50 UTC (permalink / raw)
  To: gcc-help, Java List

Hi.

I'm new to gcj. And I'm reading the source code in the directory of
libjava. I'm a little confused by the structure of the directory.

I found that there often exists two java files, which have much
differnce in content, having the same name in different directories.
Such as,

libjava/java/lang/Class.java
libjava/classpath/java/lang/Class.java

Will both of them be used?

I also found C++ files libjava/java/lang/Class.h, which declares the
class Class in C++ corresponding to Class.java.
And libjava/java/lang/natClass.cc, which implements the native methods.

 But there's often no implementation of methods in C++.
 Dose the method code come from the Java file? How dose this happen?


Thank you.

Gmmajia

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: a question about directory structure of libjava
  2011-01-20  8:50 a question about directory structure of libjava majia gm
@ 2011-01-20  9:08 ` Bryce McKinlay
  2011-01-20 12:42   ` majia gm
  0 siblings, 1 reply; 4+ messages in thread
From: Bryce McKinlay @ 2011-01-20  9:08 UTC (permalink / raw)
  To: majia gm; +Cc: gcc-help, Java List

On Thu, Jan 20, 2011 at 8:50 AM, majia gm <gmmajia@gmail.com> wrote:
>
> I'm new to gcj. And I'm reading the source code in the directory of
> libjava. I'm a little confused by the structure of the directory.
>
> I found that there often exists two java files, which have much
> differnce in content, having the same name in different directories.
> Such as,
>
> libjava/java/lang/Class.java
> libjava/classpath/java/lang/Class.java
>
> Will both of them be used?

The files in libjava/classpath are directly imported from the GNU
Classpath project. In some cases, such as this one, libjava overrides
classpath's classes with its own.

> I also found C++ files libjava/java/lang/Class.h, which declares the
> class Class in C++ corresponding to Class.java.
> And libjava/java/lang/natClass.cc, which implements the native methods.

Right, the .h files are generated by the gcjh tool.

>  But there's often no implementation of methods in C++.
>  Dose the method code come from the Java file? How dose this happen?

In some cases the native methods are implemented by the GNU Classpath
code in JNI (C), rather than CNI (C++). These implementations can be
found under libjava/classpath/native/jni.

Bryce

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: a question about directory structure of libjava
  2011-01-20  9:08 ` Bryce McKinlay
@ 2011-01-20 12:42   ` majia gm
  2011-01-20 13:24     ` Bryce McKinlay
  0 siblings, 1 reply; 4+ messages in thread
From: majia gm @ 2011-01-20 12:42 UTC (permalink / raw)
  To: Bryce McKinlay; +Cc: gcc-help, Java List

2011/1/20 Bryce McKinlay <bmckinlay@gmail.com>:
> On Thu, Jan 20, 2011 at 8:50 AM, majia gm <gmmajia@gmail.com> wrote:
>>
>> I'm new to gcj. And I'm reading the source code in the directory of
>> libjava. I'm a little confused by the structure of the directory.
>>
>> I found that there often exists two java files, which have much
>> differnce in content, having the same name in different directories.
>> Such as,
>>
>> libjava/java/lang/Class.java
>> libjava/classpath/java/lang/Class.java
>>
>> Will both of them be used?
>
> The files in libjava/classpath are directly imported from the GNU
> Classpath project. In some cases, such as this one, libjava overrides
> classpath's classes with its own.
>
>> I also found C++ files libjava/java/lang/Class.h, which declares the
>> class Class in C++ corresponding to Class.java.
>> And libjava/java/lang/natClass.cc, which implements the native methods.
>
> Right, the .h files are generated by the gcjh tool.
>
>>  But there's often no implementation of methods in C++.
>>  Dose the method code come from the Java file? How dose this happen?
>
> In some cases the native methods are implemented by the GNU Classpath
> code in JNI (C), rather than CNI (C++). These implementations can be
> found under libjava/classpath/native/jni.
>
> Bryce
>

Hi, Bryce.

Thanks for your reply. It's very kind of you.

I'v read a little document of JNI and CNI.

CNI seems to layout data such as classes and objects conforming to
C++, so there comes the header file.

 What I'm really curious about is how the non-native methods in
library being executed in runtime. One way I can imagine is to
interpret the byte codes.

But when I use GDB to track gij,  I found native codes,  source lines
of which is in Java files of the library.

Dose it mean the byte codes in library may be translated into native codes?
 If it is the truth, then when dose it happen?

Thank you.

Gmmajia

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: a question about directory structure of libjava
  2011-01-20 12:42   ` majia gm
@ 2011-01-20 13:24     ` Bryce McKinlay
  0 siblings, 0 replies; 4+ messages in thread
From: Bryce McKinlay @ 2011-01-20 13:24 UTC (permalink / raw)
  To: majia gm; +Cc: gcc-help, Java List

On Thu, Jan 20, 2011 at 12:42 PM, majia gm <gmmajia@gmail.com> wrote:

> Hi, Bryce.
>
> Thanks for your reply. It's very kind of you.
>
> I'v read a little document of JNI and CNI.
>
> CNI seems to layout data such as classes and objects conforming to
> C++, so there comes the header file.
>
>  What I'm really curious about is how the non-native methods in
> library being executed in runtime. One way I can imagine is to
> interpret the byte codes.
>
> But when I use GDB to track gij,  I found native codes,  source lines
> of which is in Java files of the library.
>
> Dose it mean the byte codes in library may be translated into native codes?
>  If it is the truth, then when dose it happen?

gcj is a java-to-native-code compiler. So, the Java code in libjava is
compiled, by gcj, into a native code library, libgcj.so. libgcj.so
contains both the Java and C/C++ parts of the library. This all
happens at the time you build GCC, rather than at runtime like a
traditional JVM.

Bryce

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-20 13:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-20  8:50 a question about directory structure of libjava majia gm
2011-01-20  9:08 ` Bryce McKinlay
2011-01-20 12:42   ` majia gm
2011-01-20 13:24     ` Bryce McKinlay

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).