Source Code Cross Referenced for ArrayClassLoader.java in  » Test-Coverage » GroboUtils » net » sourceforge » groboutils » util » classes » v1 » jdk0 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » GroboUtils » net.sourceforge.groboutils.util.classes.v1.jdk0 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)ArrayClassLoader.java    1.0.0 11/17/2000 - 12:01:17
003:         *
004:         * Copyright (C) 2000,2002-2003 Matt Albrecht
005:         * groboclown@users.sourceforge.net
006:         * http://groboutils.sourceforge.net
007:         *
008:         *  Permission is hereby granted, free of charge, to any person obtaining a
009:         *  copy of this software and associated documentation files (the "Software"),
010:         *  to deal in the Software without restriction, including without limitation
011:         *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
012:         *  and/or sell copies of the Software, and to permit persons to whom the 
013:         *  Software is furnished to do so, subject to the following conditions:
014:         *
015:         *  The above copyright notice and this permission notice shall be included in 
016:         *  all copies or substantial portions of the Software. 
017:         *
018:         *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
019:         *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
020:         *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL 
021:         *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
022:         *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
023:         *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
024:         *  DEALINGS IN THE SOFTWARE.
025:         */
026:
027:        package net.sourceforge.groboutils.util.classes.v1.jdk0;
028:
029:        import java.util.Hashtable;
030:        import java.util.Enumeration;
031:        import java.util.Vector;
032:
033:        /**
034:         * Load classes by byte Arrays.  JDK 1.0+ compatible.
035:         *
036:         * @author  Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
037:         * @version $Date: 2003/02/10 22:52:36 $
038:         * @since   November 17, 2000 (GroboUtils Alpha 0.9.0)
039:         */
040:        public class ArrayClassLoader extends ClassLoader {
041:            //----------------------------
042:            // Public data
043:
044:            //----------------------------
045:            // Private data
046:
047:            /**
048:             * list of all classes
049:             */
050:            private Hashtable m_classList = new Hashtable();
051:            private Hashtable m_classCache = new Hashtable();
052:
053:            /**
054:             * The original bytecode source, for linking.
055:             */
056:            private BytecodeSource m_bytecodeSource = null;
057:
058:            //----------------------------
059:            // constructors
060:
061:            /**
062:             * Default constructor
063:             */
064:            public ArrayClassLoader() {
065:                // do nothing
066:            }
067:
068:            //----------------------------
069:            // Public methods
070:
071:            /**
072:             * Sets the reference to the original bytecode loader.  By default,
073:             * the value is <tt>null</tt>.  If the value is <tt>null</tt>, then
074:             * there is the possibility for a link error.
075:             */
076:            public void setBytecodeSource(BytecodeSource bs) {
077:                this .m_bytecodeSource = bs;
078:            }
079:
080:            /**
081:             * Add a new class to the internal list.
082:             */
083:            public void addClass(String name, byte[] bytecode) {
084:                if (name == null || bytecode == null) {
085:                    throw new IllegalArgumentException("no null args");
086:                }
087:                this .m_classList.put(name, bytecode);
088:            }
089:
090:            // inherited from ClassLoader
091:            /**
092:             * @exception ClassNotFoundException thrown if the given class name
093:             *      could not be found, or if there was a problem loading the
094:             *      bytecode for the class.
095:             */
096:            public Class loadClass(String name, boolean resolve)
097:                    throws ClassNotFoundException {
098:                Class c;
099:
100:                if (name == null) {
101:                    throw new IllegalArgumentException("classname is null");
102:                }
103:
104:                c = (Class) this .m_classCache.get(name);
105:                if (c == null) {
106:                    try {
107:                        c = findSystemClass(name);
108:                    } catch (Exception ex) {
109:                        byte bytecode[] = getBytecode(name);
110:                        if (bytecode == null) {
111:                            System.out
112:                                    .println(this .getClass().getName()
113:                                            + "::loadClass( '"
114:                                            + name
115:                                            + "' ): bytecode for class was never defined.");
116:                            throw new ClassNotFoundException(name);
117:                        } else {
118:                            try {
119:                                c = defineClass(name, bytecode, 0,
120:                                        bytecode.length);
121:                                this .m_classCache.put(name, c);
122:                            } catch (Exception ex2) {
123:                                // something wrong with the class format
124:                                throw new ClassNotFoundException(
125:                                        "Bad class format for class " + name);
126:                            }
127:                        }
128:                    }
129:                }
130:                if (resolve) {
131:                    resolveClass(c);
132:                }
133:                return c;
134:            }
135:
136:            //----------------------------
137:            // Protected methods
138:
139:            /**
140:             * Retrieves the internal bytecode for the given class.  If not known,
141:             * then will attempt to pass it to the bytecode source.
142:             *
143:             * @param className a non-null class name.
144:             */
145:            protected byte[] getBytecode(String className) {
146:                byte bytecode[] = (byte[]) this .m_classList.get(className);
147:                if (bytecode == null) {
148:                    if (this .m_bytecodeSource != null) {
149:                        bytecode = this .m_bytecodeSource.getBytecode(className);
150:                        if (bytecode != null) {
151:                            addClass(className, bytecode);
152:                        }
153:                    }
154:                }
155:                return bytecode;
156:            }
157:
158:            //----------------------------
159:            // Private methods
160:        }
ww_w_.__j___a__va___2_s_.__c__o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.