Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Update 2 发行说明

类加载器更改

在当前发行版中,可以在 JVM 系统类路径中找到添加到 domain.xml(应用服务器配置文件)的 classpath-prefixserver-classpathclasspath-suffix 属性中的 JAR 和目录条目。依赖于这种行为的应用程序可能会使用类 java.lang.ClassLoader 中的以下方法,访问 JVM 系统类路径中的类或其他资源:

在下一个主要发行版中,添加到 classpath-prefixserver-classpathclasspath-suffix 中的 JAR 和目录条目在 JVM 系统类路径中将不再可用。如果应用程序使用上述方法之一,Sun 强烈建议使用无需假定资源包含在系统类路径中的等效方法。不依赖于 JVM 系统类路径的等效方法可在 java.lang.ClassLoader 中获得,并应尽量使用这些方法;例如:


示例 2–1 旧代码

java.net.URL url = ClassLoader.getSystemResource
("com/acme/tools/tools.properties");


示例 2–2 建议的更改

java.net.URL url = this.getClass().getClassLoader().getResource
("com/acme/tools/tools.properties");

如果不能更改此代码,可以选择使用下一个发行版中将添加的一个新配置选项,以便设置 JVM 系统类路径。