Skip to content

Commit 594e5a5

Browse files
author
root
committed
Revert "跑通测试 (#38)"
This reverts commit 0d970dc.
1 parent 0d970dc commit 594e5a5

1 file changed

Lines changed: 1 addition & 41 deletions

File tree

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +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-
84
/**
95
* @author gongxuanzhangmelt@gmail.com
106
**/
117
public class MyClassLoader extends ClassLoader {
128

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

0 commit comments

Comments
 (0)