Skip to content

Commit 8ce163f

Browse files
Revert "提交作业 (#34)"
This reverts commit 5f4eaed.
1 parent 5f4eaed commit 8ce163f

File tree

1 file changed

+0
-45
lines changed

1 file changed

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

3-
import java.io.File;
4-
import java.io.IOException;
5-
import java.nio.file.Files;
6-
import java.nio.file.Path;
73

84
/**
95
106
**/
117
public class MyClassLoader extends ClassLoader {
128

13-
public MyClassLoader() {
14-
super();
15-
}
16-
17-
@Override
18-
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
19-
synchronized (getClassLoadingLock(name)) {
20-
// First, check if the class has already been loaded
21-
Class<?> c = findLoadedClass(name);
22-
if (c == null) {
23-
if (name.startsWith("tech.insight")) {
24-
c = findClass(name);
25-
} else {
26-
c = getParent().loadClass(name);
27-
}
28-
}
29-
if (resolve) {
30-
resolveClass(c);
31-
}
32-
return c;
33-
}
34-
}
35-
36-
@Override
37-
protected Class<?> findClass(String name) throws ClassNotFoundException {
38-
String path = name.replace(".", "/").concat(".class");
39-
String fileName = "加密" + ".class";
40-
File file = new File("./", fileName);
41-
Path filePath = file.toPath();
42-
System.out.println(filePath);
43-
try {
44-
byte[] bytes = Files.readAllBytes(filePath);
45-
for (int i = 0; i < bytes.length; i++) {
46-
bytes[i] = (byte) (bytes[i] - 1);
47-
}
48-
return defineClass(name, bytes, 0, bytes.length);
49-
} catch (IOException e) {
50-
throw new RuntimeException(e);
51-
}
52-
}
53-
549
}

0 commit comments

Comments
 (0)