It would be really nice if you could have a class that was something like Double with overflow check initially and then when you detect an overflow substitute in something like BigDecimal instead, i.e. hot swapping of the object's class. This saves having to have a class with two fields and checking one field for null in each method. I believe hot-swapping of classes has been considered as a standard JVM addition and that there are some JVMs, particularly in debug mode, that can do this.
Even a very limited form of hot swapping would be useful, you could say that the class must have exactly the same number of instance fields and these must have the same length or be padded and that it must have exactly the same number of virtual methods. Note that double, long, and pointer on many JVMs are 64 bits and therefore even with the limitation of same length you could do something useful (transitioning a number from int through double to arbitrary precision). -- Howard. On 8 September 2011 07:25, Charles Oliver Nutter <head...@headius.com>wrote: > On Wed, Sep 7, 2011 at 2:00 AM, Per Bothner <p...@bothner.com> wrote: > > Kawa's gnu.math.IntNum already does this. It has only two fields: > > Yeah, I think I remember you mentioning this in one of the > arbitrary-precision math threads on JVM-L. I assume you could use an > intrinsic optimization for overflow checks too, yes? > > - Charlie > _______________________________________________ > mlvm-dev mailing list > mlvm-dev@openjdk.java.net > http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev > -- -- Howard.
_______________________________________________ mlvm-dev mailing list mlvm-dev@openjdk.java.net http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev