We consider the problem of converting C pointers to the less flexible concept
of references. Our main application is converting scientific applications
from C to Java. We provide a general method to model essentially all features
of pointers using references. The model is easily implemented in Java. We
give optimizations that map key facilities like arrays and structures onto the
obvious Java equivalents, arrays and objects. These improvements make the
conversion “optimal” for all typed pointers. For untyped
pointers, we can still fall back on the general model, hence providing general
automatic conversion from C to Java code, whose efficiency improves with the
quality of the C code.