1. A computer-readable 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, namely, types which are not built-in, 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 comprising one or more of: a field-contains bound annotation indicating that a field in the user-defined class contains a bound for the memory-accessing method and a bound-getter method annotation indicating that the bound-getting method in the user-defined class returns a bound for the memory-accessing method, 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, wherein the user-defined class is defined free of any multi-element array type as a constituent type; 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.