Language extensions ?

Alexandre Oliva
Thu Mar 27 04:35:00 GMT 2003

On Mar 27, 2003, "Robin Garner" <> wrote:

> What would be _really_ nice would be if gcj provided an address type
> as an extension to the language, and allowed unsafe casts, pointer
> arithmetic etc. in ways similar to Modula 3 and C# (at least until
> java saw the light :).

I don't think this requires language extensions.  Here's a random
thought that just occurred to me:

public class VMMemory {
  public static byte asByte[];
  public static int asInt[];
  public static long asLong[];
  // ...
  public static long getIndexAsChar(Object o);
  public static long getIndexAsInt(Object o);
  // ...

This may be a bit wasteful in that the array objects have to be
created in advance, and bounds checking may get, well, tricky, but you
get the idea.  Depending on the data structure used for arrays, you
get direct access to memory almost for free, and you don't manipulate
addresses, only indexes into the arrays.

Alexandre Oliva   Enjoy Guarana', see
Red Hat GCC Developer                 aoliva@{,}
CS PhD student at IC-Unicamp        oliva@{,}
Free Software Evangelist                Professional serial bug killer

More information about the Java mailing list