-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloClassLoader.java
More file actions
32 lines (27 loc) · 984 Bytes
/
Copy pathHelloClassLoader.java
File metadata and controls
32 lines (27 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class HelloClassLoader extends ClassLoader{
public static void main(String[] args) throws Exception {
Object o = new HelloClassLoader().findClass("com.Hello").newInstance();
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte[] bytes = new byte[0];
try {
File file = new File("E:\\work_time\\HelloClassLoader\\src\\com\\Hello.xlass");
FileInputStream is = new FileInputStream(file);
int length = is.available();
bytes = new byte[length];
for (int i = 0;i<length;i++){
bytes[i]= (byte) (255 - bytes[i]);
}
is.read(bytes);
} catch (IOException e) {
e.printStackTrace();
}
return defineClass(name,bytes,0,bytes.length);
}
}