From 2842b70e8ea58d1d514f0f634e39c87b84a02485 Mon Sep 17 00:00:00 2001 From: eea1 Date: Wed, 20 May 1998 18:20:35 +0000 Subject: Removed the deprecation warning of defineClass in the loadClass method for loading over a network. I did this by extracting the class name for the URL file name. --- java/src/ServiceLoader.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'java') diff --git a/java/src/ServiceLoader.java b/java/src/ServiceLoader.java index 540f72b07b7..86f15dc57c9 100644 --- a/java/src/ServiceLoader.java +++ b/java/src/ServiceLoader.java @@ -63,6 +63,23 @@ public class ServiceLoader extends ClassLoader public Class loadClass (URL url, boolean resolve) throws ClassNotFoundException { Class newClass = null; + + // Extract the name of the class from the URL + + String className = url.getFile(); + + // Remove any directory information + int idx = className.lastIndexOf("/"); + if (idx != -1) + className = className.substring(idx + 1); + + // Get rid of the class suffix + idx = className.lastIndexOf(".class"); + if (idx != -1) + className = className.substring(0, idx); + + ACE.DEBUG("The name of the class about to load is " + className); + // Try to load it the class by reading in the bytes. // Note that we are not catching ClassNotFoundException here // since our caller will catch it. @@ -81,7 +98,7 @@ public class ServiceLoader extends ClassLoader // Now read all the data into the buffer i.readFully (buf); - newClass = defineClass (buf, 0, buf.length); + newClass = defineClass (className, buf, 0, buf.length); // ACE.DEBUG ("Loaded class: "+ name); // Check if we need to load other classes referred to by this class. -- cgit v1.2.1