public static void maybeDumpClass(String fullName, byte[] bytes) { if (isDumpGeneratedClasses()) { dumpClass(fullName, bytes); } }
public static void maybeDumpClassIntermediate(String fullName, byte[] bytes) { if (isDumpGeneratedClassesIntermediate()) { dumpClass(fullName, bytes, true); } }
public static void maybeDumpClassIntermediate(String fullName, byte[] bytes) { if (isDumpGeneratedClassesIntermediate()) { dumpClass(fullName, bytes, true); } }
public static void maybeDumpClass(String fullName, byte[] bytes) { if (isDumpGeneratedClasses()) { dumpClass(fullName, bytes); } }
private static void dumpClass(String fullName, byte[] bytes, boolean intermediate) { // wrap this in a try catch in case the file i/o code generates a runtime exception // this may happen e.g. because of a security restriction try { int dotIdx = fullName.lastIndexOf('.'); String name = (dotIdx < 0 ? fullName : fullName.substring(dotIdx + 1)); String prefix = (dotIdx > 0 ? File.separator + fullName.substring(0, dotIdx) : ""); String dir = getDumpGeneratedClassesDir() + prefix.replace('.', File.separatorChar); if (!ensureDumpDirectory(dir)) { Helper.err("org.jboss.byteman.agent.Transformer : Cannot dump transformed bytes to directory " + dir + File.separator + prefix); return; } String newname; if (intermediate) { int counter = 0; // add _<n> prefix until we come up with a new name newname = dir + File.separator + name + "_" + counter + ".class"; File file = new File(newname); while (file.exists()) { counter++; newname = dir + File.separator + name + "_" + counter + ".class"; file = new File(newname); } } else { newname = dir + File.separator + name + ".class"; } Helper.out("org.jboss.byteman.agent.Transformer : Saving transformed bytes to " + newname); try {
private static void dumpClass(String fullName, byte[] bytes, boolean intermediate) { // wrap this in a try catch in case the file i/o code generates a runtime exception // this may happen e.g. because of a security restriction try { int dotIdx = fullName.lastIndexOf('.'); String name = (dotIdx < 0 ? fullName : fullName.substring(dotIdx + 1)); String prefix = (dotIdx > 0 ? File.separator + fullName.substring(0, dotIdx) : ""); String dir = getDumpGeneratedClassesDir() + prefix.replace('.', File.separatorChar); if (!ensureDumpDirectory(dir)) { Helper.err("org.jboss.byteman.agent.Transformer : Cannot dump transformed bytes to directory " + dir + File.separator + prefix); return; } String newname; if (intermediate) { int counter = 0; // add _<n> prefix until we come up with a new name newname = dir + File.separator + name + "_" + counter + ".class"; File file = new File(newname); while (file.exists()) { counter++; newname = dir + File.separator + name + "_" + counter + ".class"; file = new File(newname); } } else { newname = dir + File.separator + name + ".class"; } Helper.out("org.jboss.byteman.agent.Transformer : Saving transformed bytes to " + newname); try {