The basics of Java class loaders

The class loader concept, one of the cornerstones of the Java virtual machine, describes the behavior of converting a named class into the bits responsible for implementing that class. Because class loaders exist, the Java run time does not need to know anything about files and file systems when running Java programs. 

What class loaders do

Classes are introduced into the Java environment when they are referenced by name in a class that is already running. There is a bit of magic that goes on to get the first class running (which is why you have to declare the main() method as static, taking a string array as an argument), but once that class is running, future attempts at loading classes are done by the class loader.

At its simplest, a class loader creates a flat name space of class bodies that are referenced by a string name. The method definition is:

Class r = loadClass(String className, boolean resolveIt);

The variable className contains a string that is understood by the class loader and is used to uniquely identify a class implementation. The variable resolveIt is a flag to tell the class loader that classes referenced by this class name should be resolved (that is, any referenced class should be loaded as well).

All Java virtual machines include one class loader that is embedded in the virtual machine. This embedded loader is called the primordial class loader. It is somewhat special because the virtual machine assumes that it has access to a repository of trusted classes which can be run by the VM without verification.

The primordial class loader implements the default implementation of loadClass(). Thus, this code understands that the class namejava.lang.Object is stored in a file with the prefixjava/lang/Object.class somewhere in the class path. This code also implements both class path searching and looking into zip files for classes. The really cool thing about the way this is designed is that Java can change its class storage model simply by changing the set of functions that implements the class loader.

Digging around in the guts of the Java virtual machine, you will discover that the primordial class loader is implemented primarily in the functions FindClassFromClass and ResolveClass.

So when are classes loaded? There are exactly two cases: when the new bytecode is executed (for example, FooClass f = newFooClass();) and when the bytecodes make a static reference to a class (for example, System.out).


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
磁共振成像(MRI)是一种非侵入性的医学影像技术,通过使用强磁场和无害的无线电波,生成高分辨率的人体内部图像。MRI的基本原理包括磁共振现象和信号处理。 首先,MRI利用强磁场产生静态磁场。这个强磁场使得人体内的原子(通常是氢)的原子核在磁场中定向,使其自旋沿磁场方向预先排列。 其次,MRI利用无线电频率的脉冲来激发人体内的原子核,使其从平衡状态中倾斜。 然后,MRI探测激发后原子核的归位,这个过程称为回波信号。原子核的归位过程会产生微弱的无线电信号。 接下来,MRI系统采集这些回波信号并进行信号处理。信号处理包括一个复杂的计算过程,其基本目标是确定回波信号的来源和特征。通过这种方式,系统可以构建数百个不同方向上的切片图像。 最后,计算机将切片图像组合在一起,形成三维结构,可以帮助医生观察和分析人体内部组织和器官的详细结构。 MRI是一种非常有用的影像技术,因为它能够提供清晰的高对比度图像,并且不涉及使用有害的X射线。它在医学诊断中广泛应用,特别是用于观察脑部、骨骼、关节、脊椎和内脏器官等结构。同时,MRI还可以用来检测肿瘤、损伤、疾病和其他异常,并且具有较高的准确性和灵敏度。 总之,MRI是一种基于磁共振原理的医学影像技术,可生成高分辨率、非侵入性的人体内部图像,对于医学诊断和研究具有重要意义。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值