Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1A9A4115FC for ; Fri, 10 May 2013 16:41:40 +0000 (UTC) Received: (qmail 3875 invoked by uid 500); 10 May 2013 16:41:36 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 3795 invoked by uid 500); 10 May 2013 16:41:36 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 3784 invoked by uid 99); 10 May 2013 16:41:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 May 2013 16:41:36 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [194.25.134.18] (HELO mailout04.t-online.de) (194.25.134.18) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 May 2013 16:41:30 +0000 Received: from fwd18.aul.t-online.de (fwd18.aul.t-online.de ) by mailout04.t-online.de with smtp id 1UaqNY-0003Ss-VN; Fri, 10 May 2013 18:41:08 +0200 Received: from NamePC (XH7Qn8ZVohT0S5odCyeBp-i69OR7f3PiADnp1lsYyvFN0HxD47jODTDz74BDlgngB1@[217.95.95.35]) by fwd18.t-online.de with esmtp id 1UaqNX-0yNssC0; Fri, 10 May 2013 18:41:07 +0200 From: =?utf-8?Q?Konstantin_Prei=C3=9Fer?= To: "'Tomcat Users List'" Subject: [OT] Querstion about Class.forName() re. ClassLoaders Date: Fri, 10 May 2013 18:41:04 +0200 Message-ID: <000001ce4d9d$29a92c00$7cfb8400$@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 15.0 Thread-Index: Ac5NmLvwkFetk4XNQv6SU67fH1CNbg== Content-Language: de X-ID: XH7Qn8ZVohT0S5odCyeBp-i69OR7f3PiADnp1lsYyvFN0HxD47jODTDz74BDlgngB1 X-TOI-MSGID: 2c9f9cbb-8a91-4c10-95b9-bf94be7e636f X-Virus-Checked: Checked by ClamAV on apache.org Hi all, I apologize for being completely off-topic (this question has nothing to = do with Tomcat), but I thought there may be some guys here that are = experts in class loading and are able to answer my question. You probably know the method java.lang.Class.forName(String name) which = returns a class object from the given name. The JavaDoc (Java 7) of this = method says: Returns the Class object associated with the class or interface = with the given string name. Invoking this method is equivalent to: Class.forName(className, true, currentLoader)=20 where currentLoader denotes the defining class loader of the = current class. While this description may be a bit ambiguous about what "current class" = means here, the JavaDoc of Class.forName(String name, boolean = initialize, ClassLoader loader) makes it clearer by stating: For example, in an instance method the expression: Class.forName("Foo")=20 is equivalent to: Class.forName("Foo", true, this.getClass().getClassLoader()) So, shouldn't this mean that I get the same result/behavior when writing = this code: public void doSomething() throws ClassNotFoundException { Class clazz =3D Class.forName("foo.Bar"); // do something... } Instead of this one: public void doSomething() throws ClassNotFoundException { Class clazz =3D Class.forName("foo.Bar", true, = this.getClass().getClassLoader()); // do something... } or did I misunderstand something? Thanks! Regards, Konstantin Prei=C3=9Fer --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org