1. A computer-readable non-transitory storage medium configured with data and with instructions that when executed by at least one processor causes the processor(s) to perform a process for compile-time bounds checking of user-defined types, the process comprising the following steps performed during compilation of a program from a source code through an intermediate language code to an executable code: identifying in the source code a user-defined class for safely accessing memory, namely, a user-defined class having as an annotated member a memory-accessing code which is annotated with a user-defined-bounds check annotation and also having as another annotated member a bound-providing member which is annotated to indicate that it provides bound information for generating a bounds check on the memory-accessing code; inserting into the intermediate language code a bounds-check representation of the user-defined-bounds check annotation; and applying an optimization which reduces duplicative bounds checking that would otherwise occur in the executable code.