1 // Constructor.java - Represents a constructor for a class.
3 /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
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 * newInstance() needs to be written.
24 public final class Constructor
extends AccessibleObject
implements Member
26 public boolean equals (Object obj
)
28 if (! (obj
instanceof Constructor
))
30 Constructor c
= (Constructor
) obj
;
31 return declaringClass
== c
.declaringClass
&& offset
== c
.offset
;
34 public Class
getDeclaringClass ()
36 return declaringClass
;
39 public Class
[] getExceptionTypes ()
41 if (exception_types
== null)
43 return (Class
[]) exception_types
.clone();
46 public native int getModifiers ();
48 public String
getName ()
50 return declaringClass
.getName();
53 public Class
[] getParameterTypes ()
55 if (parameter_types
== null)
57 return (Class
[]) parameter_types
.clone();
60 public int hashCode ()
63 return getName().hashCode() + declaringClass
.getName().hashCode();
66 // Update cached values from method descriptor in class.
67 private native void getType ();
69 public native Object
newInstance (Object
[] args
)
70 throws InstantiationException
, IllegalAccessException
,
71 IllegalArgumentException
, InvocationTargetException
;
73 public String
toString ()
75 if (parameter_types
== null)
77 StringBuffer b
= new StringBuffer ();
78 Modifier
.toString(getModifiers(), b
);
80 Method
.appendClassName (b
, declaringClass
);
82 for (int i
= 0; i
< parameter_types
.length
; ++i
)
84 Method
.appendClassName (b
, parameter_types
[i
]);
85 if (i
< parameter_types
.length
- 1)
92 // Can't create these.
93 private Constructor ()
98 private Class declaringClass
;
101 private Class
[] exception_types
;
103 private Class
[] parameter_types
;
105 // Offset in bytes from the start of declaringClass's methods array.