Skip to content

Commit 56acff5

Browse files
author
root
committed
Revert "feat(classloader): 实现自定义类加载器功能 (#39)"
This reverts commit 49c39b0.
1 parent 49c39b0 commit 56acff5

1 file changed

Lines changed: 0 additions & 43 deletions

File tree

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,9 @@
11
package club.shengsheng;
22

33

4-
import java.io.File;
5-
import java.io.IOException;
6-
import java.nio.file.Files;
7-
import java.util.ArrayList;
8-
import java.util.Arrays;
9-
import java.util.List;
10-
114
/**
125
* @author gongxuanzhangmelt@gmail.com
136
**/
147
public class MyClassLoader extends ClassLoader {
158

16-
17-
@Override
18-
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
19-
synchronized (getClassLoadingLock(name)) {
20-
Class<?> c = findLoadedClass(name);
21-
if (c == null) {
22-
if (name.startsWith("tech.insight.ShengSheng")){
23-
c = this.findClass(name);
24-
}
25-
else {
26-
c = getParent().loadClass(name);
27-
}
28-
}
29-
return c;
30-
}
31-
}
32-
33-
@Override
34-
protected Class<?> findClass(String name) throws ClassNotFoundException {
35-
36-
37-
File classFile = new File("./加密.class");
38-
39-
try {
40-
byte[] bytes = Files.readAllBytes(classFile.toPath());
41-
byte[] newBytes = new byte[bytes.length];
42-
for (int i = 0; i < bytes.length; i++) {
43-
byte aByte = bytes[i];
44-
aByte = (byte) (aByte - 1);
45-
newBytes[i] = aByte;
46-
}
47-
return defineClass(name, newBytes, 0, bytes.length);
48-
}catch (Exception e) {
49-
throw new ClassNotFoundException(name);
50-
}
51-
}
529
}

0 commit comments

Comments
 (0)