forked from MirrorHub/authlib-injector
Add log for dumping class
This commit is contained in:
parent
d793848c79
commit
6fd5616ba6
1 changed files with 4 additions and 1 deletions
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||||
import java.lang.instrument.ClassFileTransformer;
|
import java.lang.instrument.ClassFileTransformer;
|
||||||
import java.lang.instrument.IllegalClassFormatException;
|
import java.lang.instrument.IllegalClassFormatException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.security.ProtectionDomain;
|
import java.security.ProtectionDomain;
|
||||||
|
@ -99,8 +100,10 @@ public class ClassTransformer implements ClassFileTransformer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveClassFile(String className, byte[] classBuffer) {
|
private void saveClassFile(String className, byte[] classBuffer) {
|
||||||
|
Path dumpFile = Paths.get(className + "_dump.class");
|
||||||
try {
|
try {
|
||||||
Files.write(Paths.get(className + "_dump.class"), classBuffer, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
Files.write(dumpFile, classBuffer, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||||
|
Logging.TRANSFORM.info("Transformed class is dumped to [" + dumpFile + "]");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logging.TRANSFORM.log(Level.WARNING, "Failed to dump class [" + className + "]", e);
|
Logging.TRANSFORM.log(Level.WARNING, "Failed to dump class [" + className + "]", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue