!747 m { static S[] args; p { main.args = args; makeAndroid("This is a JavaX VM talking to you.", stringfunc { answer(s) }); } static synchronized S answer(S s) { new Matches m; if (match3("kill!", s)) { killMyself(); return "ok"; } if (match3("What is your process ID?", s) || match3("what is your pid?", s)) return getPID(); if (match3("what is your program id?", s)) return getProgramID(); if (match3("what are your program arguments?", s)) return structure(args); if (match3("get fields of main class", s)) return structure(listFields(main.class)); if (match3("get field * of main class", s, m)) return structure(get(main.class, m.m[0])); if (match3("invoke function * of main class", s, m)) return structure(call(main.class, m.m[0])); if (match3("set field * of main class to *", s, m)) { set(main.class, m.m[0], unstructure(m.m[1])); return "ok"; } if (match3("how much memory are you consuming", s)) return "Java heap size: " + (Runtime.getRuntime().totalMemory()+1024*1024-1)/1024/1024 + " MB"; if (match3("how much memory is used after GC?", s)) { System.gc(); return "Java heap used: " + (Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()+1024*1024-1)/1024/1024 + " MB"; } if (match3("how much memory is used?", s)) return "Java heap used: " + (Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()+1024*1024-1)/1024/1024 + " MB"; return null; } }