1 4 package com.tc.runtime; 5 6 import com.tc.util.Assert; 7 import com.tc.util.runtime.Vm; 8 9 import java.lang.reflect.Constructor ; 10 11 public class TCRuntime { 12 13 private static JVMMemoryManager memoryManager; 14 15 static { 16 init(); 17 } 18 19 public static final JVMMemoryManager getJVMMemoryManager() { 20 Assert.assertNotNull(memoryManager); 21 return memoryManager; 22 } 23 24 private static void init() { 25 if (Vm.isJDK15Compliant()) { 26 memoryManager = getMemoryManagerJdk15(); 27 } else { 28 memoryManager = new TCMemoryManagerJdk14(); 29 } 30 } 31 32 36 private static JVMMemoryManager getMemoryManagerJdk15() { 37 try { 38 Class c = Class.forName("com.tc.runtime.TCMemoryManagerJdk15"); 39 Constructor constructor = c.getConstructor(new Class [0]); 40 return (JVMMemoryManager) constructor.newInstance(new Object [0]); 41 } catch (Exception e) { 42 throw new AssertionError (e); 43 } 44 } 45 46 } 47 | Popular Tags |