Forum Stats

  • 3,757,676 Users
  • 2,251,255 Discussions


Java 'struct' request

Peter Quiring
Peter Quiring Member Posts: 7

I would like to see Java include a light-weight class called a 'struct'.  I originally thought that is what Valhalla was going to be but it seems to be more like a user-defined type that is not a reference.  So a Valhalla object must be 'copied' in full with each assignment.  Good for small tuples.

I was hoping for something more like a 'struct' which would be similar to a 'class' but is more light-weight (a struct would still be a reference but does NOT derive from Object but maybe something called Structure)  It could still have members but because it's a reference you could assign it to other struct references much faster than a Valhalla object.  The overhead of a full 'class' causes much of the 'bloat' in Java.  A leaner 'struct' I think would help reduce memory usage (no monitor or any virtual functions in the base class Structure).