JavaTXCompilerInJavaTXNoMaven/javatx-src/main/java/de/dhbwstuttgart/environment/IByteArrayClassLoader.java
2024-05-02 23:04:07 +02:00

24 lines
686 B
Java

package de.dhbwstuttgart.environment;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public interface IByteArrayClassLoader {
Class loadClass(String path) throws ClassNotFoundException;
default Class loadClass(byte[] code) {
return this._defineClass(null, code, 0, code.length);
}
default Class loadClass(Path path) throws IOException {
var code = Files.readAllBytes(path);
return this._defineClass(null, code, 0, code.length);
}
public Class<?> findClass(String name) throws ClassNotFoundException;
Class _defineClass(String name, byte[] code, int i, int length) throws ClassFormatError;
}