A
Adam Warner
Hi all,
Since the JVM omits a critical 64-bit abstraction (long array indices)
I've created some custom int indexed and long indexed sequence classes.
The long indexed classes have to emulate contiguous blocks of memory (with
all the overhead that this entails). Note that Java's so-called "New IO"
is also an int constrained travesty.
To top it all off there appears to be no clean way to group the classes.
The int indexed classes return int indices. The long indexed classes
return long indices. Consider:
abstract class Sequence {
abstract long length();
}
class Sequence32 extends Sequence {
int length() {return Integer.MAX_VALUE;}
}
class Sequence64 extends Sequence {
long length() {return Long.MAX_VALUE;}
}
This code will not compile. To my mind the int return value should be
treated as a subtype of long and be promoted to long when necessary.
Can anyone come up with a workaround whereby I can operate upon int
indexed classes that return int indices (e.g. class Sequence32) while also
being able to operate upon them as if they're long indexed classes (e.g.
class Sequence)?
Regards,
Adam
Since the JVM omits a critical 64-bit abstraction (long array indices)
I've created some custom int indexed and long indexed sequence classes.
The long indexed classes have to emulate contiguous blocks of memory (with
all the overhead that this entails). Note that Java's so-called "New IO"
is also an int constrained travesty.
To top it all off there appears to be no clean way to group the classes.
The int indexed classes return int indices. The long indexed classes
return long indices. Consider:
abstract class Sequence {
abstract long length();
}
class Sequence32 extends Sequence {
int length() {return Integer.MAX_VALUE;}
}
class Sequence64 extends Sequence {
long length() {return Long.MAX_VALUE;}
}
This code will not compile. To my mind the int return value should be
treated as a subtype of long and be promoted to long when necessary.
Can anyone come up with a workaround whereby I can operate upon int
indexed classes that return int indices (e.g. class Sequence32) while also
being able to operate upon them as if they're long indexed classes (e.g.
class Sequence)?
Regards,
Adam