Language extensions ?

Alexandre Oliva aoliva@redhat.com
Thu Mar 27 04:35:00 GMT 2003


On Mar 27, 2003, "Robin Garner" <robin.garner@iname.com> 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 http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer



More information about the Java mailing list