Understanding the Java ClassLoader
来源:互联网 发布:io域名是哪裡 编辑:程序博客网 时间:2024/05/07 21:45
Tutorial tipsold I take this tutorial?
The Java ClassLoader is a crucial, but often overlooked, component of the Java run-time system. It is the class responsible for finding and loading class files at run time. Creating your own ClassLoader lets you customize the JVM in useful and interesting ways, allowing you to completely redefine how class files are brought into the system.
This tutorial provides an overview of the Java ClassLoader and takes you through the construction of an example ClassLoader that automatically compiles your code before loading it. You'll learn exactly what a ClassLoader does and what you need to do to create your own.
A basic understanding of Java programming, including the ability to create, compile, and execute simple command-line Java programs, as well as an understanding of the class file paradigm is sufficient background to take this tutorial.
Upon completion of this tutorial, you will know how to:
- Expand the functionality of the JVM
- Create a custom ClassLoader
- Learn how to integrate a custom ClassLoader into your Java application
- Modify your ClassLoader to accommodate the Java 2 release
Introductionis a ClassLoader?
Among commercially popular programming languages, the Java language distinguishes itself by running on a Java virtual machine (JVM). This means that compiled programs are expressed in a special, platform-independent format, rather than in the format of the machine they are running on. This format differs from traditional executable program formats in a number of important ways.
In particular, a Java program, unlike one written in C or C++, isn't a single executable file, but instead is composed of many individual class files, each of which corresponds to a single Java class.
Additionally, these class files are not loaded into memory all at once, but rather are loaded on demand, as needed by the program. The ClassLoader is the part of the JVM that loads classes into memory.
The Java ClassLoader, furthermore, is written in the Java language itself. This means that it's easy to create your own ClassLoader without having to understand the finer details of the JVM.wre a Class
If the JVM has a ClassLoader, then why would you want to write another one? Good question. The default ClassLoader only knows how to load class files from the local filesystem. This is fine for regular situations, when you have your Java program fully compiled and waiting on your computer.
But one of the most innovative things about the Java language is that it makes it easy for the JVM to get classes from places other than the local hard drive or network. For example, browsers use a custom ClassLoader to load executable content from a Web site.
There are many other ways to get class files. Besides simply loading files from the local disk or from a network, you can use a custom ClassLoader to:
- Automatically verify a digital signature before executing untrusted code
- Transparently decrypt code with a user-supplied password
- Create dynamically built classes customized to the user's specific needs
Anything you can think of to write that can generate Java bytecode can be integrated into your application.
- Understanding the Java ClassLoader
- Understanding the Java ClassLoader part.1 (认识JAVA中的ClassLoader )
- Understanding the Java Classloading Mechanism
- Java 7: Understanding the Phaser
- Understanding the basis of Java I18n
- the personal understanding about JAVA Heap space and GC
- 《深入理解Java虚拟机》--Understanding the Jvm(上)
- 《深入理解Java虚拟机》--Understanding the Jvm(下)
- Understanding the Manifest
- Understanding the Manifest
- Understanding the Linux Kernel
- Understanding The Laser Engraver
- Understanding the SCN
- Understanding the Git Workflow
- understanding the linux kernel
- The Understanding of KMP
- Understanding the PS_TOKEN Cookie
- Understanding the digital signature
- IPv6的链路本地(link-local)地址和站点本地(site-local)地址
- 黑马程序员_面向对象(1)
- python正则表达式
- yii快速学习教程(五)------用户授权
- this.filterConfig = filterConfig;
- Understanding the Java ClassLoader
- 二叉树的常见遍历
- insmod 加载模块过程、modprobe 与 insmod的区别 、lsmod命令
- C++内存和进程,线程学习补充(内存泄漏,信号量)
- 玩儿转C语言:运算符的优先级和结合性
- CentOS 6 使用 X-Win32 安装Oracle 11gR2
- MIUI Note 研究笔记之 TextUtils
- VS2005中const char *转换为LPCWSTR的方法Unicode
- 项目管理之项目群管理