클래스가 JVM에로드되면 동일한 클래스 로더에 대해 동일한 클래스가 다시로드되지 않습니다. 새 인스턴스가 메모리의 클래스 객체에서 만들어집니다 (동일한 클래스 로더의 경우). 이미 클래스를로드하는 경우 (https://www.ibm.com/developerworks/java/tutorials/j-classloader/j-classloader.html에서 복사) 높은 수준의
- 전화 findLoadedClass에서
단계를 확인합니다.
- 클래스를로드하지 않은 경우 findClass (클래스 로더 구현에서 재정의)를 사용하여 바이트를 가져옵니다.
- 원시 바이트가 발견되면 defineClass를 호출하여 클래스 객체로 변환합니다. (AppClassLoader의 예)
- 클래스가 해석되면 resolveClass를 호출하여 Class 객체를 확인합니다.
여전히 클래스가없는 경우 ClassNotFoundException을 발생시킵니다.
protected synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
// First, check if the class has already been loaded
Class c = findLoadedClass(name);
if (c == null) {
try {
if (parent != null) {
c = parent.loadClass(name, false);
} else {
c = findBootstrapClass0(name);
}
} catch (ClassNotFoundException e) {
// If still not found, then invoke findClass in order
// to find the class.
c = findClass(name);
}
}
if (resolve) {
resolveClass(c);
}
return c;
}
예와 동일한 해시 코드를 인쇄 할 다음의 모든과에로드되는 자세한 내용 http://www.onjava.com/pub/a/onjava/2005/01/26/classloading.html?page=1
<
불투명 한 부분은 * 프로그램이 시작될 때 클래스 로더가 클래스 파일을로드하고 Class 클래스의 객체로 메모리에 저장하는 것을 이해합니다. * –
이 잘못 되었습니까? 그렇다면 실행주기를 배울 수있는 방향을 가리킬 수 있습니다. @YCF_L – rematnarab