Re: How to tie
Abble wrote:
On Dec 31, 10:52 am, Eric Sosman <esos...@ieee-dot-org.invalid> wrote:
Abble wrote:
If the goal is to interpose your own code on array accesses
in Java, I think you're out of luck: Array accesses use built-in
opcodes of the Java Virtual Machine, and there's no provision for
you to insert your own code into the JVM. (Hard to see how the
security and integrity models could permit such a thing, anyhow.)
Perhaps it's time to take a step back: What kind of code do
you want to interpose, and for what purpose? Perhaps the cat
can be skinned some other way.
--
Eric Sosman
esos...@ieee-dot-org.invalid
Thanks Eric,
What I'd like to do is tie a Java array to a a sparse array
database of sorts. These arrays might be really sparse, or maybe
dimensioned far in excess of any RAM or even VM. It sure would be
nice to present the appearance of an array[million,million,million].
I can do this in FORTRAN (by trapping segment violations), I can do
this in C (with macros), I can do it in C++, I think, by overloading
operators. I can do it in Delphi Pascal, same as in FORTRAN.
Sure would be nice to do it in Java too.
I understand this is likely to a bit of a stretch in any language
that is security-conscious.
I think your best approach is going to be to write an interface
representing your sparse arrays. For example, if they are two
dimensional doubles:
public interface SparseArray{
double get(long i, long j);
void set(double val, long i, long j);
}
and then write various implementations of the interface. The interface
may need additional methods for constructing views, such as rows,
columns, subblocks etc.
Most of the code would work in terms of the interface.
Unfortunately, Java lacks the operator overloading that would let you
represent get and set using array notation. That lack gets in the way of
easy translation from e.g. subscripted matrix notation to code.
Patricia