- Bootstrap class loader:它是虚拟机的内置类加载器,通常表示为null ,并且没有父null
- Platform class loader:平台类加载器可以看到所有平台类 ,平台类包括由平台类加载器或其祖先定义的Java SE平台API,其实现类和JDK特定的运行时类
- System class loader:它也被称为应用程序类加载器 ,与平台类加载器不同。 系统类加载器通常用于定义应用程序类路径,模块路径和JDK特定工具上的类
- 类加载器的继承关系:System的父加载器为Platform,而Platform的父加载器为Bootstrap
```java
public class ClassLoaderDemo {
public static void main(String[] args) {
//static ClassLoader getSystemClassLoader():返回用于委派的系统类加载器
ClassLoader c = ClassLoader.getSystemClassLoader();
System.out.println(c); //AppClassLoader
```java
public class ReflectDemo02 {
public static void main(String[] args) throws Exception {
//获取Class对象
Class<?> c = Class.forName("com.itheima_02.Student");
//Student s = new Student();
Constructor<?> con = c.getConstructor();
Object obj = con.newInstance();
System.out.println(obj);
//s.name = "林青霞";
// Field nameField = c.getField("name"); //NoSuchFieldException: name
Field nameField = c.getDeclaredField("name");
nameField.setAccessible(true);
nameField.set(obj, "林青霞");
System.out.println(obj);
//s.age = 30;
Field ageField = c.getDeclaredField("age");
ageField.setAccessible(true);
ageField.set(obj,30);
System.out.println(obj);
```java
public class ReflectDemo01 {
public static void main(String[] args) throws Exception {
//获取Class对象
Class<?> c = Class.forName("com.itheima_02.Student");
```java
public class ReflectDemo02 {
public static void main(String[] args) throws Exception {
//获取Class对象
Class<?> c = Class.forName("com.itheima_02.Student");
//Student s = new Student();
Constructor<?> con = c.getConstructor();
Object obj = con.newInstance();
```java
public class ReflectTest01 {
public static void main(String[] args) throws Exception {
//创建集合
ArrayList<Integer> array = new ArrayList<Integer>();