Understanding Class.forName (一)

Spring AI微服务集成实战:从ChatClient到多模态与AI Agent AI能力正从外部HTTP服务演进为可装配、可治理的微服务原生组件。理解Spring AI的核心抽象——如ChatClient对上下文管理、流式响应、错误语义化和可观测性的封装——是构建高可靠AI链路的前提。它将大模型调用升维为类似数据库连接池的基础设施层,支持动态模型路由、熔断重试与指标埋点。在电商、金融、工业等场景中,该能力可支撑实时物流分析、个性化欢迎语生成、身份证OCR校验等关键业务。本文聚焦Spring AI 2.0在真实微服务架构中的落地实践,涵盖Alibaba多模态集成、VisionChatCl 阅读详情

Understanding Class.forName

Loading Classes Dynamically from within Extensions

Abstract

Dynamic loading of Java classes at runtime provides tremendous flexibility in the development of enterprise systems. It provides for the basis of “application servers”, and allows even simpler, lighter-weight systems to accomplish some of the same ends. WithinJava, dynamic loading is typically achieved by calling the forName method on the class java.lang.Class; however, when Class.forName is naïvely called from within an Extension,strange errors can occur. This paper describes why those errors occur, and how Java2 provides two facilities: one a modification to the forName syntax, and the other, called the “Thread context ClassLoader”, to avoid them. This paper assumes you are passingly familiar with Java Reflection, and have at least a general idea of what Java ClassLoaders are and how they are used within Java code.

KEYWORDS: Java ClassLoaders Extensions Threads 2

?

Dynamic runtime loading. One of Java’s strongest features is its ability to dynamically load code given the name of the class to load, without having to know the actual classname until runtime. This allows Java developers to build flexible, dynamic systems that can grow and change without requiring complete recompilation. For example, the following code executes the main method of a class given on the command-line to the class DynamicLoader:

public class DynamicLoader

{

public static void main(String[] args)

throws Exception

{

Class toRun = Class.forName(args[0]);

String[] newArgs = scrubArgs(args);

Method mainMethod = findMain(toRun);

mainMethod.invoke(null, new Object[] { newArgs });

}

private static String[] scrubArgs(String[] args)

{

String[] toReturn = new String[args.length-1];

for (int i=1; i

{

toReturn[i-1] = args[i].toLowerCase();

}

return toReturn;

}

private static Method findMain(Class clazz)

throws Exception

{

Method[] methods = clazz.getMethods();

for (int i=0; i

{

if (methods[i].getName().equals("main"))

return methods[i];

}

return null;

}

}

As you can see, DynamicLoader takes the arguments (except the first one) given to it, and passes them directly on to the main method of the loaded class, after first making all the command-line arguments lower case. This means we can run any compiled Java class through DynamicLoader without having to change DynamicLoader’s code in the slightest. In fact, we can run any executable Java code, from Swing-based client apps to consolebased Web servers—DynamicLoader really doesn’t care. For example, when we run the following class:

public class Echo

{

public static void main (String args[])

{

for (int i=0; i

{

System.out.println("Echo arg"+i+" = "+args[i]);

}

}

}

through DynamicLoader, like this:

> java DynamicLoader Echo ONE TWO THREE

we get the following output:

Echo arg0 = one

Echo arg1 = two

Echo arg2 = three

As you can see, DynamicLoader created an instance of the Echo class, and called its main method, all without having any direct reference to Echo itself. In O-O parlance, this means DynamicLoader is completely decoupled from Echo; there are no explicit dependencies between these two classes. This use of dynamic runtime loading is the heart of Java Application Servers like the Java2 Enterprise Edition reference implementation, Enterprise JavaBeans, and the Servlet Specification. In each one of these architectures, at the time the application server is compiled, it knows nothing about the code that will be attached to it. Instead, it simply asks the user for a classname to load, loads the class, creates an instance of the class, and starts making method calls on that instance. (It does so either through Reflection, or by requiring that clients implement a particular interface or class, like GenericServlet in the Servlet spec, or EJBObject in the EJB spec.) ?Use of dynamic runtime loading isn’t restricted solely to server-side architectures, however. Web browsers must use it in order to be able to load applets specified by name by a remote web page, as well. RMI uses it to dynamically load stubs and/or skeletons for remote objects, and JNDI and JDBC will use it to load, at runtime, the exact driver necessary (given by the user’s appropriate “.properties” file) to perform the work asked. In each case, a ClassLoader is asked to load a class by name that may not have existed within the JVM before this moment. ?Enterprise application architects are also starting to discover ways to put dynamic runtime loading to work for them, as well. For example, several papers and articles have already been published describing how to use XML to create GUI dialogs and/or windows [6], including the ability to instantiate custom classes that didn’t exist when the basic system was built. Class.forName. In most of these systems, the code to do the runtime loading comes through the method forName on the class java.lang.Class; its use is demonstrated in the previous DynamicLoader code. Class.forName attempts to load the class whose name is given in its only argument, and returns the Class instance representing that class. In the event that the Class could not be found, resolved, verified, or loaded, Class.forName throws one of several different Exceptions, all of which are listed in the javadoc page for java.lang.Class [1]. Assume for the moment that this DynamicLoader class we’ve created is a useful bit of functionality, and several other developers have expressed an interest in making use of it. In accordance with the new Java2 emphasis on Extensions, we package DynamicLoader up into a .jar file, and drop it into the Extensions directory of our Java execution environment1. (If you’re not familiar with Java Extensions, see [1] or [5] for details.) The problem comes, however, when we try to execute the Echo class found on the CLASSPATH from within DynamicLoader2:

> java DynamicLoader Echo ONE TWO THREE

Exception in thread "main" java.lang.ClassNotFoundException: Echo

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:191)

at java.lang.ClassLoader.loadClass(ClassLoader.java:280)

at java.lang.ClassLoader.loadClass(ClassLoader.java:237)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:124)

at DynamicLoader.main(DynamicLoader.java:8)

1 Either /jre/lib/ext or the /lib/ext directories, depending on whether the executing version of java is

running out of the /bin directory or /bin.

2 This assumes you’ve jar’ed DynamicLoader.class into a .jar and placed the .jar in the /jre/lib/ext

directory; if you haven’t, do that now.

We can verify that the class, Echo, does in fact exist, either by running Echo directly, or by running the javap utility to list its attributes:

> javap Echo

Compiled from Echo.java

public class Echo extends java.lang.Object {

public Echo();

public static void main(java.lang.String[]);

}

So what gives? Why is DynamicLoader failing to load Echo? What changed between DynamicLoader-on-the-CLASSPATH and DynamicLoader-as-an-Extension?

Problem Analysis

In order to understand precisely what’s going on here, you have to understand some of the basics of the Java ClassLoader model and what changed in Java2 from JDK 1.1. Java2 ClassLoader Delegation Model. As described in [2], the Java2 ClassLoader model is a “delegating parent” model, meaning that when a ClassLoader is asked to load a class, it first delegates the opportunity to load the requested class to its parent ClassLoader. Only if the parent (a) hasn’t already loaded the Class, and (b) can’t load the Class does the child ClassLoader get the opportunity to provide the Class requested, if it can. This means that ClassLoaders form a hierarchical tree, with the “bootstrap” ClassLoader (the only ClassLoader in the JVM with a “value” of null) as the root of the tree. (More on the bootstrap ClassLoader later.) Any ClassLoader constructed within user code3 must have a parent ClassLoader; if none is provided in the ClassLoader constructor call, the ClassLoader constructors assume this ClassLoader’s parent to be the “system” or ClassLoader. (More on the “system ClassLoader” later.) Implicitly associated with each loaded Class in a JVM is the ClassLoader that loaded it. It is this ClassLoader that is returned from the Class method getClassLoader. Each Class is associated with one-and-only-one ClassLoader, and this is not mutable—Class objects can’t change the ClassLoader reference to point to another ClassLoader. A ClassLoader’s loadClass method is called (either directly by the programmer or implicitly by the JVM) when a client wishes to load a class through that ClassLoader. Under the JDK 1.0 and 1.1 models, the ClassLoader directly overrode loadClass to undertake the necessary actions to load the code. Under JDK 1.2, however, this is no longer the case; instead, the loadClass method calls its ClassLoader parent/delegate’s loadClass to see if the parent recognizes the class. Only if the parent (and, by extensions, all of its parental ancestors, as well) fails to load the class does this ClassLoader get the chance to load the code. To do that, it calls the findClass method, which is the method customized ClassLoaders are now supposed to override.

3 That is, non-JVM code.

?

As an example of how this works, consider a JVM embedded inside of a Web browser. When a Web page comes in with an tag on it, the Web browser constructs an instance of its (vendor-specific) AppletClassLoader. This ClassLoader is responsible for obtaining the compiled bytecode from the Website that served the page in the first place; the Web browser simply does something similar to the following:

// inside the Web browser somewhere...

AppletClassLoader cl = new AppletClassLoader(appletCodebase);

Applet applet = (Applet)cl.loadClass(appletClassName).newInstance();

where appletClassName is given within the HTML tag. AppletClassLoader, in its loadClass method, first checks with its parent, which under most JVMs will be the primordial ClassLoader. Let’s track how this applet’s Class gets loaded. Because the system ClassLoader is the parent to the AppletClassLoader, the system ClassLoader is given the opportunity to find the Class. Because the Class code can’t be found along the CLASSPATH, in any of the Extensions directories, or in the core library classes (it’s an applet, remember the code resides up on the server), the system ClassLoader signals failure. This means it’s now AppletClassLoader’s turn, and it examines the tag for any information, like CODEBASE attributes, on the whereabouts of the Class file requested. If AppletClassLoader finds a compiled .jar or .class file, it downloads the code as a binary file and loads it into the JVM (via the defineClass method on ClassLoader) from there. The Web browser can now construct an instance of the Applet class, because now it has the requested Class file loaded into its JVM: It can now call the start, stop, and other methods on Applet. This parent-child relationship of Java2 now releases Java ClassLoader developers from having to remember to check the system ClassLoader to see if the class has already been loaded. More importantly, however, it permits a “chain-loading” of classes from a variety of sources. For example, in a hypothetical enterprise system, I might create a JDBCClassLoader, whose parent is a URLClassLoader pointing to an HTTP server inside my corporate firewall. That URLClassLoader in turn is a child of the primordial ClassLoader. This provides me a three-layered, code-loading facility, where rapidly-changing code, such as business rules (sales promotionals and the like) can be stored in the RDBMS, potentially on a user-by-user basis, if necessary. The less-mutable code is stored on my HTTP server, and the system and bootstrap ClassLoaders are responsible for the core Java classes, as usual. This approach allows the more stable code to “override” more mutable behavior; if you desire the opposite, simply reverse the placement of the JDBCClassLoader and the URLCLassLoader. In each case, because the nature of the ClassLoading mechanism is “parent-first”, whichever ClassLoader is highest up on the hierarchy has “classloading priority” over its children. Because each child delegates to its parent, we will load code in top-down order; in the fictitious aforementioned example, the system ClassLoader gets the first chance, followed by the URLClassLoader, followed by the JDBCClassLoader. Understanding how the system ClassLoader is architected, along with this understanding of the “parent-first” nature of delegating ClassLoaders, yields discovery of the problem.

?

Java2/JDK1.2 Default ClassLoader architecture. The Java2 system provides for loading code from one of three places by default: the core library, the Extensions directory (or directories, if you modify the java.ext.dirs property to include multiple subdirectories), and from the directories and/or .jar/.zip files found along the java.class.path property, which in turn comes from the CLASSPATH environment variable. Each of these three locations is in turn covered by its own ClassLoader instance: the core classes, by the bootstrap ClassLoader, the Extensions directory/directories by the extension ClassLoader, and the CLASSPATH by the system or application ClassLoader4. Before we delve too deeply into this, let’s run a quick test. Compiling and executing this code:

public class EchoClassLoader

{

public static void main (String args[])

{

ClassLoader current =

new EchoClassLoader().getClass().getClassLoader();

while (current != null)

{

System.out.println(current.getClass());

current = current.getParent();

}

}

}

produces this rather interesting result:

> java EchoClassLoader

class sun.misc.Launcher$AppClassLoader

class sun.misc.Launcher$ExtClassLoader

The result highlights something very interesting. I’ve been speaking of the system ClassLoader as a singular entity, but there are two parents to our class’ ClassLoader: one called Launcher$AppClassLoader, and one called Launcher$ExtClassLoader, both of which live in the sun.misc package. The bootstrap ClassLoader is implemented as part of the VM itself, and cannot be instantiated by Java code. It is this ClassLoader that brings the core Java classes into the VM, allowing the rest of the JVM to load itself. (Take a second to think about this—in order to construct a ClassLoader, which extends Object, the JVM must load the Object class. But in order to do this, it requires a ClassLoader with which to load it!) Normally, this means loading code from the “rt.jar” file in the jdk/jre/lib subdirectory, but under the Sun JVM, the boot.class.path property actually controls it5.

4 At one point, during the JDK 1.2 Beta3 release, it was also called the base ClassLoader.

5 Why this could be important is beyond the scope of this paper.

?

The extension ClassLoader, the first child of the boostrap ClassLoader, is implemented in pure Java code. As already mentioned, the extension ClassLoader’s primary responsibility is to load code from the JDK’s extension directories. This in turn provides users of Java the ability to simply “drop in” new code extensions (hence the name “Extension directory”), such as JNDI or JSDT, without requiring modification to the user’s CLASSPATH environment variable. The system, or application, ClassLoader is the ClassLoader returned from the static method ClassLoader.getSystemClassLoader. This is the ClassLoader responsible for loading code from the CLASSPATH, and by default will be the parent to any user-created or user-defined ClassLoader in the system. (As an aside, both of these classes are direct descendants of URLClassLoader. ExtClassLoader reads the java.ext.dirs property for a list of directories. It takes each directory in turn, iterates over each file in the directory, builds a URL out of it, and stores that URL in the URLClassLoader-parent portion of itself. ExtClassLoader also overrides the findLibrary method to search the directory given by the property os.arch under each extension directory for the library matching the requested name. This allows extension directories to also silently support native-libraries in the same “drop-in” manner as Extensions themselves. AppClassLoader reads the java.class.path property, and for each File.pathSeparator-separated entry, builds a URL out of it. Once these two classes are created, however, they behave in all respects like a standard URLClassLoader. These two classes, along with URLClassLoader, are described more fully in [5].)

So now we have some deeper insight into the architecture of the ClassLoader system in Java2. Let’s take a moment and see, step-by-step, why Class.forName, when called on a class found within the CLASSPATH, fails when called from within an Extension.

To summarize the “normal” ClassLoader tree:

Bootstrap ClassLoader

Type: none; implemented within the VM

Parent: none

Loads core runtime library code from sun.boot.class.path

Extension ClassLoader

Type: sun.misc.Launcher$ExtClassLoader

Parent: null (bootstrap ClassLoader)

Loads code found in extension directories (given by java.ext.dirs )

System (or Application) ClassLoader

Type: sun.misc.Launcher$AppClassLoader

Parent: Extension ClassLoader

Returned from ClassLoader.getSystemClassLoader

Loads code found on java.class.path (the CLASSPATH variable)

?

Calling Class.forName within an Extension. Go back to the original problem: this

code:

public class DynamicLoader

{

public static void main(String[] args)

throws Exception

{

Class toRun = Class.forName(args[0]);

String[] newArgs = scrubArgs(args);

Method mainMethod = findMain(toRun);

mainMethod.invoke(null, new Object[] { newArgs });

}

// . . .

}

when called from within an Extension, fails with:

> java DynamicLoader Echo ONE TWO THREE

Exception in thread "main" java.lang.ClassNotFoundException: Echo

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:191)

at java.lang.ClassLoader.loadClass(ClassLoader.java:280)

at java.lang.ClassLoader.loadClass(ClassLoader.java:237)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:124)

at DynamicLoader.main(DynamicLoader.java:8)

Walking through the Class.forName call highlights the problem. Class.forName obtains the caller’s ClassLoader, and uses that ClassLoader instance to load the Class into the VM. Written in pseudoc ode, Class.forName looks like:

public Class forName(String classToLoad)

throws . . .

{

ClassLoader cl = ClassLoader.getCallerClassLoader();

return cl.loadClass(classToLoad);

}

It’s fairly easy, now, to spot what the problem is. When a Class is loaded from the CLASSPATH, its associated ClassLoader is the AppClassLoader instance. When that Class invokes Class.forName, it can find other classes along the CLASSPATH or in the Extensions directory because AppClassLoader first delegates to its parent, the ExtClassLoader. Only if the requested class is not found as an Extension is the CLASSPATH searched.

?

When the calling Class is loaded as an Extension, however, its associated ClassLoader is the ExtClassLoader. Thus, when the Extension-loaded class calls Class.forName,

1. The caller’s ClassLoader is obtained; in this case, that ClassLoader is the ExtClassLoader instance.

2. The ExtClassLoader, being a good child, gives its parent, the bootstrap ClassLoader, the opportunity to load the class.

3. Because the bootstrap ClassLoader fails to find it in jdk/jre/lib/rt.jar, it returns without a loaded Class.

4. ExtClassLoader’s loadClass method then attempts to load the Class from within its list of URLs (given, as described earlier, in the java.ext.dirs property). Because the class is not within the list of URLs associated with ExtClassLoader, the load fails, and a ClassNotFoundException is thrown.

Put simply, because Extension-loaded classes don’t have the AppClassLoader instance anywhere on their parent-ClassLoader chain, they can’t load any classes off of the CLASSPATH.

Solution

Fundamentally, there are two solutions available to you: use a different form of the forName method on Class, or use a ClassLoader associated with each specific Thread, called the Thread’s context ClassLoader. As with everything, each approach has its own consequences. Use Thread.getContextClassLoader. A new concept introduced in Java2, each Thread now has a context ClassLoader associated with it. Looking at the javadocs[1] for the Thread methods getContextClassLoader and setContextClassLoader reveals that Thread.getContextClassLoader: Returns the context ClassLoader for this Thread. The context ClassLoader is provided by the creator of the thread for use by code running in this thread when loading classes and resources. If not set, the default is the ClassLoader context of the parent Thread. The context ClassLoader of the primordial thread is typically set to the class loader used to load the application. Thread.setContextClassLoader: Sets the context ClassLoader for this Thread. The context ClassLoader can be set when a thread is created, and allows the creator of the thread to provide the appropriate class loader to code running in the thread when loading classes and resources.

Dynamic Class Loading in the JavaTM Virtual Machine Class loaders are a powerful mechanism for dynamically loading software components on the Java platform. They are unusual in supporting all of the following features: laziness, type-safe linkage, user-defined extensibility, and multiple communicating namespaces. We present the notion of class loaders and demonstrate some of their interesting uses. In addition, we discusshow to maintain type safety in the presence of user-defined dynamic class loading. 立即下载

相关推荐

【CubeMX】STM32G474 HRTIM 互补PWM与死区时间配置实战

本文详细介绍了如何使用STM32CubeMX配置STM32G474的高分辨率定时器HRTIM生成互补PWM波形并精确设置死区时间。通过实战步骤讲解时钟配置、死区计算与高级功能,帮助工程师在电机驱动和电源应用中实现精准控制,避免上下桥臂直通风险。

grpc6streamer的博客 727

科研写作——常见句式(五)

These are particularly disappointing finding(s). 这些发现特别令人失望。This is a rather surprising result(s). 这是一个相当令人惊讶的结果。These are particularly troubling result(s). 这些结果尤其令人不安。These are particularly disappointing result(s). 这些结果特别令人失望。These are rather surprising f

qq_42635142的博客 2763

一文读懂YOLO V5 与 YOLO V4

一文读懂YOLO V5 与 YOLO V4 YOLO之父Joseph Redmon在今年年初宣布退出计算机视觉的研究的时候,很多人都以为目标检测神器YOLO系列就此终结。然而在4月23日,继任者YOLO V4却悄无声息地来了。Alexey Bochkovskiy发表了一篇名为YOLOV4: Optimal Speed and Accuracy of Object Detection的文章。YOLO V4是YOLO系列一个重大的更新,其在COCO数据集上的平均精度(AP)和帧率精度(FPS)分别提高了10%

williamhyin的博客 8794

Java安全代码扫描问题:不允许使用自动加载类

解决问题:代码安全扫描 "Classes should not be loaded dynamically",要求 "Remove this use of dynamic class loading." 解决方法:使用jdk自带方法ClassLoader.getSystemClassLoader().loadClass ClassLoader.getSystemClassLoader().loadClass("com.cn.MyTestVo"); ...

yxh6533的博客 5890

有限时间 vs 固定时间 vs 预定时间滑模:稳定性分析与仿真验证方法对比(中)

有限时间滑模控制(FTSMC)和固定时间滑模控制(FixTSMC)是两种重要的控制策略,旨在实现系统状态的快速收敛。FTSMC通过设计滑模面和控制律,确保系统状态在有限时间内收敛到原点,但其收敛时间与初始状态相关。FixTSMC则进一步优化,使收敛时间与初始状态无关,适用于高动态环境,具有更强的鲁棒性和更平滑的控制信号。两种方法均通过李雅普诺夫函数证明其稳定性,并通过仿真验证其有效性。FixTSMC在工程应用中更为可靠,尤其适合安全关键系统。

Lyajpunov的博客 3224

SAP Gateway OData V4 大数据集合分页机制详解,$skiptoken、Next Link 与服务端分页

更关键的是确定稳定排序方式,选择可靠的分页游标,限制单次 Response Size,正确生成 Next Link,让 Consumer 把 Next Link 当成不可解释的协议结果,并明确区分 Pagination、Delta Synchronization 和 Snapshot Consistency。从协议表达来看,请求没有问题。假设系统内部配置为每次最多返回 100 条,而数据库里一共存在 12580 条符合条件的销售订单,那么第一次响应只包含前 100 条,同时附带一个 Next Link。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 53

Java动态加载类

Class.forName("")返回的是类 Class.forName("").newInstance()返回的是object 假如你需要动态调用的类名是HelloWord.class。HelloWord.class继承extends于父类HelloUniverse.clss,子类在集成父类属性和方法的时候可以扩展自己的属性和方法,父类必须有一个无参构造,子类可以通过默认super...

cuipanguo的博客 1072

手把手教你学 Simulink (1.3)--Simulink 的模块库及其模块介绍

Simulink 提供了丰富的模块库,涵盖了从基本的信号生成和处理到复杂的数学运算和系统建模的各种功能。通过熟悉这些模块库及其模块,你可以更高效地构建和仿真动态系统。

MHD0815的博客 5150

JVM笔记02.Class Loading

本文主要基于周志明老师的《深入理解Java虚拟机》及部分网络资源。 类加载 Class Loading 在Java代码中,类型(Class)的加载、连接与初始化过程都是在程序运行期间完成的。 类的生命周期 Class Cycle 加载 loading 查找并加载类的二进制数据 连接 linking 验证 verification 确保被加载的类的正确性 准备 preparation 为类的静态变量分配内存,并将其初始化为默认值(不是初值!!!) 解析 resolution 把类中.

努力推石头的西西弗斯 626

pg lib的信息及产生pg lib的三种方法

pg lib相比basic lib会多几方面pg 信息。除了pg arc(pg pin)以外,liberty还提供电压值,以及pmk cell的power_down_function功能相关信息。1.电压值除了常见的primary pg还有secondary pg和衬底。2.pg arc后端需要去做redhawk功耗分析,需要pg liberty提供pg arc,如果没有pg arc就需要手动去写custom lib代替3.pmk cell的power_down_function。

m0_61544122的博客 595

使用GeoServer发布WMS动态地图服务,使用openlayers访问wms服务浏览地图数据

GEOServer是java版开源工具,使用GEOServer简单几步就可以搭建自己的地图服务,与小伙伴们共享地图数据。 一、使用GEOServer发布WMS动态地图服务 大致步骤如下: 1. 新建工作区 左边菜单栏,工作区,新建,起个名字,设置url。 2. 选择数据源 左边菜单栏,选择“数据源”,点击“添加新的数据源”,常用的有shp、postgresql数据库,根据自己的需要选择,这里选择了shp文件源。 选中存放在刚才新建的工作区下面,给数据源起个名字,选择文件本机存放位置,设置编码,包含中文属

从地图看世界的专栏 4540

Java Reflection - Dynamic Class Loading and Reloading

It is possible to load and reload classes at runtime in Java, though it is not as straightforward as one might have hoped. This text will explain when and how you can load and reload classes in Java...

hnggg 390

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Understanding Class.forName (二)

The Launcher constructor, after constructing both the ExtClassLoader and AppClassLoader, sets the thread context ClassLoader to be the AppClassLoader instance. This means, unless your code (or other c

Anders小明的Blog 2027

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

java.lang.ClassCastException 强制类型转换错误

强制类型转换错误 找代码中的强转,一般是强转失败

weixin_41624462的博客 315

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Dynamic Class Loading for C++ on Linux

Dynamic Class Loading for C++ on LinuxLinux has much to offer as a developmentplatform: a robust operating environment with tested tools. Linuxalso boasts implement

Rhinocerotic Doozer 1970

利用Class.forName 方法来动态加载驱动类举例详解classloader

一直搞不懂的classloader,看了这篇文章之后弄清晰 了,博主还利用Class.forName 方法来动态加载驱动类来给我们解释类具体如何加载的 原文链接:https://juejin.im/post/5c04892351882516e70dcc9b 老大难的 Java ClassLoader 再不理解就老了 ClassLoader 是 Java 届最为神秘的技术之一,无数人被它伤透了...

zhao_1109的博客 3585

代码审查问题及解决方案

bug类型: 1、".equals()" should not be used to test the values of "Atomic" classes. bug 主要 不要使用equals方法对AtomicXXX进行是否相等的判断 Atomic变量永远只会和自身相等,Atomic变量没有覆写equals()方法. 2、"=+" should not be used instead of "+=" bug 主要 "=+" 与 "=+" 意义不同 a =+ b;虽然...

weixin_44792817的博客 1万+

Dynamic class loading

The dynamic class loading system is another new feature for Ext JS 4. It also provides an integrated dependency management system.   This new feature is optional and you should avoid using it in p...

我的博客 1426

java重新加载class,DynamicClassLoader 动态加载/重新(动态)加载 class,,运行期重新加载一个已经加...

DynamicClassLoader 动态加载/重新(动态)加载 class,,运行期重新加载一个已经加运行期重新加载一个已经加载过的class,必须重新new一个DynamicClassLoader对象进行加载,java规范中规定,同一个ClassLoader对象中只能加载一次相同的classDynamicClassLoader.javapackage libra.law.util;import...

weixin_40006265的博客 1280

Dynamic Class Loading in Java

It is possible to load and reload classes at runtime in Java, though it is not as straightforward as one might have hoped. This text will explain when and how you can load and reload classes in Java. ...

移动开发记录 492

java-如何删除这种使用动态类加载或替换此类加载的方法?

othersMap.put("maskedPan", Class.forName("Some Class")); 删除对动态类加载的使用. 规则 变更日志 类不应动态加载 动态加载的类可能包含由静态类初始化程序执行的恶意代码.即您甚至不必实例化或显式调用此类上的方法即可轻松受到攻击. 对于每次使用动态类加载,此规则都会引起一个问题. 不兼容的代码示例 String classNa...

weixin_44109689的博客 1325

sonar 规则之漏洞类型

漏洞类型:1、"@RequestMapping" methods should be "public"漏洞 阻断标注了RequestMapping是controller是处理web请求。既使方法修饰为private,同样也能被外部调用,因为spring通过反射调用方法,没有检查方法可视度,2、"enum" fields should not be publicly mutable漏洞 次要枚举类域...

lxlmycsdnfree的博客 8536

Class.forName和ClassLoader.loadClass

这里讨论的Class.forName是Class类的方法public static Class<?> forName(String className) throws ClassNotFoundException 这里讨论的ClassLoader.loadClass是ClassLoader类的方法public Class<?> loadClass(String name) throws ClassNotFoundException ClassLoader在加载类时的概念区分 &n.

WeiPeng2K的博客 786

InnoDB 内存结构总览:Change Buffer、AHI 与 Log Buffer

本文系统梳理InnoDB内存结构中的ChangeBuffer、Adaptive Hash Index(AHI)与LogBuffer。ChangeBuffer缓存二级索引页不在内存时的变更,减少随机IO,仅在页加载时合并;聚簇索引修改立即执行,因数据本身不可延后。AHI基于高频等值查询自动构建哈希索引,加速定位,仅支持等值操作。LogBuffer为redo log内存缓冲,配合磁盘日志实现崩溃恢复。三者均服务于性能优化,其中ChangeBuffer与AHI共享BufferPool空间,而LogBuffer独立

bksczm的博客 290
上一篇: 《简单实现Crystal Report动态加载》补遗
下一篇: Understanding Class.forName (二)
林仪明
博客等级 码龄25年 313粉丝 61原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值