001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.transformer.bytecode.reflection;
020
021import java.io.InputStream;
022import java.lang.reflect.Constructor;
023import java.lang.reflect.Field;
024import java.lang.reflect.GenericSignatureFormatError;
025import java.lang.reflect.MalformedParameterizedTypeException;
026import java.lang.reflect.Method;
027import java.lang.reflect.Type;
028import java.util.Map;
029
030public final class ASMClass implements java.io.Serializable {
031    
032
033    private String name;
034        private Map<String, ASMMethod> methods;
035
036
037        public ASMClass(String name, Map<String, ASMMethod> methods) {
038                this.name=name;
039                this.methods=methods;
040        }
041
042        /**
043     * Converts the object to a string. The string representation is the
044     * string "class" or "interface", followed by a space, and then by the
045     * fully qualified name of the class in the format returned by
046     * {@code getName}.  If this {@code Class} object represents a
047     * primitive type, this method returns the name of the primitive type.  If
048     * this {@code Class} object represents void this method returns
049     * "void".
050     *
051     * @return a string representation of this class object.
052     */
053    public String toString() {
054        return (isInterface() ? "interface " : (isPrimitive() ? "" : "class "))
055            + getName();
056    }
057
058    /**
059     * Creates a new instance of the class represented by this {@code Class}
060     * object.  The class is instantiated as if by a {@code new}
061     * expression with an empty argument list.  The class is initialized if it
062     * has not already been initialized.
063     *
064     * <p>Note that this method propagates any exception thrown by the
065     * nullary constructor, including a checked exception.  Use of
066     * this method effectively bypasses the compile-time exception
067     * checking that would otherwise be performed by the compiler.
068     * The {@link
069     * java.lang.reflect.Constructor#newInstance(java.lang.Object...)
070     * Constructor.newInstance} method avoids this problem by wrapping
071     * any exception thrown by the constructor in a (checked) {@link
072     * java.lang.reflect.InvocationTargetException}.
073     *
074     * @return     a newly allocated instance of the class represented by this
075     *             object.
076     * @exception  IllegalAccessException  if the class or its nullary
077     *               constructor is not accessible.
078     * @exception  InstantiationException
079     *               if this {@code Class} represents an abstract class,
080     *               an interface, an array class, a primitive type, or void;
081     *               or if the class has no nullary constructor;
082     *               or if the instantiation fails for some other reason.
083     * @exception  ExceptionInInitializerError if the initialization
084     *               provoked by this method fails.
085     * @exception  SecurityException
086     *             If a security manager, <i>s</i>, is present and any of the
087     *             following conditions is met:
088     *
089     *             <ul>
090     *
091     *             <li> invocation of
092     *             {@link SecurityManager#checkMemberAccess
093     *             s.checkMemberAccess(this, Member.PUBLIC)} denies
094     *             creation of new instances of this class
095     *
096     *             <li> the caller's class loader is not the same as or an
097     *             ancestor of the class loader for the current class and
098     *             invocation of {@link SecurityManager#checkPackageAccess
099     *             s.checkPackageAccess()} denies access to the package
100     *             of this class
101     *
102     *             </ul>
103     *
104     */
105    public Object newInstance()
106        throws InstantiationException, IllegalAccessException {
107        _throw();
108        return null;
109    }
110
111    /**
112     * Determines if the specified {@code Class} object represents an
113     * interface type.
114     *
115     * @return  {@code true} if this object represents an interface;
116     *          {@code false} otherwise.
117     */
118    public boolean isInterface(){
119        _throw();
120        return false;
121    }
122
123
124    /**
125     * Determines if this {@code Class} object represents an array class.
126     *
127     * @return  {@code true} if this object represents an array class;
128     *          {@code false} otherwise.
129     * @since   JDK1.1
130     */
131    public boolean isArray(){
132        _throw();
133        return false;
134    }
135
136
137    /**
138     * Determines if the specified {@code Class} object represents a
139     * primitive type.
140     *
141     * <p> There are nine predefined {@code Class} objects to represent
142     * the eight primitive types and void.  These are created by the Java
143     * Virtual Machine, and have the same names as the primitive types that
144     * they represent, namely {@code boolean}, {@code byte},
145     * {@code char}, {@code short}, {@code int},
146     * {@code long}, {@code float}, and {@code double}.
147     *
148     * <p> These objects may only be accessed via the following public static
149     * final variables, and are the only {@code Class} objects for which
150     * this method returns {@code true}.
151     *
152     * @return true if and only if this class represents a primitive type
153     *
154     * @see     java.lang.Boolean#TYPE
155     * @see     java.lang.Character#TYPE
156     * @see     java.lang.Byte#TYPE
157     * @see     java.lang.Short#TYPE
158     * @see     java.lang.Integer#TYPE
159     * @see     java.lang.Long#TYPE
160     * @see     java.lang.Float#TYPE
161     * @see     java.lang.Double#TYPE
162     * @see     java.lang.Void#TYPE
163     * @since JDK1.1
164     */
165    public boolean isPrimitive(){
166        _throw();
167        return false;
168    }
169
170    /**
171     * Returns the  name of the entity (class, interface, array class,
172     * primitive type, or void) represented by this {@code Class} object,
173     * as a {@code String}.
174     *
175     * <p> If this class object represents a reference type that is not an
176     * array type then the binary name of the class is returned, as specified
177     * by the Java Language Specification, Second Edition.
178     *
179     * <p> If this class object represents a primitive type or void, then the
180     * name returned is a {@code String} equal to the Java language
181     * keyword corresponding to the primitive type or void.
182     *
183     * <p> If this class object represents a class of arrays, then the internal
184     * form of the name consists of the name of the element type preceded by
185     * one or more '{@code [}' characters representing the depth of the array
186     * nesting.  The encoding of element type names is as follows:
187     *
188     * <blockquote><table summary="Element types and encodings">
189     * <tr><th> Element Type <th> &nbsp;&nbsp;&nbsp; <th> Encoding
190     * <tr><td> boolean      <td> &nbsp;&nbsp;&nbsp; <td align=center> Z
191     * <tr><td> byte         <td> &nbsp;&nbsp;&nbsp; <td align=center> B
192     * <tr><td> char         <td> &nbsp;&nbsp;&nbsp; <td align=center> C
193     * <tr><td> class or interface
194     *                       <td> &nbsp;&nbsp;&nbsp; <td align=center> L<i>classname</i>;
195     * <tr><td> double       <td> &nbsp;&nbsp;&nbsp; <td align=center> D
196     * <tr><td> float        <td> &nbsp;&nbsp;&nbsp; <td align=center> F
197     * <tr><td> int          <td> &nbsp;&nbsp;&nbsp; <td align=center> I
198     * <tr><td> long         <td> &nbsp;&nbsp;&nbsp; <td align=center> J
199     * <tr><td> short        <td> &nbsp;&nbsp;&nbsp; <td align=center> S
200     * </table></blockquote>
201     *
202     * <p> The class or interface name <i>classname</i> is the binary name of
203     * the class specified above.
204     *
205     * <p> Examples:
206     * <blockquote><pre>
207     * String.class.getName()
208     *     returns "java.lang.String"
209     * byte.class.getName()
210     *     returns "byte"
211     * (new Object[3]).getClass().getName()
212     *     returns "[Ljava.lang.Object;"
213     * (new int[3][4][5][6][7][8][9]).getClass().getName()
214     *     returns "[[[[[[[I"
215     * </pre></blockquote>
216     *
217     * @return  the name of the class or interface
218     *          represented by this object.
219     */
220    public String getName() {
221        _throw();
222        return name;
223    }
224
225    
226    /**
227     * Returns the class loader for the class.  Some implementations may use
228     * null to represent the bootstrap class loader. This method will return
229     * null in such implementations if this class was loaded by the bootstrap
230     * class loader.
231     *
232     * <p> If a security manager is present, and the caller's class loader is
233     * not null and the caller's class loader is not the same as or an ancestor of
234     * the class loader for the class whose class loader is requested, then
235     * this method calls the security manager's {@code checkPermission}
236     * method with a {@code RuntimePermission("getClassLoader")}
237     * permission to ensure it's ok to access the class loader for the class.
238     *
239     * <p>If this object
240     * represents a primitive type or void, null is returned.
241     *
242     * @return  the class loader that loaded the class or interface
243     *          represented by this object.
244     * @throws SecurityException
245     *    if a security manager exists and its
246     *    {@code checkPermission} method denies
247     *    access to the class loader for the class.
248     * @see java.lang.ClassLoader
249     * @see SecurityManager#checkPermission
250     * @see java.lang.RuntimePermission
251     */
252    public ClassLoader getClassLoader() {
253        _throw();
254        return null;
255    }
256
257
258    /**
259     * Returns the {@code Class} representing the superclass of the entity
260     * (class, interface, primitive type or void) represented by this
261     * {@code Class}.  If this {@code Class} represents either the
262     * {@code Object} class, an interface, a primitive type, or void, then
263     * null is returned.  If this object represents an array class then the
264     * {@code Class} object representing the {@code Object} class is
265     * returned.
266     *
267     * @return the superclass of the class represented by this object.
268     */
269    public  Class getSuperclass(){
270        _throw();
271        return null;
272    }
273
274
275    /**
276     * Returns the {@code Type} representing the direct superclass of
277     * the entity (class, interface, primitive type or void) represented by
278     * this {@code Class}.
279     *
280     * <p>If the superclass is a parameterized type, the {@code Type}
281     * object returned must accurately reflect the actual type
282     * parameters used in the source code. The parameterized type
283     * representing the superclass is created if it had not been
284     * created before. See the declaration of {@link
285     * java.lang.reflect.ParameterizedType ParameterizedType} for the
286     * semantics of the creation process for parameterized types.  If
287     * this {@code Class} represents either the {@code Object}
288     * class, an interface, a primitive type, or void, then null is
289     * returned.  If this object represents an array class then the
290     * {@code Class} object representing the {@code Object} class is
291     * returned.
292     *
293     * @throws GenericSignatureFormatError if the generic
294     *     class signature does not conform to the format specified in the
295     *     Java Virtual Machine Specification, 3rd edition
296     * @throws TypeNotPresentException if the generic superclass
297     *     refers to a non-existent type declaration
298     * @throws MalformedParameterizedTypeException if the
299     *     generic superclass refers to a parameterized type that cannot be
300     *     instantiated  for any reason
301     * @return the superclass of the class represented by this object
302     * @since 1.5
303     */
304    public Type getGenericSuperclass() {
305        _throw();
306        return null;
307    }
308
309    /**
310     * Gets the package for this class.  The class loader of this class is used
311     * to find the package.  If the class was loaded by the bootstrap class
312     * loader the set of packages loaded from CLASSPATH is searched to find the
313     * package of the class. Null is returned if no package object was created
314     * by the class loader of this class.
315     *
316     * <p> Packages have attributes for versions and specifications only if the
317     * information was defined in the manifests that accompany the classes, and
318     * if the class loader created the package instance with the attributes
319     * from the manifest.
320     *
321     * @return the package of the class, or null if no package
322     *         information is available from the archive or codebase.
323     */
324    public Package getPackage() {
325        _throw();
326        return null;
327    }
328
329
330    /**
331     * Determines the interfaces implemented by the class or interface
332     * represented by this object.
333     *
334     * <p> If this object represents a class, the return value is an array
335     * containing objects representing all interfaces implemented by the
336     * class. The order of the interface objects in the array corresponds to
337     * the order of the interface names in the {@code implements} clause
338     * of the declaration of the class represented by this object. For
339     * example, given the declaration:
340     * <blockquote>
341     * {@code class Shimmer implements FloorWax, DessertTopping { ... }}
342     * </blockquote>
343     * suppose the value of {@code s} is an instance of
344     * {@code Shimmer}; the value of the expression:
345     * <blockquote>
346     * {@code s.getClass().getInterfaces()[0]}
347     * </blockquote>
348     * is the {@code Class} object that represents interface
349     * {@code FloorWax}; and the value of:
350     * <blockquote>
351     * {@code s.getClass().getInterfaces()[1]}
352     * </blockquote>
353     * is the {@code Class} object that represents interface
354     * {@code DessertTopping}.
355     *
356     * <p> If this object represents an interface, the array contains objects
357     * representing all interfaces extended by the interface. The order of the
358     * interface objects in the array corresponds to the order of the interface
359     * names in the {@code extends} clause of the declaration of the
360     * interface represented by this object.
361     *
362     * <p> If this object represents a class or interface that implements no
363     * interfaces, the method returns an array of length 0.
364     *
365     * <p> If this object represents a primitive type or void, the method
366     * returns an array of length 0.
367     *
368     * @return an array of interfaces implemented by this class.
369     */
370    public  Class[] getInterfaces(){
371        _throw();
372        return null;
373    }
374
375    /**
376     * Returns the {@code Class} representing the component type of an
377     * array.  If this class does not represent an array class this method
378     * returns null.
379     *
380     * @return the {@code Class} representing the component type of this
381     * class if this class is an array
382     * @see     java.lang.reflect.Array
383     * @since JDK1.1
384     */
385    public Class getComponentType(){
386        _throw();
387        return null;
388    }
389
390
391    /**
392     * Returns the Java language modifiers for this class or interface, encoded
393     * in an integer. The modifiers consist of the Java Virtual Machine's
394     * constants for {@code public}, {@code protected},
395     * {@code private}, {@code final}, {@code static},
396     * {@code abstract} and {@code interface}; they should be decoded
397     * using the methods of class {@code Modifier}.
398     *
399     * <p> If the underlying class is an array class, then its
400     * {@code public}, {@code private} and {@code protected}
401     * modifiers are the same as those of its component type.  If this
402     * {@code Class} represents a primitive type or void, its
403     * {@code public} modifier is always {@code true}, and its
404     * {@code protected} and {@code private} modifiers are always
405     * {@code false}. If this object represents an array class, a
406     * primitive type or void, then its {@code final} modifier is always
407     * {@code true} and its interface modifier is always
408     * {@code false}. The values of its other modifiers are not determined
409     * by this specification.
410     *
411     * <p> The modifier encodings are defined in <em>The Java Virtual Machine
412     * Specification</em>, table 4.1.
413     *
414     * @return the {@code int} representing the modifiers for this class
415     * @see     java.lang.reflect.Modifier
416     * @since JDK1.1
417     */
418    public int getModifiers() {
419        _throw();
420        return 0;
421    }
422
423
424    /**
425     * If the class or interface represented by this {@code Class} object
426     * is a member of another class, returns the {@code Class} object
427     * representing the class in which it was declared.  This method returns
428     * null if this class or interface is not a member of any other class.  If
429     * this {@code Class} object represents an array class, a primitive
430     * type, or void,then this method returns null.
431     *
432     * @return the declaring class for this class
433     * @since JDK1.1
434     */
435    public Class getDeclaringClass(){
436        _throw();
437        return null;
438    }
439
440    /**
441     * Returns an array containing {@code Class} objects representing all
442     * the public classes and interfaces that are members of the class
443     * represented by this {@code Class} object.  This includes public
444     * class and interface members inherited from superclasses and public class
445     * and interface members declared by the class.  This method returns an
446     * array of length 0 if this {@code Class} object has no public member
447     * classes or interfaces.  This method also returns an array of length 0 if
448     * this {@code Class} object represents a primitive type, an array
449     * class, or void.
450     *
451     * @return the array of {@code Class} objects representing the public
452     * members of this class
453     * @exception  SecurityException
454     *             If a security manager, <i>s</i>, is present and any of the
455     *             following conditions is met:
456     *
457     *             <ul>
458     *
459     *             <li> invocation of
460     *             {@link SecurityManager#checkMemberAccess
461     *             s.checkMemberAccess(this, Member.PUBLIC)} method
462     *             denies access to the classes within this class
463     *
464     *             <li> the caller's class loader is not the same as or an
465     *             ancestor of the class loader for the current class and
466     *             invocation of {@link SecurityManager#checkPackageAccess
467     *             s.checkPackageAccess()} denies access to the package
468     *             of this class
469     *
470     *             </ul>
471     *
472     * @since JDK1.1
473     */
474    public Class[] getClasses() {
475        _throw();
476        return null;
477    }
478
479
480    /**
481     * Returns an array containing {@code Field} objects reflecting all
482     * the accessible public fields of the class or interface represented by
483     * this {@code Class} object.  The elements in the array returned are
484     * not sorted and are not in any particular order.  This method returns an
485     * array of length 0 if the class or interface has no accessible public
486     * fields, or if it represents an array class, a primitive type, or void.
487     *
488     * <p> Specifically, if this {@code Class} object represents a class,
489     * this method returns the public fields of this class and of all its
490     * superclasses.  If this {@code Class} object represents an
491     * interface, this method returns the fields of this interface and of all
492     * its superinterfaces.
493     *
494     * <p> The implicit length field for array class is not reflected by this
495     * method. User code should use the methods of class {@code Array} to
496     * manipulate arrays.
497     *
498     * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.
499     *
500     * @return the array of {@code Field} objects representing the
501     * public fields
502     * @exception  SecurityException
503     *             If a security manager, <i>s</i>, is present and any of the
504     *             following conditions is met:
505     *
506     *             <ul>
507     *
508     *             <li> invocation of
509     *             {@link SecurityManager#checkMemberAccess
510     *             s.checkMemberAccess(this, Member.PUBLIC)} denies
511     *             access to the fields within this class
512     *
513     *             <li> the caller's class loader is not the same as or an
514     *             ancestor of the class loader for the current class and
515     *             invocation of {@link SecurityManager#checkPackageAccess
516     *             s.checkPackageAccess()} denies access to the package
517     *             of this class
518     *
519     *             </ul>
520     *
521     * @since JDK1.1
522     */
523    public Field[] getFields() throws SecurityException {
524        _throw();
525        return null;
526    }
527
528
529    /**
530     * Returns an array containing {@code Method} objects reflecting all
531     * the public <em>member</em> methods of the class or interface represented
532     * by this {@code Class} object, including those declared by the class
533     * or interface and those inherited from superclasses and
534     * superinterfaces.  Array classes return all the (public) member methods
535     * inherited from the {@code Object} class.  The elements in the array
536     * returned are not sorted and are not in any particular order.  This
537     * method returns an array of length 0 if this {@code Class} object
538     * represents a class or interface that has no public member methods, or if
539     * this {@code Class} object represents a primitive type or void.
540     *
541     * <p> The class initialization method {@code <clinit>} is not
542     * included in the returned array. If the class declares multiple public
543     * member methods with the same parameter types, they are all included in
544     * the returned array.
545     *
546     * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4.
547     *
548     * @return the array of {@code Method} objects representing the
549     * public methods of this class
550     * @exception  SecurityException
551     *             If a security manager, <i>s</i>, is present and any of the
552     *             following conditions is met:
553     *
554     *             <ul>
555     *
556     *             <li> invocation of
557     *             {@link SecurityManager#checkMemberAccess
558     *             s.checkMemberAccess(this, Member.PUBLIC)} denies
559     *             access to the methods within this class
560     *
561     *             <li> the caller's class loader is not the same as or an
562     *             ancestor of the class loader for the current class and
563     *             invocation of {@link SecurityManager#checkPackageAccess
564     *             s.checkPackageAccess()} denies access to the package
565     *             of this class
566     *
567     *             </ul>
568     *
569     * @since JDK1.1
570     */
571    public ASMMethod[] getMethods() throws SecurityException {
572        _throw();
573        return methods.entrySet().toArray(new ASMMethod[methods.size()]);
574    }
575
576
577    /**
578     * Returns an array containing {@code Constructor} objects reflecting
579     * all the public constructors of the class represented by this
580     * {@code Class} object.  An array of length 0 is returned if the
581     * class has no public constructors, or if the class is an array class, or
582     * if the class reflects a primitive type or void.
583     *
584     * Note that while this method returns an array of {@code
585     * Constructor<T>} objects (that is an array of constructors from
586     * this class), the return type of this method is {@code
587     * Constructor<?>[]} and <em>not</em> {@code Constructor<T>[]} as
588     * might be expected.  This less informative return type is
589     * necessary since after being returned from this method, the
590     * array could be modified to hold {@code Constructor} objects for
591     * different classes, which would violate the type guarantees of
592     * {@code Constructor<T>[]}.
593     *
594     * @return the array of {@code Constructor} objects representing the
595     *  public constructors of this class
596     * @exception  SecurityException
597     *             If a security manager, <i>s</i>, is present and any of the
598     *             following conditions is met:
599     *
600     *             <ul>
601     *
602     *             <li> invocation of
603     *             {@link SecurityManager#checkMemberAccess
604     *             s.checkMemberAccess(this, Member.PUBLIC)} denies
605     *             access to the constructors within this class
606     *
607     *             <li> the caller's class loader is not the same as or an
608     *             ancestor of the class loader for the current class and
609     *             invocation of {@link SecurityManager#checkPackageAccess
610     *             s.checkPackageAccess()} denies access to the package
611     *             of this class
612     *
613     *             </ul>
614     *
615     * @since JDK1.1
616     */
617    public Constructor[] getConstructors() throws SecurityException {
618        _throw();
619        return null;
620    }
621
622
623    /**
624     * Returns a {@code Field} object that reflects the specified public
625     * member field of the class or interface represented by this
626     * {@code Class} object. The {@code name} parameter is a
627     * {@code String} specifying the simple name of the desired field.
628     *
629     * <p> The field to be reflected is determined by the algorithm that
630     * follows.  Let C be the class represented by this object:
631     * <OL>
632     * <LI> If C declares a public field with the name specified, that is the
633     *      field to be reflected.</LI>
634     * <LI> If no field was found in step 1 above, this algorithm is applied
635     *      recursively to each direct superinterface of C. The direct
636     *      superinterfaces are searched in the order they were declared.</LI>
637     * <LI> If no field was found in steps 1 and 2 above, and C has a
638     *      superclass S, then this algorithm is invoked recursively upon S.
639     *      If C has no superclass, then a {@code NoSuchFieldException}
640     *      is thrown.</LI>
641     * </OL>
642     *
643     * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.
644     *
645     * @param name the field name
646     * @return  the {@code Field} object of this class specified by
647     * {@code name}
648     * @exception NoSuchFieldException if a field with the specified name is
649     *              not found.
650     * @exception NullPointerException if {@code name} is {@code null}
651     * @exception  SecurityException
652     *             If a security manager, <i>s</i>, is present and any of the
653     *             following conditions is met:
654     *
655     *             <ul>
656     *
657     *             <li> invocation of
658     *             {@link SecurityManager#checkMemberAccess
659     *             s.checkMemberAccess(this, Member.PUBLIC)} denies
660     *             access to the field
661     *
662     *             <li> the caller's class loader is not the same as or an
663     *             ancestor of the class loader for the current class and
664     *             invocation of {@link SecurityManager#checkPackageAccess
665     *             s.checkPackageAccess()} denies access to the package
666     *             of this class
667     *
668     *             </ul>
669     *
670     * @since JDK1.1
671     */
672    public Field getField(String name) throws NoSuchFieldException, SecurityException {
673        _throw();
674        return null;
675    }
676
677
678    /**
679     * Returns a {@code Method} object that reflects the specified public
680     * member method of the class or interface represented by this
681     * {@code Class} object. The {@code name} parameter is a
682     * {@code String} specifying the simple name of the desired method. The
683     * {@code parameterTypes} parameter is an array of {@code Class}
684     * objects that identify the method's formal parameter types, in declared
685     * order. If {@code parameterTypes} is {@code null}, it is
686     * treated as if it were an empty array.
687     *
688     * <p> If the {@code name} is "{@code <init>};"or "{@code <clinit>}" a
689     * {@code NoSuchMethodException} is raised. Otherwise, the method to
690     * be reflected is determined by the algorithm that follows.  Let C be the
691     * class represented by this object:
692     * <OL>
693     * <LI> C is searched for any <I>matching methods</I>. If no matching
694     *      method is found, the algorithm of step 1 is invoked recursively on
695     *      the superclass of C.</LI>
696     * <LI> If no method was found in step 1 above, the superinterfaces of C
697     *      are searched for a matching method. If any such method is found, it
698     *      is reflected.</LI>
699     * </OL>
700     *
701     * To find a matching method in a class C:&nbsp; If C declares exactly one
702     * public method with the specified name and exactly the same formal
703     * parameter types, that is the method reflected. If more than one such
704     * method is found in C, and one of these methods has a return type that is
705     * more specific than any of the others, that method is reflected;
706     * otherwise one of the methods is chosen arbitrarily.
707     *
708     * <p>Note that there may be more than one matching method in a
709     * class because while the Java language forbids a class to
710     * declare multiple methods with the same signature but different
711     * return types, the Java virtual machine does not.  This
712     * increased flexibility in the virtual machine can be used to
713     * implement various language features.  For example, covariant
714     * returns can be implemented with {@linkplain
715     * java.lang.reflect.Method#isBridge bridge methods}; the bridge
716     * method and the method being overridden would have the same
717     * signature but different return types.
718     *
719     * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4.
720     *
721     * @param name the name of the method
722     * @param parameterTypes the list of parameters
723     * @return the {@code Method} object that matches the specified
724     * {@code name} and {@code parameterTypes}
725     * @exception NoSuchMethodException if a matching method is not found
726     *            or if the name is "&lt;init&gt;"or "&lt;clinit&gt;".
727     * @exception NullPointerException if {@code name} is {@code null}
728     * @exception  SecurityException
729     *             If a security manager, <i>s</i>, is present and any of the
730     *             following conditions is met:
731     *
732     *             <ul>
733     *
734     *             <li> invocation of
735     *             {@link SecurityManager#checkMemberAccess
736     *             s.checkMemberAccess(this, Member.PUBLIC)} denies
737     *             access to the method
738     *
739     *             <li> the caller's class loader is not the same as or an
740     *             ancestor of the class loader for the current class and
741     *             invocation of {@link SecurityManager#checkPackageAccess
742     *             s.checkPackageAccess()} denies access to the package
743     *             of this class
744     *
745     *             </ul>
746     *
747     * @since JDK1.1
748     */
749    public Method getMethod(String name, Class... parameterTypes) throws NoSuchMethodException, SecurityException {
750        _throw();
751        return null;
752    }
753
754
755    /**
756     * Returns a {@code Constructor} object that reflects the specified
757     * public constructor of the class represented by this {@code Class}
758     * object. The {@code parameterTypes} parameter is an array of
759     * {@code Class} objects that identify the constructor's formal
760     * parameter types, in declared order.
761     *
762     * If this {@code Class} object represents an inner class
763     * declared in a non-static context, the formal parameter types
764     * include the explicit enclosing instance as the first parameter.
765     *
766     * <p> The constructor to reflect is the public constructor of the class
767     * represented by this {@code Class} object whose formal parameter
768     * types match those specified by {@code parameterTypes}.
769     *
770     * @param parameterTypes the parameter array
771     * @return the {@code Constructor} object of the public constructor that
772     * matches the specified {@code parameterTypes}
773     * @exception NoSuchMethodException if a matching method is not found.
774     * @exception  SecurityException
775     *             If a security manager, <i>s</i>, is present and any of the
776     *             following conditions is met:
777     *
778     *             <ul>
779     *
780     *             <li> invocation of
781     *             {@link SecurityManager#checkMemberAccess
782     *             s.checkMemberAccess(this, Member.PUBLIC)} denies
783     *             access to the constructor
784     *
785     *             <li> the caller's class loader is not the same as or an
786     *             ancestor of the class loader for the current class and
787     *             invocation of {@link SecurityManager#checkPackageAccess
788     *             s.checkPackageAccess()} denies access to the package
789     *             of this class
790     *
791     *             </ul>
792     *
793     * @since JDK1.1
794     */
795    public Constructor getConstructor(Class... parameterTypes) throws NoSuchMethodException, SecurityException {
796        _throw();
797        return null;
798    }
799
800
801    /**
802     * Returns an array of {@code Class} objects reflecting all the
803     * classes and interfaces declared as members of the class represented by
804     * this {@code Class} object. This includes public, protected, default
805     * (package) access, and private classes and interfaces declared by the
806     * class, but excludes inherited classes and interfaces.  This method
807     * returns an array of length 0 if the class declares no classes or
808     * interfaces as members, or if this {@code Class} object represents a
809     * primitive type, an array class, or void.
810     *
811     * @return the array of {@code Class} objects representing all the
812     * declared members of this class
813     * @exception  SecurityException
814     *             If a security manager, <i>s</i>, is present and any of the
815     *             following conditions is met:
816     *
817     *             <ul>
818     *
819     *             <li> invocation of
820     *             {@link SecurityManager#checkMemberAccess
821     *             s.checkMemberAccess(this, Member.DECLARED)} denies
822     *             access to the declared classes within this class
823     *
824     *             <li> the caller's class loader is not the same as or an
825     *             ancestor of the class loader for the current class and
826     *             invocation of {@link SecurityManager#checkPackageAccess
827     *             s.checkPackageAccess()} denies access to the package
828     *             of this class
829     *
830     *             </ul>
831     *
832     * @since JDK1.1
833     */
834    public Class[] getDeclaredClasses() throws SecurityException {
835        _throw();
836        return null;
837    }
838
839
840    /**
841     * Returns an array of {@code Field} objects reflecting all the fields
842     * declared by the class or interface represented by this
843     * {@code Class} object. This includes public, protected, default
844     * (package) access, and private fields, but excludes inherited fields.
845     * The elements in the array returned are not sorted and are not in any
846     * particular order.  This method returns an array of length 0 if the class
847     * or interface declares no fields, or if this {@code Class} object
848     * represents a primitive type, an array class, or void.
849     *
850     * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.
851     *
852     * @return    the array of {@code Field} objects representing all the
853     * declared fields of this class
854     * @exception  SecurityException
855     *             If a security manager, <i>s</i>, is present and any of the
856     *             following conditions is met:
857     *
858     *             <ul>
859     *
860     *             <li> invocation of
861     *             {@link SecurityManager#checkMemberAccess
862     *             s.checkMemberAccess(this, Member.DECLARED)} denies
863     *             access to the declared fields within this class
864     *
865     *             <li> the caller's class loader is not the same as or an
866     *             ancestor of the class loader for the current class and
867     *             invocation of {@link SecurityManager#checkPackageAccess
868     *             s.checkPackageAccess()} denies access to the package
869     *             of this class
870     *
871     *             </ul>
872     *
873     * @since JDK1.1
874     */
875    public Field[] getDeclaredFields() throws SecurityException {
876        _throw();
877        return null;
878    }
879
880
881    /**
882     * Returns an array of {@code Method} objects reflecting all the
883     * methods declared by the class or interface represented by this
884     * {@code Class} object. This includes public, protected, default
885     * (package) access, and private methods, but excludes inherited methods.
886     * The elements in the array returned are not sorted and are not in any
887     * particular order.  This method returns an array of length 0 if the class
888     * or interface declares no methods, or if this {@code Class} object
889     * represents a primitive type, an array class, or void.  The class
890     * initialization method {@code <clinit>} is not included in the
891     * returned array. If the class declares multiple public member methods
892     * with the same parameter types, they are all included in the returned
893     * array.
894     *
895     * <p> See <em>The Java Language Specification</em>, section 8.2.
896     *
897     * @return    the array of {@code Method} objects representing all the
898     * declared methods of this class
899     * @exception  SecurityException
900     *             If a security manager, <i>s</i>, is present and any of the
901     *             following conditions is met:
902     *
903     *             <ul>
904     *
905     *             <li> invocation of
906     *             {@link SecurityManager#checkMemberAccess
907     *             s.checkMemberAccess(this, Member.DECLARED)} denies
908     *             access to the declared methods within this class
909     *
910     *             <li> the caller's class loader is not the same as or an
911     *             ancestor of the class loader for the current class and
912     *             invocation of {@link SecurityManager#checkPackageAccess
913     *             s.checkPackageAccess()} denies access to the package
914     *             of this class
915     *
916     *             </ul>
917     *
918     * @since JDK1.1
919     */
920    public Method[] getDeclaredMethods() throws SecurityException {
921        _throw();
922        return null;
923    }
924
925
926    /**
927     * Returns an array of {@code Constructor} objects reflecting all the
928     * constructors declared by the class represented by this
929     * {@code Class} object. These are public, protected, default
930     * (package) access, and private constructors.  The elements in the array
931     * returned are not sorted and are not in any particular order.  If the
932     * class has a default constructor, it is included in the returned array.
933     * This method returns an array of length 0 if this {@code Class}
934     * object represents an interface, a primitive type, an array class, or
935     * void.
936     *
937     * <p> See <em>The Java Language Specification</em>, section 8.2.
938     *
939     * @return    the array of {@code Constructor} objects representing all the
940     * declared constructors of this class
941     * @exception  SecurityException
942     *             If a security manager, <i>s</i>, is present and any of the
943     *             following conditions is met:
944     *
945     *             <ul>
946     *
947     *             <li> invocation of
948     *             {@link SecurityManager#checkMemberAccess
949     *             s.checkMemberAccess(this, Member.DECLARED)} denies
950     *             access to the declared constructors within this class
951     *
952     *             <li> the caller's class loader is not the same as or an
953     *             ancestor of the class loader for the current class and
954     *             invocation of {@link SecurityManager#checkPackageAccess
955     *             s.checkPackageAccess()} denies access to the package
956     *             of this class
957     *
958     *             </ul>
959     *
960     * @since JDK1.1
961     */
962    public Constructor[] getDeclaredConstructors() throws SecurityException {
963        _throw();
964        return null;
965    }
966
967
968    /**
969     * Returns a {@code Field} object that reflects the specified declared
970     * field of the class or interface represented by this {@code Class}
971     * object. The {@code name} parameter is a {@code String} that
972     * specifies the simple name of the desired field.  Note that this method
973     * will not reflect the {@code length} field of an array class.
974     *
975     * @param name the name of the field
976     * @return the {@code Field} object for the specified field in this
977     * class
978     * @exception NoSuchFieldException if a field with the specified name is
979     *              not found.
980     * @exception NullPointerException if {@code name} is {@code null}
981     * @exception  SecurityException
982     *             If a security manager, <i>s</i>, is present and any of the
983     *             following conditions is met:
984     *
985     *             <ul>
986     *
987     *             <li> invocation of
988     *             {@link SecurityManager#checkMemberAccess
989     *             s.checkMemberAccess(this, Member.DECLARED)} denies
990     *             access to the declared field
991     *
992     *             <li> the caller's class loader is not the same as or an
993     *             ancestor of the class loader for the current class and
994     *             invocation of {@link SecurityManager#checkPackageAccess
995     *             s.checkPackageAccess()} denies access to the package
996     *             of this class
997     *
998     *             </ul>
999     *
1000     * @since JDK1.1
1001     */
1002    public Field getDeclaredField(String name)
1003        throws NoSuchFieldException, SecurityException {
1004        _throw();
1005        return null;
1006    }
1007
1008
1009    /**
1010     * Returns a {@code Method} object that reflects the specified
1011     * declared method of the class or interface represented by this
1012     * {@code Class} object. The {@code name} parameter is a
1013     * {@code String} that specifies the simple name of the desired
1014     * method, and the {@code parameterTypes} parameter is an array of
1015     * {@code Class} objects that identify the method's formal parameter
1016     * types, in declared order.  If more than one method with the same
1017     * parameter types is declared in a class, and one of these methods has a
1018     * return type that is more specific than any of the others, that method is
1019     * returned; otherwise one of the methods is chosen arbitrarily.  If the
1020     * name is "&lt;init&gt;"or "&lt;clinit&gt;" a {@code NoSuchMethodException}
1021     * is raised.
1022     *
1023     * @param name the name of the method
1024     * @param parameterTypes the parameter array
1025     * @return    the {@code Method} object for the method of this class
1026     * matching the specified name and parameters
1027     * @exception NoSuchMethodException if a matching method is not found.
1028     * @exception NullPointerException if {@code name} is {@code null}
1029     * @exception  SecurityException
1030     *             If a security manager, <i>s</i>, is present and any of the
1031     *             following conditions is met:
1032     *
1033     *             <ul>
1034     *
1035     *             <li> invocation of
1036     *             {@link SecurityManager#checkMemberAccess
1037     *             s.checkMemberAccess(this, Member.DECLARED)} denies
1038     *             access to the declared method
1039     *
1040     *             <li> the caller's class loader is not the same as or an
1041     *             ancestor of the class loader for the current class and
1042     *             invocation of {@link SecurityManager#checkPackageAccess
1043     *             s.checkPackageAccess()} denies access to the package
1044     *             of this class
1045     *
1046     *             </ul>
1047     *
1048     * @since JDK1.1
1049     */
1050    public Method getDeclaredMethod(String name, Class... parameterTypes)
1051        throws NoSuchMethodException, SecurityException {
1052        _throw();
1053        return null;
1054    }
1055
1056
1057    /**
1058     * Returns a {@code Constructor} object that reflects the specified
1059     * constructor of the class or interface represented by this
1060     * {@code Class} object.  The {@code parameterTypes} parameter is
1061     * an array of {@code Class} objects that identify the constructor's
1062     * formal parameter types, in declared order.
1063     *
1064     * If this {@code Class} object represents an inner class
1065     * declared in a non-static context, the formal parameter types
1066     * include the explicit enclosing instance as the first parameter.
1067     *
1068     * @param parameterTypes the parameter array
1069     * @return    The {@code Constructor} object for the constructor with the
1070     * specified parameter list
1071     * @exception NoSuchMethodException if a matching method is not found.
1072     * @exception  SecurityException
1073     *             If a security manager, <i>s</i>, is present and any of the
1074     *             following conditions is met:
1075     *
1076     *             <ul>
1077     *
1078     *             <li> invocation of
1079     *             {@link SecurityManager#checkMemberAccess
1080     *             s.checkMemberAccess(this, Member.DECLARED)} denies
1081     *             access to the declared constructor
1082     *
1083     *             <li> the caller's class loader is not the same as or an
1084     *             ancestor of the class loader for the current class and
1085     *             invocation of {@link SecurityManager#checkPackageAccess
1086     *             s.checkPackageAccess()} denies access to the package
1087     *             of this class
1088     *
1089     *             </ul>
1090     *
1091     * @since JDK1.1
1092     */
1093    public Constructor getDeclaredConstructor(Class... parameterTypes)
1094        throws NoSuchMethodException, SecurityException {
1095        _throw();
1096        return null;
1097    }
1098
1099    /**
1100     * Finds a resource with a given name.  The rules for searching resources
1101     * associated with a given class are implemented by the defining
1102     * {@linkplain ClassLoader class loader} of the class.  This method
1103     * delegates to this object's class loader.  If this object was loaded by
1104     * the bootstrap class loader, the method delegates to {@link
1105     * ClassLoader#getSystemResourceAsStream}.
1106     *
1107     * <p> Before delegation, an absolute resource name is constructed from the
1108     * given resource name using this algorithm:
1109     *
1110     * <ul>
1111     *
1112     * <li> If the {@code name} begins with a {@code '/'}
1113     * (<tt>'&#92;u002f'</tt>), then the absolute name of the resource is the
1114     * portion of the {@code name} following the {@code '/'}.
1115     *
1116     * <li> Otherwise, the absolute name is of the following form:
1117     *
1118     * <blockquote>
1119     *   {@code modified_package_name/name}
1120     * </blockquote>
1121     *
1122     * <p> Where the {@code modified_package_name} is the package name of this
1123     * object with {@code '/'} substituted for {@code '.'}
1124     * (<tt>'&#92;u002e'</tt>).
1125     *
1126     * </ul>
1127     *
1128     * @param  name name of the desired resource
1129     * @return      A {@link java.io.InputStream} object or {@code null} if
1130     *              no resource with this name is found
1131     * @throws  NullPointerException If {@code name} is {@code null}
1132     * @since  JDK1.1
1133     */
1134     public InputStream getResourceAsStream(String name) {
1135         _throw();
1136        return null;
1137    }
1138
1139    /**
1140     * Finds a resource with a given name.  The rules for searching resources
1141     * associated with a given class are implemented by the defining
1142     * {@linkplain ClassLoader class loader} of the class.  This method
1143     * delegates to this object's class loader.  If this object was loaded by
1144     * the bootstrap class loader, the method delegates to {@link
1145     * ClassLoader#getSystemResource}.
1146     *
1147     * <p> Before delegation, an absolute resource name is constructed from the
1148     * given resource name using this algorithm:
1149     *
1150     * <ul>
1151     *
1152     * <li> If the {@code name} begins with a {@code '/'}
1153     * (<tt>'&#92;u002f'</tt>), then the absolute name of the resource is the
1154     * portion of the {@code name} following the {@code '/'}.
1155     *
1156     * <li> Otherwise, the absolute name is of the following form:
1157     *
1158     * <blockquote>
1159     *   {@code modified_package_name/name}
1160     * </blockquote>
1161     *
1162     * <p> Where the {@code modified_package_name} is the package name of this
1163     * object with {@code '/'} substituted for {@code '.'}
1164     * (<tt>'&#92;u002e'</tt>).
1165     *
1166     * </ul>
1167     *
1168     * @param  name name of the desired resource
1169     * @return      A  {@link java.net.URL} object or {@code null} if no
1170     *              resource with this name is found
1171     * @since  JDK1.1
1172     */
1173    public java.net.URL getResource(String name) {
1174        _throw();
1175        return null;
1176    }
1177
1178
1179    private static void _throw() {
1180                throw new RuntimeException("not supported!");
1181        }
1182}