/** * This method is called during the parsing process to register Native function definitions * implemented as static methods in a Java class. This method handles the registration process so * that the right function is called with the right arguments. * * @param pf a PrimitiveFunction object whose implementing class is not null */ public static void registerStaticPrimitive(PrimitiveFunction pf) { Class cls = pf.getKlass(); /* sanity check */ if (cls == null) return; /* create static call */ String clname = TypeHelper.getExternalName(cls).replace('.', '/'); String fname = BytecodeGenerator.encodeName2Java(pf.getName()); Class[] args = BytecodeGenerator.encodeType2Java(pf.getType()); StringBuffer sig = new StringBuffer("("); for (int i = 0; i < (args.length - 1); i++) sig.append(TypeHelper.getInternalName(args[i])); sig.append(')').append(TypeHelper.getInternalName(args[args.length - 1])); primitives.put(pf, new StaticMethodPrimitiveCode(clname, fname, sig.toString())); }
public ClassInfoCollector(String className) throws IOException { ClassReader reader = null; try { String file = BytecodeGenerator.magic(className + ".class"); if (file.charAt(0) == '/') { file = file.substring(1); } reader = new ClassReader(new FileInputStream(new File(file))); // reader = new ClassReader(className); } catch (IOException e) { throw e; } reader.accept(this, ClassReader.SKIP_CODE); }