Re: Java virtual machine as target language for C/C++

moresys@world.std.com (More Systems Employee)
19 May 1996 18:25:34 -0400

          From comp.compilers

Related articles
[13 earlier articles]
Re: Java virtual machine as target language for C/C++ dean@psy.uq.oz.au (1996-05-10)
Re: Java virtual machine as target language for C/C++ khays@sequent.com (1996-05-13)
Re: Java virtual machine as target language for C/C++ genew@mindlink.bc.ca (1996-05-13)
Re: Java virtual machine as target language for C/C++ pardo@cs.washington.edu (1996-05-14)
Re: Java virtual machine as target language for C/C++ dmoisan@shore.net (1996-05-14)
Re: Java virtual machine as target language for C/C++ rfg@monkeys.com (1996-05-19)
Re: Java virtual machine as target language for C/C++ moresys@world.std.com (1996-05-19)
Re: Java virtual machine as target language for C/C++ pardo@cs.washington.edu (1996-05-19)
Re: Java virtual machine as target language for C/C++ robison@kai.com (Arch Robison) (1996-05-21)
Re: Java virtual machine as target language for C/C++ pardo@cs.washington.edu (1996-05-24)
Re: Java virtual machine as target language for C/C++ wws@renaissance.cray.com (1996-05-25)
Re: Java virtual machine as target language for C/C++ tmb@best.com (1996-05-26)
Re: Java virtual machine as target language for C/C++ dw3u+@andrew.cmu.edu (Daniel C. Wang) (1996-05-27)
[4 later articles]
| List of all articles for this month |
From: moresys@world.std.com (More Systems Employee)
Newsgroups: comp.lang.java,comp.lang.c++,comp.compilers
Date: 19 May 1996 18:25:34 -0400
Organization: MORE Systems, inc.
References: 96-05-036
Keywords: Java, C++

Drinie@xs4all.nl says...
>I know that Java does not support pointer arithmetic.
>
>But as the Java virtual machine gets integrated in many OSes it would
>be nice to use it as a target language for other languages.
>
>Is it possible (and will Sun allow it) to extend the JVM to support
>pointer arithmetic.


No. This would be extremely unpopular, as it would completely invalidate
Java's much-touted security.


However, it would be possible to emulate a C environment using a simple
byte array. A C pointer would translate into an array offset, and
all the pointer arithmetic and arbitrary casts of types could be
supported. With a smart JIT compiler, you may even get just as
efficient code. You'd have to port malloc(), free(), and the rest of
the standard C library, but that should be pretty straightforward:
they could all be methods of a C emulator class that would also
implement the memory-access primitives.


You'd get memory leaks, invalid pointers, and all the rest of the
problems you get from normal C, but you wouldn't need to change a
line of your legacy code, and you wouldn't be able to jeopardize
anything outside the 'anything goes' byte-array memory space.
Attempts to access values outside the byte-array would throw
an exeption (perhapse we could call it GPF!)


-Eugene


--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.