001    package javax.realtime;
002    
003    // Ideally, this class should not exist.  It's the class of
004    // the MemoryAreas that escape the current scope of analysis
005    // (returned from native methods, etc.)  This class becomes
006    // very useful as a tracer when you're trying to track down 
007    // random bugs with respect to memory area restrictions and 
008    // native methods.
009    
010    public class NullMemoryArea extends MemoryArea {
011        /** Count how many instances of the NullMemoryArea are asked for.
012         */
013        public static long count = 0;
014    
015        /** The one and only NullMemoryArea. 
016         */
017        private static NullMemoryArea nullMemory;
018    
019        /** Create the one and only NullMemoryArea.
020         */
021        private NullMemoryArea() {
022            super(0);
023            nullMem = true;
024        }
025    
026        /** Initialize the native component of this NullMemoryArea. 
027         */
028    
029        protected native void initNative(long sizeInBytes);
030    
031        /** Return an instance of the one and only NullMemoryArea. 
032         */
033    
034        public static NullMemoryArea instance() {
035            if (nullMemory == null) {
036                nullMemory = new NullMemoryArea();
037            }
038            count++;
039            return nullMemory;
040        }
041    
042        /** Check access to this NullMemoryArea. 
043         */
044    
045        public void checkAccess(Object obj) {
046    //      System.out.println("Checking access from a NullMemory!");
047        }
048    
049        /** Print out a helpful string representing this NullMemoryArea. */
050    
051        public String toString() {
052            return "NullMemory: " + super.toString();
053        }
054    }