<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FReflection%2FClass_Method_Field_Name</id>
		<title>Java/Reflection/Class Method Field Name - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FReflection%2FClass_Method_Field_Name"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Reflection/Class_Method_Field_Name&amp;action=history"/>
		<updated>2026-04-07T06:10:07Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Reflection/Class_Method_Field_Name&amp;diff=6061&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Reflection/Class_Method_Field_Name&amp;diff=6061&amp;oldid=prev"/>
				<updated>2010-06-01T06:01:26Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:01, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Reflection/Class_Method_Field_Name&amp;diff=6060&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Reflection/Class_Method_Field_Name&amp;diff=6060&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:43Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Create a new instance given a class name ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
 * contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
 * this work for additional information regarding copyright ownership.&lt;br /&gt;
 * The ASF licenses this file to You under the Apache License, Version 2.0&lt;br /&gt;
 * (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
 * the License.  You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
import java.net.MalformedURLException;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
/**&lt;br /&gt;
 * A collection of class management utility methods.&lt;br /&gt;
 *&lt;br /&gt;
 * @version $Id: ClassUtils.java 587751 2007-10-24 02:41:36Z vgritsenko $&lt;br /&gt;
 */&lt;br /&gt;
public class ClassUtils {&lt;br /&gt;
    /**&lt;br /&gt;
     * Create a new instance given a class name&lt;br /&gt;
     *&lt;br /&gt;
     * @param className A class name&lt;br /&gt;
     * @return A new instance&lt;br /&gt;
     * @exception Exception If an instantiation error occurs&lt;br /&gt;
     */&lt;br /&gt;
    public static Object newInstance(String className) throws Exception {&lt;br /&gt;
        return loadClass(className).newInstance();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Load a class given its name.&lt;br /&gt;
     * BL: We wan&amp;quot;t to use a known ClassLoader--hopefully the heirarchy&lt;br /&gt;
     *     is set correctly.&lt;br /&gt;
     *&lt;br /&gt;
     * @param className A class name&lt;br /&gt;
     * @return The class pointed to by &amp;lt;code&amp;gt;className&amp;lt;/code&amp;gt;&lt;br /&gt;
     * @exception ClassNotFoundException If a loading error occurs&lt;br /&gt;
     */&lt;br /&gt;
    public static Class loadClass(String className) throws ClassNotFoundException {&lt;br /&gt;
        return getClassLoader().loadClass(className);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Return a resource URL.&lt;br /&gt;
     * BL: if this is command line operation, the classloading issues&lt;br /&gt;
     *     are more sane.  During servlet execution, we explicitly set&lt;br /&gt;
     *     the ClassLoader.&lt;br /&gt;
     *&lt;br /&gt;
     * @return The context classloader.&lt;br /&gt;
     * @exception MalformedURLException If a loading error occurs&lt;br /&gt;
     */&lt;br /&gt;
    public static URL getResource(String resource) throws MalformedURLException {&lt;br /&gt;
        return getClassLoader().getResource(resource);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Return the context classloader.&lt;br /&gt;
     * BL: if this is command line operation, the classloading issues&lt;br /&gt;
     *     are more sane.  During servlet execution, we explicitly set&lt;br /&gt;
     *     the ClassLoader.&lt;br /&gt;
     *&lt;br /&gt;
     * @return The context classloader.&lt;br /&gt;
     */&lt;br /&gt;
    public static ClassLoader getClassLoader() {&lt;br /&gt;
        return Thread.currentThread().getContextClassLoader();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create a unique hash for Constructor and method ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 * JBoss, Home of Professional Open Source&lt;br /&gt;
 * Copyright 2005, JBoss Inc., and individual contributors as indicated&lt;br /&gt;
 * by the @authors tag. See the copyright.txt in the distribution for a&lt;br /&gt;
 * full listing of individual contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as&lt;br /&gt;
 * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
 * the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this software; if not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.ByteArrayOutputStream;&lt;br /&gt;
import java.io.DataOutputStream;&lt;br /&gt;
import java.lang.reflect.Constructor;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.security.DigestOutputStream;&lt;br /&gt;
import java.security.MessageDigest;&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.WeakHashMap;&lt;br /&gt;
/**&lt;br /&gt;
 * Create a unique hash for&lt;br /&gt;
 * &lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 2787 $&lt;br /&gt;
 */&lt;br /&gt;
@SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
public class MethodHashing {&lt;br /&gt;
  // Constants -----------------------------------------------------&lt;br /&gt;
  // Static --------------------------------------------------------&lt;br /&gt;
  static Map hashMap = new WeakHashMap();&lt;br /&gt;
  public static Method findMethodByHash(Class clazz, long hash) throws Exception {&lt;br /&gt;
    Method[] methods = clazz.getDeclaredMethods();&lt;br /&gt;
    for (int i = 0; i &amp;lt; methods.length; i++) {&lt;br /&gt;
      if (methodHash(methods[i]) == hash)&lt;br /&gt;
        return methods[i];&lt;br /&gt;
    }&lt;br /&gt;
    if (clazz.getSuperclass() != null) {&lt;br /&gt;
      return findMethodByHash(clazz.getSuperclass(), hash);&lt;br /&gt;
    }&lt;br /&gt;
    return null;&lt;br /&gt;
  }&lt;br /&gt;
  public static Constructor findConstructorByHash(Class clazz, long hash) throws Exception {&lt;br /&gt;
    Constructor[] cons = clazz.getDeclaredConstructors();&lt;br /&gt;
    for (int i = 0; i &amp;lt; cons.length; i++) {&lt;br /&gt;
      if (constructorHash(cons[i]) == hash)&lt;br /&gt;
        return cons[i];&lt;br /&gt;
    }&lt;br /&gt;
    if (clazz.getSuperclass() != null) {&lt;br /&gt;
      return findConstructorByHash(clazz.getSuperclass(), hash);&lt;br /&gt;
    }&lt;br /&gt;
    return null;&lt;br /&gt;
  }&lt;br /&gt;
  public static long methodHash(Method method) throws Exception {&lt;br /&gt;
    Class[] parameterTypes = method.getParameterTypes();&lt;br /&gt;
    String methodDesc = method.getName() + &amp;quot;(&amp;quot;;&lt;br /&gt;
    for (int j = 0; j &amp;lt; parameterTypes.length; j++) {&lt;br /&gt;
      methodDesc += getTypeString(parameterTypes[j]);&lt;br /&gt;
    }&lt;br /&gt;
    methodDesc += &amp;quot;)&amp;quot; + getTypeString(method.getReturnType());&lt;br /&gt;
    long hash = 0;&lt;br /&gt;
    ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(512);&lt;br /&gt;
    MessageDigest messagedigest = MessageDigest.getInstance(&amp;quot;SHA&amp;quot;);&lt;br /&gt;
    DataOutputStream dataoutputstream = new DataOutputStream(new DigestOutputStream(&lt;br /&gt;
        bytearrayoutputstream, messagedigest));&lt;br /&gt;
    dataoutputstream.writeUTF(methodDesc);&lt;br /&gt;
    dataoutputstream.flush();&lt;br /&gt;
    byte abyte0[] = messagedigest.digest();&lt;br /&gt;
    for (int j = 0; j &amp;lt; Math.min(8, abyte0.length); j++)&lt;br /&gt;
      hash += (long) (abyte0[j] &amp;amp; 0xff) &amp;lt;&amp;lt; j * 8;&lt;br /&gt;
    return hash;&lt;br /&gt;
  }&lt;br /&gt;
  public static long constructorHash(Constructor method) throws Exception {&lt;br /&gt;
    Class[] parameterTypes = method.getParameterTypes();&lt;br /&gt;
    String methodDesc = method.getName() + &amp;quot;(&amp;quot;;&lt;br /&gt;
    for (int j = 0; j &amp;lt; parameterTypes.length; j++) {&lt;br /&gt;
      methodDesc += getTypeString(parameterTypes[j]);&lt;br /&gt;
    }&lt;br /&gt;
    methodDesc += &amp;quot;)&amp;quot;;&lt;br /&gt;
    long hash = 0;&lt;br /&gt;
    ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(512);&lt;br /&gt;
    MessageDigest messagedigest = MessageDigest.getInstance(&amp;quot;SHA&amp;quot;);&lt;br /&gt;
    DataOutputStream dataoutputstream = new DataOutputStream(new DigestOutputStream(&lt;br /&gt;
        bytearrayoutputstream, messagedigest));&lt;br /&gt;
    dataoutputstream.writeUTF(methodDesc);&lt;br /&gt;
    dataoutputstream.flush();&lt;br /&gt;
    byte abyte0[] = messagedigest.digest();&lt;br /&gt;
    for (int j = 0; j &amp;lt; Math.min(8, abyte0.length); j++)&lt;br /&gt;
      hash += (long) (abyte0[j] &amp;amp; 0xff) &amp;lt;&amp;lt; j * 8;&lt;br /&gt;
    return hash;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Calculate method hashes. This algo is taken from RMI.&lt;br /&gt;
   * &lt;br /&gt;
   * @param intf&lt;br /&gt;
   * @return the map&lt;br /&gt;
   */&lt;br /&gt;
  public static Map getInterfaceHashes(Class intf) {&lt;br /&gt;
    // Create method hashes&lt;br /&gt;
    Method[] methods = intf.getDeclaredMethods();&lt;br /&gt;
    HashMap map = new HashMap();&lt;br /&gt;
    for (int i = 0; i &amp;lt; methods.length; i++) {&lt;br /&gt;
      Method method = methods[i];&lt;br /&gt;
      try {&lt;br /&gt;
        long hash = methodHash(method);&lt;br /&gt;
        map.put(method.toString(), new Long(hash));&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return map;&lt;br /&gt;
  }&lt;br /&gt;
  static String getTypeString(Class cl) {&lt;br /&gt;
    if (cl == Byte.TYPE) {&lt;br /&gt;
      return &amp;quot;B&amp;quot;;&lt;br /&gt;
    } else if (cl == Character.TYPE) {&lt;br /&gt;
      return &amp;quot;C&amp;quot;;&lt;br /&gt;
    } else if (cl == Double.TYPE) {&lt;br /&gt;
      return &amp;quot;D&amp;quot;;&lt;br /&gt;
    } else if (cl == Float.TYPE) {&lt;br /&gt;
      return &amp;quot;F&amp;quot;;&lt;br /&gt;
    } else if (cl == Integer.TYPE) {&lt;br /&gt;
      return &amp;quot;I&amp;quot;;&lt;br /&gt;
    } else if (cl == Long.TYPE) {&lt;br /&gt;
      return &amp;quot;J&amp;quot;;&lt;br /&gt;
    } else if (cl == Short.TYPE) {&lt;br /&gt;
      return &amp;quot;S&amp;quot;;&lt;br /&gt;
    } else if (cl == Boolean.TYPE) {&lt;br /&gt;
      return &amp;quot;Z&amp;quot;;&lt;br /&gt;
    } else if (cl == Void.TYPE) {&lt;br /&gt;
      return &amp;quot;V&amp;quot;;&lt;br /&gt;
    } else if (cl.isArray()) {&lt;br /&gt;
      return &amp;quot;[&amp;quot; + getTypeString(cl.getComponentType());&lt;br /&gt;
    } else {&lt;br /&gt;
      return &amp;quot;L&amp;quot; + cl.getName().replace(&amp;quot;.&amp;quot;, &amp;quot;/&amp;quot;) + &amp;quot;;&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /*&lt;br /&gt;
   * The use of hashCode is not enough to differenciate methods we override the&lt;br /&gt;
   * hashCode&lt;br /&gt;
   * &lt;br /&gt;
   * The hashes are cached in a static for efficiency RO: WeakHashMap needed to&lt;br /&gt;
   * support undeploy&lt;br /&gt;
   */&lt;br /&gt;
  public static long calculateHash(Method method) {&lt;br /&gt;
    Map methodHashes = (Map) hashMap.get(method.getDeclaringClass());&lt;br /&gt;
    if (methodHashes == null) {&lt;br /&gt;
      methodHashes = getInterfaceHashes(method.getDeclaringClass());&lt;br /&gt;
      // Copy and add&lt;br /&gt;
      WeakHashMap newHashMap = new WeakHashMap();&lt;br /&gt;
      newHashMap.putAll(hashMap);&lt;br /&gt;
      newHashMap.put(method.getDeclaringClass(), methodHashes);&lt;br /&gt;
      hashMap = newHashMap;&lt;br /&gt;
    }&lt;br /&gt;
    return ((Long) methodHashes.get(method.toString())).longValue();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Format a string buffer containing the Class, Interfaces, CodeSource, and ClassLoader information for the given object clazz. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.security.CodeSource;&lt;br /&gt;
import java.security.ProtectionDomain;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/*&lt;br /&gt;
 * JBoss, Home of Professional Open Source&lt;br /&gt;
 * Copyright 2005, JBoss Inc., and individual contributors as indicated&lt;br /&gt;
 * by the @authors tag. See the copyright.txt in the distribution for a&lt;br /&gt;
 * full listing of individual contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as&lt;br /&gt;
 * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
 * the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this software; if not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
 */&lt;br /&gt;
public class Main {&lt;br /&gt;
&lt;br /&gt;
  /**&lt;br /&gt;
   * Format a string buffer containing the Class, Interfaces, CodeSource, and&lt;br /&gt;
   * ClassLoader information for the given object clazz.&lt;br /&gt;
   * &lt;br /&gt;
   * @param clazz&lt;br /&gt;
   *          the Class&lt;br /&gt;
   * @param results -&lt;br /&gt;
   *          the buffer to write the info to&lt;br /&gt;
   */&lt;br /&gt;
  public static void displayClassInfo(Class clazz, StringBuffer results) {&lt;br /&gt;
    // Print out some codebase info for the clazz&lt;br /&gt;
    ClassLoader cl = clazz.getClassLoader();&lt;br /&gt;
    results.append(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    results.append(clazz.getName());&lt;br /&gt;
    results.append(&amp;quot;(&amp;quot;);&lt;br /&gt;
    results.append(Integer.toHexString(clazz.hashCode()));&lt;br /&gt;
    results.append(&amp;quot;).ClassLoader=&amp;quot;);&lt;br /&gt;
    results.append(cl);&lt;br /&gt;
    ClassLoader parent = cl;&lt;br /&gt;
    while (parent != null) {&lt;br /&gt;
      results.append(&amp;quot;\n..&amp;quot;);&lt;br /&gt;
      results.append(parent);&lt;br /&gt;
      URL[] urls = getClassLoaderURLs(parent);&lt;br /&gt;
      int length = urls != null ? urls.length : 0;&lt;br /&gt;
      for (int u = 0; u &amp;lt; length; u++) {&lt;br /&gt;
        results.append(&amp;quot;\n....&amp;quot;);&lt;br /&gt;
        results.append(urls[u]);&lt;br /&gt;
      }&lt;br /&gt;
      if (parent != null)&lt;br /&gt;
        parent = parent.getParent();&lt;br /&gt;
    }&lt;br /&gt;
    CodeSource clazzCS = clazz.getProtectionDomain().getCodeSource();&lt;br /&gt;
    if (clazzCS != null) {&lt;br /&gt;
      results.append(&amp;quot;\n++++CodeSource: &amp;quot;);&lt;br /&gt;
      results.append(clazzCS);&lt;br /&gt;
    } else&lt;br /&gt;
      results.append(&amp;quot;\n++++Null CodeSource&amp;quot;);&lt;br /&gt;
    results.append(&amp;quot;\nImplemented Interfaces:&amp;quot;);&lt;br /&gt;
    Class[] ifaces = clazz.getInterfaces();&lt;br /&gt;
    for (int i = 0; i &amp;lt; ifaces.length; i++) {&lt;br /&gt;
      Class iface = ifaces[i];&lt;br /&gt;
      results.append(&amp;quot;\n++&amp;quot;);&lt;br /&gt;
      results.append(iface);&lt;br /&gt;
      results.append(&amp;quot;(&amp;quot;);&lt;br /&gt;
      results.append(Integer.toHexString(iface.hashCode()));&lt;br /&gt;
      results.append(&amp;quot;)&amp;quot;);&lt;br /&gt;
      ClassLoader loader = ifaces[i].getClassLoader();&lt;br /&gt;
      results.append(&amp;quot;\n++++ClassLoader: &amp;quot;);&lt;br /&gt;
      results.append(loader);&lt;br /&gt;
      ProtectionDomain pd = ifaces[i].getProtectionDomain();&lt;br /&gt;
      CodeSource cs = pd.getCodeSource();&lt;br /&gt;
      if (cs != null) {&lt;br /&gt;
        results.append(&amp;quot;\n++++CodeSource: &amp;quot;);&lt;br /&gt;
        results.append(cs);&lt;br /&gt;
      } else&lt;br /&gt;
        results.append(&amp;quot;\n++++Null CodeSource&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /**&lt;br /&gt;
   * Use reflection to access a URL[] getURLs or URL[] getClasspath method so&lt;br /&gt;
   * that non-URLClassLoader class loaders, or class loaders that override&lt;br /&gt;
   * getURLs to return null or empty, can provide the true classpath info.&lt;br /&gt;
   * &lt;br /&gt;
   * @param cl&lt;br /&gt;
   * @return the urls&lt;br /&gt;
   */&lt;br /&gt;
  public static URL[] getClassLoaderURLs(ClassLoader cl) {&lt;br /&gt;
    URL[] urls = {};&lt;br /&gt;
    try {&lt;br /&gt;
      Class returnType = urls.getClass();&lt;br /&gt;
      Class[] parameterTypes = {};&lt;br /&gt;
      Class clClass = cl.getClass();&lt;br /&gt;
      Method getURLs = clClass.getMethod(&amp;quot;getURLs&amp;quot;, parameterTypes);&lt;br /&gt;
      if (returnType.isAssignableFrom(getURLs.getReturnType())) {&lt;br /&gt;
        Object[] args = {};&lt;br /&gt;
        urls = (URL[]) getURLs.invoke(cl, args);&lt;br /&gt;
      }&lt;br /&gt;
      if (urls == null || urls.length == 0) {&lt;br /&gt;
        Method getCp = clClass.getMethod(&amp;quot;getClasspath&amp;quot;, parameterTypes);&lt;br /&gt;
        if (returnType.isAssignableFrom(getCp.getReturnType())) {&lt;br /&gt;
          Object[] args = {};&lt;br /&gt;
          urls = (URL[]) getCp.invoke(cl, args);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    } catch (Exception ignore) {&lt;br /&gt;
    }&lt;br /&gt;
    return urls;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Get non Package Qualified Name ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class Utils {&lt;br /&gt;
  public static String nonPackageQualifiedName( final Class&amp;lt;?&amp;gt; clazz ) {&lt;br /&gt;
      String name = clazz.getName();&lt;br /&gt;
      return name.substring(name.lastIndexOf(&amp;quot;.&amp;quot;) + 1);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Get the short name of the specified class by striping off the package name. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.security.CodeSource;&lt;br /&gt;
import java.security.ProtectionDomain;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/*&lt;br /&gt;
 * JBoss, Home of Professional Open Source&lt;br /&gt;
 * Copyright 2005, JBoss Inc., and individual contributors as indicated&lt;br /&gt;
 * by the @authors tag. See the copyright.txt in the distribution for a&lt;br /&gt;
 * full listing of individual contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as&lt;br /&gt;
 * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
 * the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this software; if not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
 */&lt;br /&gt;
public class Main {&lt;br /&gt;
  /** The string used to separator packages */&lt;br /&gt;
  public static final String PACKAGE_SEPARATOR = &amp;quot;.&amp;quot;;&lt;br /&gt;
  /**&lt;br /&gt;
   * Get the short name of the specified class by striping off the package name.&lt;br /&gt;
   * &lt;br /&gt;
   * @param classname&lt;br /&gt;
   *          Class name.&lt;br /&gt;
   * @return Short class name.&lt;br /&gt;
   */&lt;br /&gt;
  public static String stripPackageName(final String classname) {&lt;br /&gt;
    int idx = classname.lastIndexOf(PACKAGE_SEPARATOR);&lt;br /&gt;
    if (idx != -1)&lt;br /&gt;
      return classname.substring(idx + 1, classname.length());&lt;br /&gt;
    return classname;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Load a class given its name. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
 * contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
 * this work for additional information regarding copyright ownership.&lt;br /&gt;
 * The ASF licenses this file to You under the Apache License, Version 2.0&lt;br /&gt;
 * (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
 * the License.  You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
import java.net.MalformedURLException;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
/**&lt;br /&gt;
 * A collection of class management utility methods.&lt;br /&gt;
 *&lt;br /&gt;
 * @version $Id: ClassUtils.java 587751 2007-10-24 02:41:36Z vgritsenko $&lt;br /&gt;
 */&lt;br /&gt;
public class ClassUtils {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Load a class given its name.&lt;br /&gt;
     * BL: We wan&amp;quot;t to use a known ClassLoader--hopefully the heirarchy&lt;br /&gt;
     *     is set correctly.&lt;br /&gt;
     *&lt;br /&gt;
     * @param className A class name&lt;br /&gt;
     * @return The class pointed to by &amp;lt;code&amp;gt;className&amp;lt;/code&amp;gt;&lt;br /&gt;
     * @exception ClassNotFoundException If a loading error occurs&lt;br /&gt;
     */&lt;br /&gt;
    public static Class loadClass(String className) throws ClassNotFoundException {&lt;br /&gt;
        return getClassLoader().loadClass(className);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Return a resource URL.&lt;br /&gt;
     * BL: if this is command line operation, the classloading issues&lt;br /&gt;
     *     are more sane.  During servlet execution, we explicitly set&lt;br /&gt;
     *     the ClassLoader.&lt;br /&gt;
     *&lt;br /&gt;
     * @return The context classloader.&lt;br /&gt;
     * @exception MalformedURLException If a loading error occurs&lt;br /&gt;
     */&lt;br /&gt;
    public static URL getResource(String resource) throws MalformedURLException {&lt;br /&gt;
        return getClassLoader().getResource(resource);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Return the context classloader.&lt;br /&gt;
     * BL: if this is command line operation, the classloading issues&lt;br /&gt;
     *     are more sane.  During servlet execution, we explicitly set&lt;br /&gt;
     *     the ClassLoader.&lt;br /&gt;
     *&lt;br /&gt;
     * @return The context classloader.&lt;br /&gt;
     */&lt;br /&gt;
    public static ClassLoader getClassLoader() {&lt;br /&gt;
        return Thread.currentThread().getContextClassLoader();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Returns an instance of the given class name, by calling the default constructor. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 * $Id: ClassUtil.java 709153 2008-10-30 12:54:10Z apetrelli $&lt;br /&gt;
 *&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements.  See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership.  The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License.  You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied.  See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Utilities to work with dynamic class loading and instantiation.&lt;br /&gt;
 *&lt;br /&gt;
 * @version $Rev: 709153 $ $Date: 2008-10-30 13:54:10 +0100 (Thu, 30 Oct 2008) $&lt;br /&gt;
 * @since 2.0.7&lt;br /&gt;
 */&lt;br /&gt;
public class Main {&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns an instance of the given class name, by calling the default&lt;br /&gt;
   * constructor.&lt;br /&gt;
   *&lt;br /&gt;
   * @param className The class name to load and to instantiate.&lt;br /&gt;
   * @param returnNull If &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, if the class is not found it&lt;br /&gt;
   * returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, otherwise it throws a&lt;br /&gt;
   * &amp;lt;code&amp;gt;TilesException&amp;lt;/code&amp;gt;.&lt;br /&gt;
   * @return The new instance of the class name.&lt;br /&gt;
   * @throws CannotInstantiateObjectException If something goes wrong during instantiation.&lt;br /&gt;
   * @since 2.0.7&lt;br /&gt;
   */&lt;br /&gt;
  public static Object instantiate(String className, boolean returnNull) {&lt;br /&gt;
      ClassLoader original = Thread.currentThread().getContextClassLoader();&lt;br /&gt;
      if (original == null) {&lt;br /&gt;
          Thread.currentThread().setContextClassLoader(Main.class.getClassLoader());&lt;br /&gt;
      }&lt;br /&gt;
      try {&lt;br /&gt;
          Class&amp;lt;?&amp;gt; namedClass = Class.forName(className);&lt;br /&gt;
          return namedClass.newInstance();&lt;br /&gt;
      } catch (ClassNotFoundException e) {&lt;br /&gt;
          if (returnNull) {&lt;br /&gt;
              return null;&lt;br /&gt;
          }&lt;br /&gt;
          throw new RuntimeException(&lt;br /&gt;
                  &amp;quot;Unable to resolve factory class: &amp;quot;&amp;quot; + className + &amp;quot;&amp;quot;&amp;quot;, e);&lt;br /&gt;
      } catch (IllegalAccessException e) {&lt;br /&gt;
          throw new RuntimeException(&lt;br /&gt;
                  &amp;quot;Unable to access factory class: &amp;quot;&amp;quot; + className + &amp;quot;&amp;quot;&amp;quot;, e);&lt;br /&gt;
      } catch (InstantiationException e) {&lt;br /&gt;
          throw new RuntimeException(&lt;br /&gt;
                  &amp;quot;Unable to instantiate factory class: &amp;quot;&amp;quot;&lt;br /&gt;
                          + className&lt;br /&gt;
                          + &amp;quot;&amp;quot;. Make sure that this class has a default constructor&amp;quot;,&lt;br /&gt;
                  e);&lt;br /&gt;
      } finally {&lt;br /&gt;
          // If the original context classloader of the current thread was&lt;br /&gt;
          // null, it must be reset.&lt;br /&gt;
          if (original == null) {&lt;br /&gt;
              Thread.currentThread().setContextClassLoader(null);&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Returns the name of a class without the package name ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
public class Utils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the name of a class without the package name.  For example: if&lt;br /&gt;
   * input = &amp;quot;java.lang.Object&amp;quot; , then output = &amp;quot;Object&amp;quot;.&lt;br /&gt;
   * @param fully qualified classname&lt;br /&gt;
   * @return the unqualified classname &lt;br /&gt;
   */&lt;br /&gt;
  public static String getShortClassName(final String className) {&lt;br /&gt;
      if (className != null) {&lt;br /&gt;
          final int index = className.lastIndexOf(&amp;quot;.&amp;quot;);&lt;br /&gt;
          return className.substring(index + 1);&lt;br /&gt;
      }&lt;br /&gt;
      return null;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Returns the package portion of the specified class ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
public class Utils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the package portion of the specified class&lt;br /&gt;
   * @param className the name of the class from which to extract the package&lt;br /&gt;
   * @return package portion of the specified class&lt;br /&gt;
   */&lt;br /&gt;
  public static String getPackageName(final String className) {&lt;br /&gt;
      if (className != null) {&lt;br /&gt;
          final int index = className.lastIndexOf(&amp;quot;.&amp;quot;);&lt;br /&gt;
          return ((index != -1) ? className.substring(0, index) : &amp;quot;&amp;quot;); // NOI18N&lt;br /&gt;
      }&lt;br /&gt;
      return null;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>