public void toAsm(JarOutputStream jos) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); // ClassWriter cw = new ClassWriter(0); CheckClassAdapter cca = new CheckClassAdapter(cw); cca.visit(version, access, name, sig, superName, interfaces); Iterator it = fieldVisitors.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); ByteCodeFieldVisitor fv = (ByteCodeFieldVisitor) pairs.getValue(); fv.toAsm(cca); } it = methodVisitors.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); ByteCodeMethodVisitor mv = (ByteCodeMethodVisitor) pairs.getValue(); mv.toAsm(cca); } byte[] bytes = cw.toByteArray(); if (ProjectProperties.getBoolean("fortress.bytecode.verify", false)) { PrintWriter pw = new PrintWriter(System.out); CheckClassAdapter.verify(new ClassReader(bytes), true, pw); } System.out.println("About to write " + name); ByteCodeWriter.writeJarredClass(jos, name, bytes); }
protected Class findClass(String className) throws ClassNotFoundException { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); InstanceKlass klass = SystemDictionaryHelper.findInstanceKlass(className); ClassWriter cw = new ClassWriter(klass, bos); cw.write(); byte[] buf = bos.toByteArray(); return defineClass(className, buf, 0, buf.length); } catch (Exception e) { throw (ClassNotFoundException) new ClassNotFoundException().initCause(e); } }