Source Code Cross Referenced for VMClassRegistry.java in  » Apache-Harmony-Java-SE » java-package » java » lang » 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 » Apache Harmony Java SE » java package » java.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        /**
018:         * @author Evgueni Brevnov, Roman S. Bushmanov
019:         * @version $Revision: 1.1.2.1.4.4 $
020:         */package java.lang;
021:
022:        import java.lang.reflect.Constructor;
023:        import java.lang.reflect.Field;
024:        import java.lang.reflect.Method;
025:        import java.lang.reflect.Member;
026:        import org.apache.harmony.drlvm.VMHelper;
027:
028:        /**
029:         * Provides the class information methods required for the
030:         * {@link java.lang.Class Class} implementation, and class loading/resolution
031:         * methods for the {@link java.lang.ClassLoader ClassLoader} implementation.
032:         * <p>
033:         * An implementation of the <code>java.lang.Class</code> class should not relay
034:         * on default object initialization by the VM. In other words the VM is free to
035:         * skip execution of the <code>java.lang.Class</code> private constructor. 
036:         * <p>
037:         * This class must be implemented according to the common policy for porting
038:         * interfaces - see the porting interface overview for more detailes.
039:         * 
040:         * @api2vm
041:         */
042:        final class VMClassRegistry {
043:            /**
044:             * This method satisfies the requirements of the specification for the
045:             * {@link Class#getSimpleName() Class.getSimpleName()}
046:             * method.
047:             * 
048:             * @param clazz a class to perform an operation on.
049:             * @return the simple name of the specified class 
050:             * 
051:             * @api2vm
052:             */
053:            static native String getSimpleName(Class<?> clazz);
054:
055:            /**
056:             * Returns the nearest enclosing class of the specified Class instance, 
057:             * or <code>null</code> if the specified class is a top-level class.
058:             * <br>This information is gathered from corresponding class-file structures 
059:             * (either EnclosingMethod or InnerClasses attribute, if any present). 
060:             * 
061:             * @param clazz a class to perform an operation on.
062:             * @return the immediately enclosing class of the specified class or null 
063:             * 
064:             * @api2vm
065:             */
066:            static native Class getEnclosingClass(Class<?> clazz);
067:
068:            /**
069:             * If the specified class is a local or anonymous class defined 
070:             * within a method or constructor, returns that closest
071:             * enclosing reflection member. Otherwise returns <code>null</code>.
072:             * Note, instance initializers and static initializers 
073:             * are not reflectable and will never be considered.
074:             * <br>This information is gathered from corresponding class-file structure 
075:             * (EnclosingMethod attribute, if present). 
076:             * 
077:             * @param clazz a class to perform an operation on.
078:             * @return the immediately enclosing member for the specified class or null 
079:             * 
080:             * @api2vm
081:             */
082:            static native Member getEnclosingMember(Class<?> clazz);
083:
084:            /**
085:             * This class is not supposed to be instantiated.
086:             */
087:            private VMClassRegistry() {
088:            }
089:
090:            /**
091:             * Loads the specified class with the bootstrap classloader.  
092:             * @throws LinkageError (or any subtype) if loading failed
093:             * @api2vm
094:             */
095:            static native Class<?> loadBootstrapClass(String name);
096:
097:            /**
098:             * This method satisfies the requirements of the specification for the
099:             * {@link Object#getClass() Object.getClass()} method.
100:             * @api2vm
101:             */
102:            static native Class<? extends Object> getClassNative(Object obj);
103:
104:            static Class<? extends Object> getClass(Object obj) {
105:                if (VMHelper.isVMMagicPackageSupported()) {
106:                    return (Class<? extends Object>) VMHelper.getManagedClass(
107:                            obj).toObjectReference().toObject();
108:                }
109:                return getClassNative(obj);
110:            }
111:
112:            /**
113:             * This method satisfies the requirements of the specification for the
114:             * {@link Class#getClassLoader() Class.getClassLoader()} method except
115:             * the clazz parameter may be null. In this case context class loader
116:             * of the current thread is returned.
117:             * 
118:             * @api2vm
119:             */
120:            static ClassLoader getClassLoader(Class<?> clazz) {
121:                if (clazz != null) {
122:                    assert (getClassLoader0(clazz) == clazz.definingLoader);
123:                    return clazz.definingLoader;
124:                }
125:                return Thread.currentThread().getContextClassLoader();
126:            }
127:
128:            /**
129:             * This method satisfies the requirements of the specification for the
130:             * {@link Class#getClassLoader() Class.getClassLoader()} method.
131:             * 
132:             * @api2vm
133:             */
134:            static native ClassLoader getClassLoader0(Class<?> clazz);
135:
136:            /**
137:             * This method satisfies the requirements of the specification for the
138:             * {@link Class#getComponentType() Class.getComponentType()} method.
139:             * @api2vm
140:             */
141:            static native Class<?> getComponentType(Class clazz);
142:
143:            /**
144:             * This method satisfies the requirements of the specification for the
145:             * {@link Class#getDeclaredClasses() Class.getDeclaredClasses()}
146:             *  method.
147:             * @api2vm
148:             */
149:            static native Class[] getDeclaredClasses(Class clazz);
150:
151:            /**
152:             * This method satisfies the requirements of the specification for the
153:             * {@link Class#getDeclaredConstructors() Class.getDeclaredConstructors()}
154:             * method.
155:             * @api2vm
156:             */
157:            static native <U> Constructor<U>[] getDeclaredConstructors(
158:                    Class<U> clazz);
159:
160:            /**
161:             * This method satisfies the requirements of the specification for the
162:             * {@link Class#getDeclaredFields() Class.getDeclaredFields()} method.
163:             * @api2vm
164:             */
165:            static native Field[] getDeclaredFields(Class clazz);
166:
167:            /**
168:             * This method satisfies the requirements of the specification for the
169:             * {@link Class#getDeclaredMethods() Class.getDeclaredMethods()} method. 
170:             * @api2vm
171:             */
172:            static native Method[] getDeclaredMethods(Class clazz);
173:
174:            /**
175:             * This method satisfies the requirements of the specification for the
176:             * {@link Class#getDeclaringClass() Class.getDeclaringClass()} method.
177:             * @api2vm
178:             */
179:            static native Class<?> getDeclaringClass(Class clazz);
180:
181:            /**
182:             * This method satisfies the requirements of the specification for the
183:             * {@link Class#getInterfaces() Class.getInterfaces()} method.
184:             * @api2vm
185:             */
186:            static native Class[] getInterfaces(Class clazz);
187:
188:            /**
189:             * This method satisfies the requirements of the specification for the
190:             * {@link Class#getModifiers() Class.getModifiers()} method.
191:             * @api2vm
192:             */
193:            static native int getModifiers(Class clazz);
194:
195:            /**
196:             * This method satisfies the requirements of the specification for the
197:             * {@link Class#getName() Class.getName()} method.
198:             * @api2vm
199:             */
200:            static native String getName(Class clazz);
201:
202:            /**
203:             * This method satisfies the requirements of the specification for the
204:             * {@link Class#getSuperclass() Class.getSuperclass()} method.
205:             * @api2vm
206:             */
207:            static native <U> Class<? super  U> getSuperclass(Class<U> clazz);
208:
209:            /**
210:             * This method returns a list describing the system packages, 
211:             * in format of {{name, url}}. That is, the list consists of 
212:             * pairs "{name, url}", organized as the 2-dimensional array[N][2].
213:             * The "name" is a Java package name.    
214:             * The "url" points to the jar file from which the corresponding package 
215:             * is loaded. If package comes not from a jar, then url is null.
216:             * 
217:             * @param len number of packages caller already knows. If this number is
218:             * equal to the actual number of system packages defined by VM, 
219:             * this method will skip array creation and return null.
220:             * @return a set of packages defined by bootstrap class loader or null
221:             * @api2vm
222:             */
223:            static native String[][] getSystemPackages(int len);
224:
225:            /**
226:             * This method is used for the
227:             * {@link Class#forName(java.lang.String, boolean, java.lang.ClassLoader)
228:             * Class.forName(String name, boolean initialize, ClassLoader loader)}
229:             * method implementation. If the initialize parameter is true then this 
230:             * method should be invoked in order to initialize a class. The specified
231:             * clazz parameter must not be null.
232:             * 
233:             * @param clazz a class to perform an operation on.
234:             * @throws ExceptionInInitializerError if initialization fails.
235:             * @api2vm
236:             */
237:            static native void initializeClass(Class clazz);
238:
239:            /**
240:             * This method satisfies the requirements of the specification for the
241:             * {@link Class#isArray() Class.isArray()} method.
242:             * @api2vm
243:             */
244:            static native boolean isArray(Class clazz);
245:
246:            /**
247:             * This method satisfies the requirements of the specification for the
248:             * {@link Class#isAssignableFrom(java.lang.Class)
249:             * Class.isAssignableFrom(Class cls)} method.
250:             * @api2vm
251:             */
252:            static native boolean isAssignableFrom(Class clazz,
253:                    Class<?> fromClazz); //XXX: does it have any sense?
254:
255:            /**
256:             * This method satisfies the requirements of the specification for the
257:             * {@link Class#isInstance(java.lang.Object) Class.isInstance(Object obj)}
258:             * method.
259:             * @api2vm
260:             */
261:            static native boolean isInstance(Class clazz, Object obj);
262:
263:            /**
264:             * This method satisfies the requirements of the specification for the
265:             * {@link Class#isPrimitive() Class.isPrimitive()} method.
266:             * @api2vm
267:             */
268:            static native boolean isPrimitive(Class clazz);
269:
270:            /**
271:             * This method satisfies the requirements of the specification for the
272:             * {@link ClassLoader#resolveClass(java.lang.Class)
273:             * ClassLoader.resolveClass(Class c)} method. Except that it doesn't throw
274:             * <code>NullPointerException</code> but throws <code>LinkagError</code>
275:             * exception. The specified clazz parameter must not be null.
276:             * 
277:             * @throws LinkageError if linking fails.
278:             * @api2vm
279:             */
280:            static native void linkClass(Class<?> clazz);
281:
282:            /**
283:             * This method is used for the
284:             * {@link Class#forName(java.lang.String, boolean, java.lang.ClassLoader)
285:             * Class.forName(String name, boolean initialize, ClassLoader loader)}
286:             * method implementation. If the name parameter represents an array then this  
287:             * method should be invoked in order to load an array class. For example, an
288:             * expression (loadArray(Integer.TYPE, 1) == new int[0].getClass()) must be
289:             * true. 
290:             * <p>
291:             * <b>Note:</b> Under design yet. Subjected to change.
292:             * 
293:             * @param componentType the type of array components. It must not be null.
294:             * @param dimensions array dimension. It must be greater or equal to 0.
295:             * @return a class which represents array
296:             * @api2vm
297:             */
298:            static native Class loadArray(Class componentType, int dimensions);
299:
300:            /**
301:             * This method is used for implementation of the
302:             * {@link Runtime#load(java.lang.String) Runtime.load(String filename)}
303:             * method.
304:             * @param filename full library name.
305:             * @param loader the library will be loaded into the specified class loader
306:             *        namespace
307:             * @throws UnsatisfiedLinkError if library can not be loaded for any reason  
308:             * @api2vm
309:             */
310:            static native void loadLibrary(String filename, ClassLoader loader);
311:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.