8286015: JFR: Remove jfr.save.generated.asm

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin 2022-05-12 15:18:18 +00:00
parent 1904e9d280
commit 82aa045584
3 changed files with 1 additions and 32 deletions

View File

@ -325,9 +325,7 @@ public final class EventInstrumentation {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
classNode.accept(cw);
cw.visitEnd();
byte[] result = cw.toByteArray();
Utils.writeGeneratedASM(classNode.name, result);
return result;
return cw.toByteArray();
}
public byte[] buildUninstrumented() {

View File

@ -79,8 +79,6 @@ public final class Utils {
public static final String ACCESS_FLIGHT_RECORDER = "accessFlightRecorder";
private static final String LEGACY_EVENT_NAME_PREFIX = "com.oracle.jdk.";
private static Boolean SAVE_GENERATED;
private static final Duration MICRO_SECOND = Duration.ofNanos(1_000);
private static final Duration SECOND = Duration.ofSeconds(1);
private static final Duration MINUTE = Duration.ofMinutes(1);
@ -514,31 +512,6 @@ public final class Utils {
}
}
public static void writeGeneratedASM(String className, byte[] bytes) {
if (SAVE_GENERATED == null) {
// We can't calculate value statically because it will force
// initialization of SecuritySupport, which cause
// UnsatisfiedLinkedError on JDK 8 or non-Oracle JDKs
SAVE_GENERATED = SecuritySupport.getBooleanProperty("jfr.save.generated.asm");
}
if (SAVE_GENERATED) {
className = className.substring(className.lastIndexOf("/") + 1, className.length());
try {
try (FileOutputStream fos = new FileOutputStream(className + ".class")) {
fos.write(bytes);
}
try (FileWriter fw = new FileWriter(className + ".asm"); PrintWriter pw = new PrintWriter(fw)) {
ClassReader cr = new ClassReader(bytes);
CheckClassAdapter.verify(cr, true, pw);
}
Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.INFO, "Instrumented code saved to " + className + ".class and .asm");
} catch (IOException e) {
Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.INFO, "Could not save instrumented code, for " + className + ".class and .asm");
}
}
}
public static void ensureInitialized(Class<? extends jdk.internal.event.Event> eventClass) {
SecuritySupport.ensureClassIsInitialized(eventClass);
}

View File

@ -37,7 +37,6 @@ import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Opcodes;
import jdk.internal.org.objectweb.asm.tree.ClassNode;
import jdk.jfr.internal.SecuritySupport;
import jdk.jfr.internal.Utils;
/**
* This class will perform byte code instrumentation given an "instrumentor" class.
@ -72,7 +71,6 @@ final class JIClassInstrumentation {
this.targetClassReader = new ClassReader(old_target_bytes);
this.instrClassReader = new ClassReader(getOriginalClassBytes(instrumentor));
this.newBytes = makeBytecode();
Utils.writeGeneratedASM(target.getName(), newBytes);
}
private static byte[] getOriginalClassBytes(Class<?> clazz) throws IOException {