1 // Method.java - Represent method of class or interface.
3 /* Copyright (C) 1998, 1999 Cygnus Solutions
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11 package java
.lang
.reflect
;
14 * @author Tom Tromey <tromey@cygnus.com>
15 * @date December 12, 1998
17 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
18 * "The Java Language Specification", ISBN 0-201-63451-1
19 * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
20 * Status: Incomplete: needs a private constructor, and
21 * invoke() needs to be finished.
24 public final class Method
extends AccessibleObject
implements Member
26 public boolean equals (Object obj
)
28 if (! (obj
instanceof Method
))
30 Method m
= (Method
) obj
;
31 return declaringClass
== m
.declaringClass
&& offset
== m
.offset
;
34 public Class
getDeclaringClass ()
36 return declaringClass
;
39 public Class
[] getExceptionTypes ()
41 return (Class
[]) exception_types
.clone();
44 public native int getModifiers ();
46 public native String
getName ();
48 private native void getType ();
50 public Class
[] getParameterTypes ()
52 if (parameter_types
== null)
54 return (Class
[]) parameter_types
.clone();
57 public Class
getReturnType ()
59 if (return_type
== null)
64 public int hashCode ()
67 return name
.hashCode() + declaringClass
.getName().hashCode();
70 public native Object
invoke (Object obj
, Object
[] args
)
71 throws IllegalAccessException
, IllegalArgumentException
,
72 InvocationTargetException
;
74 public String
toString ()
76 StringBuffer b
= new StringBuffer ();
77 b
.append(Modifier
.toString(getModifiers()));
79 b
.append(return_type
.toString());
81 b
.append(declaringClass
.toString());
85 for (int i
= 0; i
< parameter_types
.length
; ++i
)
87 b
.append(parameter_types
[i
].toString());
88 if (i
< parameter_types
.length
- 1)
92 if (exception_types
.length
> 0)
95 for (int i
= 0; i
< exception_types
.length
; ++i
)
97 b
.append(exception_types
[i
].toString());
98 if (i
< exception_types
.length
- 1)
110 private Class declaringClass
;
113 private Class
[] exception_types
;
114 // Name cache. (Initially null.)
117 private Class
[] parameter_types
;
119 private Class return_type
;
121 // Offset in bytes from the start of declaringClass's methods array.