Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/main/java/club/shengsheng/MyClassLoader.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
package club.shengsheng;


import java.io.*;

/**
* @author gongxuanzhangmelt@gmail.com
**/
public class MyClassLoader extends ClassLoader {

@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
if (name.contains("tech.insight.ShengSheng")) {
this.findClass(name);
}
return super.loadClass(name);
}

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
File file = new File("加密.class");
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))){
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int classByte;
while ((classByte = inputStream.read()) != -1) {
byteArrayOutputStream.write((classByte-1));
}
return defineClass(name, byteArrayOutputStream.toByteArray(), 0, byteArrayOutputStream.size());

} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Loading