Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Combining C and java

Reply
Thread Tools

Combining C and java

 
 
kim bruning
Guest
Posts: n/a
 
      10-21-2003
Jezuch wrote:
> Mike Yawn wrote:
>
> But GCC is *not* a C compiler. It is among others a C compiler It can
> also compile C++, Ada, Fortran and Java, both to native and byte-code.
>
> see http://www.gnu.org/software/gcc/java/
>
> "GCJ is a portable, optimizing, ahead-of-time compiler for the Java
> Programming Language. It can compile:
> * Java source code directly to native machine code,
> * Java source code to Java bytecode (class files),
> * and Java bytecode to native machine code."


Heh, cool!

"In IT whenever you say something is impossible, there's always
someone who will will stand up the and point out that not only is it
possible, but that it's already being done." - I wonder who said this?

Thank you very much. I'd better start looking at gcj more seriously for
myself too.

read you soon,
Kim Bruning

 
Reply With Quote
 
 
 
 
Paul Lutus
Guest
Posts: n/a
 
      10-21-2003
Jezuch wrote:

> Mike Yawn wrote:
>> I suspect it would be very difficult to get a C compiler to target the
>> JVM. The JVM bytecodes were designed to implement a strongly-typed
>> language (Java). While compilers for other strongly-typed languages
>> might be able to target the JVM, I can't imagine how some of the crap C
>> allows you to get away with could be mapped to a valid bytecode sequence.

>
> But GCC is *not* a C compiler. It is among others a C compiler It can
> also compile C++, Ada, Fortran and Java, both to native and byte-code.
>
> see http://www.gnu.org/software/gcc/java/
>
> "GCJ is a portable, optimizing, ahead-of-time compiler for the Java
> Programming Language. It can compile:
> * Java source code directly to native machine code,
> * Java source code to Java bytecode (class files),
> * and Java bytecode to native machine code."


Yes, but only for Java 1.1, and that with important limitations. An
important qualification.

--
Paul Lutus
http://www.arachnoid.com

 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      10-22-2003
Jezuch <(E-Mail Removed)> writes:
> But GCC is *not* a C compiler. It is among others a C compiler It can
> also compile C++, Ada, Fortran and Java, both to native and byte-code.
>
> see http://www.gnu.org/software/gcc/java/
>
> "GCJ is a portable, optimizing, ahead-of-time compiler for the Java
> Programming Language. It can compile:
> * Java source code directly to native machine code,
> * Java source code to Java bytecode (class files),
> * and Java bytecode to native machine code."



I think we all know that it is possible to compile Java to Java byte
code.

The question was to compile C to Java byte code. And(!) to get a
program that indeed works the same as if the C code would have been
compiled to native machine code directly.

/Thomas
 
Reply With Quote
 
John Eskie
Guest
Posts: n/a
 
      10-22-2003
> I think we all know that it is possible to compile Java to Java byte
> code.
>
> The question was to compile C to Java byte code. And(!) to get a
> program that indeed works the same as if the C code would have been
> compiled to native machine code directly.
>


Thats right. I think I came to the conclusion that it was not possible with
GCC or GCJ. I concluded I will go via the JNI way.
But this raises new problems. One is that I will need to native library for
every platform I support. I don't know java good enough to say if JNI is
actually supported on all it's platforms but I think it should be.
The other problem is if people actually accept this solution. After all java
is similar to saying "write once, execute anywhere". By having the JNI it
becomes "write once and run where I want it to run". I will naturally make
sure to cover the major platforms but I got no reallife experience if people
actually accept solutions like this.

-- John


 
Reply With Quote
 
Jezuch
Guest
Posts: n/a
 
      10-22-2003
Paul Lutus wrote:
> Yes, but only for Java 1.1, and that with important limitations. An
> important qualification.


I'm not sure about this, the main limitation is libraries, mostly lack
od Swing and parts of AWT (it will compile, but Toolkit won't work, for
example). And I've successfully compiled programs written for 1.3.
--
Ecce Jezuch
"Life feeds on life feeds on life feeds on life feeds on life...
This is necessary." - M. J. Keenan

 
Reply With Quote
 
Jezuch
Guest
Posts: n/a
 
      10-22-2003
Thomas Weidenfeller wrote:
> The question was to compile C to Java byte code. And(!) to get a
> program that indeed works the same as if the C code would have been
> compiled to native machine code directly.


Ok, then I missed this part
--
Ecce Jezuch
"Life feeds on life feeds on life feeds on life feeds on life...
This is necessary." - M. J. Keenan

 
Reply With Quote
 
kim bruning
Guest
Posts: n/a
 
      10-22-2003
John Eskie wrote:
>>I think we all know that it is possible to compile Java to Java byte
>>code.
>>
>>The question was to compile C to Java byte code. And(!) to get a
>>program that indeed works the same as if the C code would have been
>>compiled to native machine code directly.
>>

>
>
> Thats right. I think I came to the conclusion that it was not possible with
> GCC or GCJ.


Well, there *is* experimental support to be found here:
http://www.itee.uq.edu.au/~cristina/uqbt.html#gcc-jvm

Unfortunately there probably won't be mainstram gcc support in time for
you to use it in this case. This is a 1999 project in fact, and for some
reason people don't appear to have implemented this in the main source
tree. (according to google)

Perhaps because too few people are showing a vocal interest?

Do annoy the gcc team with a complaint I'd say. You never know.

In the mean time, good luck with your chosen solution, and
have fun!

sincerely,
Kim Bruning

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining Java Reflection API with Java Annotation Types for Thread Safety pek Java 2 10-23-2007 03:00 PM
Combining The Best Of Python, Ruby, & Java?????? Tim Daneliuk Python 9 06-13-2006 08:30 PM
Combining numeric mode paging and nextPreview paging in datagrid Red ASP .Net 1 03-12-2005 11:41 PM
T-bird and combining messages Dudhorse Firefox 2 11-12-2004 11:55 PM
Combining forms and Windows authentication Nils Magnus Englund ASP .Net 0 04-19-2004 12:09 PM



Advertisments