JavaParserTests.st
author Claus Gittinger <cg@exept.de>
Thu, 24 Nov 2011 13:02:05 +0100
changeset 2330 b189800c0d92
parent 2152 1cbdfbcc685c
permissions -rw-r--r--
automatically generated by browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     1
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     3
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     4
                            SWING Research Group, Czech Technical University in Prague
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     6
 Parts of the code written by Claus Gittinger are under following
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     7
 license:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     8
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    14
 hereby transferred.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    15
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    16
 Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    17
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    18
 Permission is hereby granted, free of charge, to any person
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    19
 obtaining a copy of this software and associated documentation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    20
 files (the 'Software'), to deal in the Software without
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    21
 restriction, including without limitation the rights to use,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    22
 copy, modify, merge, publish, distribute, sublicense, and/or sell
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    23
 copies of the Software, and to permit persons to whom the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    24
 Software is furnished to do so, subject to the following
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    25
 conditions:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    26
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    27
 The above copyright notice and this permission notice shall be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    28
 included in all copies or substantial portions of the Software.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    29
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    30
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    31
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    32
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    33
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    34
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    35
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    36
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    37
 OTHER DEALINGS IN THE SOFTWARE.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    38
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    39
 [1] Code written at SWING Research Group contain a signature
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    40
     of one of the above copright owners.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    41
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    42
"{ Package: 'stx:libjava' }"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    43
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    44
JavaParserTestCase subclass:#JavaParserTests
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    45
	instanceVariableNames:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    46
	classVariableNames:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    47
	poolDictionaries:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    48
	category:'Languages-Java-Tests'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    49
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    50
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    51
!JavaParserTests class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    52
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    53
copyright
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    54
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    55
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    56
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    57
                            SWING Research Group, Czech Technical University in Prague
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    58
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    59
 Parts of the code written by Claus Gittinger are under following
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    60
 license:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    61
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    62
 This software is furnished under a license and may be used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    63
 only in accordance with the terms of that license and with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    64
 inclusion of the above copyright notice.   This software may not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    65
 be provided or otherwise made available to, or used by, any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    66
 other person.  No title to or ownership of the software is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    67
 hereby transferred.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    68
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    69
 Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    70
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    71
 Permission is hereby granted, free of charge, to any person
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    72
 obtaining a copy of this software and associated documentation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    73
 files (the 'Software'), to deal in the Software without
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    74
 restriction, including without limitation the rights to use,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    75
 copy, modify, merge, publish, distribute, sublicense, and/or sell
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    76
 copies of the Software, and to permit persons to whom the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    77
 Software is furnished to do so, subject to the following
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    78
 conditions:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    79
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    80
 The above copyright notice and this permission notice shall be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    81
 included in all copies or substantial portions of the Software.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    82
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    83
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    84
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    85
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    86
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    87
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    88
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    89
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    90
 OTHER DEALINGS IN THE SOFTWARE.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    91
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    92
 [1] Code written at SWING Research Group contain a signature
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    93
     of one of the above copright owners.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    94
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    95
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    96
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    97
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    98
!JavaParserTests methodsFor:'arguments'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    99
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   100
testMethodWithArgs
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   101
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   102
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   103
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   104
			public void fooMethod(Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   105
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   106
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   107
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   108
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   109
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   110
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   111
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   112
testMethodWithArgs2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   113
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   114
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   115
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   116
			public void fooMethod(Object o, Object o2)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   117
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   118
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   119
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   120
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   121
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   122
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   123
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   124
testMethodWithArgs3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   125
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   126
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   127
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   128
			public void fooMethod(int i)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   129
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   130
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   131
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   132
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   133
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   134
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   135
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   136
testMethodWithArgs4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   137
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   138
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   139
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   140
			public void fooMethod(int i, Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   141
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   142
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   143
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   144
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   145
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   146
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   147
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   148
testMethodWithArgs5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   149
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   150
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   151
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   152
			public void fooMethod(final int i, Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   153
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   154
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   155
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   156
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   157
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   158
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   159
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   160
testMethodWithArgs6
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   161
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   162
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   163
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   164
			public void fooMethod(final int i, final Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   165
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   166
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   167
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   168
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   169
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   170
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   171
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   172
testMethodWithArgs7
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   173
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   174
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   175
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   176
			public void fooMethod(java.lang.Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   177
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   178
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   179
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   180
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   181
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   182
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   183
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   184
testMethodWithArgs8
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   185
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   186
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   187
			public void fooMethod(int ... numbers)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   188
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   189
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   190
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   191
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   192
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   193
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   194
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   195
testMethodWithArgs9
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   196
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   197
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   198
			public void fooMethod(Object<T> ... numbers)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   199
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   200
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   201
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   202
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   203
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   204
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   205
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   206
testMethodWithArrayArgs
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   207
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   208
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   209
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   210
			public void fooMethod(Object[] o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   211
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   212
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   213
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   214
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   215
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   216
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   217
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   218
testMethodWithArrayArgs2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   219
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   220
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   221
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   222
			public void fooMethod(int[] o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   223
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   224
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   225
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   226
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   227
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   228
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   229
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   230
!JavaParserTests methodsFor:'classOrInterface'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   231
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   232
testClassWithComment
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   233
        ^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   234
// this is one line comment
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   235
public class Object {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   236
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   237
        '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   238
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   239
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   240
testClassWithComment2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   241
        ^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   242
// this is one line comment
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   243
public class Object {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   244
        // this is one line comment
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   245
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   246
'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   247
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   248
    "Modified: / 29-12-2010 / 20:28:27 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   249
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   250
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   251
testClassWithComment3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   252
        ^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   253
public class Object {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   254
        // this is one line comment
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   255
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   256
'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   257
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   258
    "Modified: / 29-12-2010 / 20:28:40 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   259
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   260
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   261
testClassWithJavadoc
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   262
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   263
		/** this is class javadoc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   264
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   265
			public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   266
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   267
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   268
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   269
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   270
testClassWithJavadoc2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   271
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   272
/*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   273
 * Possible end/of javadoc?
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   274
 */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   275
public class Object {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   276
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   277
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   278
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   279
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   280
testClassWithStaticInitializer
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   281
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   282
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   283
			int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   284
			
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   285
			static { 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   286
				//cokoli
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   287
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   288
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   289
			
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   290
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   291
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   292
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   293
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   294
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   295
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   296
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   297
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   298
testClassWithStaticInitializer2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   299
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   300
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   301
			static { 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   302
				//cokoli
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   303
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   304
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   305
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   306
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   307
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   308
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   309
testClassWithStaticInitializer3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   310
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   311
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   312
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   313
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   314
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   315
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   316
			static { 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   317
				//cokoli
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   318
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   319
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   320
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   321
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   322
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   323
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   324
testEmptyAbstractClass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   325
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   326
		public abstract class Foo {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   327
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   328
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   329
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   330
testEmptyClass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   331
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   332
		public class Foo {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   333
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   334
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   335
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   336
testEmptyStatement
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   337
	^ self
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   338
		assertParse:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   339
			'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   340
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   341
			;;;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   342
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   343
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   344
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   345
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   346
testFinalClass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   347
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   348
		public final class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   349
			public Foo fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   350
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   351
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   352
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   353
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   354
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   355
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   356
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   357
testFoo
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   358
	self assert: true.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   359
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   360
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   361
testGenericClass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   362
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   363
		public class Foo<T> {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   364
			public T fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   365
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   366
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   367
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   368
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   369
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   370
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   371
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   372
testGenericClass2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   373
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   374
		public class Foo<T extends Foo> {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   375
			public T fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   376
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   377
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   378
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   379
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   380
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   381
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   382
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   383
testHeader
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   384
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   385
		package a.b.c;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   386
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   387
		import a.b.*;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   388
		import c.d.*;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   389
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   390
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   391
			public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   392
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   393
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   394
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   395
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   396
testHeader2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   397
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   398
		package a.b.c;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   399
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   400
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   401
			public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   402
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   403
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   404
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   405
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   406
testHeader3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   407
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   408
		import a.b.c;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   409
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   410
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   411
			public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   412
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   413
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   414
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   415
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   416
testHeader4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   417
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   418
		/* some doc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   419
		package a.b;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   420
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   421
		import a.b.c;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   422
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   423
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   424
			public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   425
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   426
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   427
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   428
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   429
testHeader5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   430
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   431
		/* some doc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   432
		package a.b;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   433
		/* another doc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   434
		import a.b.c;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   435
		/* ane another doc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   436
		/** class javadoc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   437
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   438
			public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   439
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   440
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   441
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   442
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   443
testHeader6
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   444
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   445
/*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   446
 * simple doc
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   447
 */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   448
public class Object {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   449
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   450
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   451
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   452
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   453
testHeader7
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   454
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   455
/*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   456
 * Copyright (c) 2006, Oracle and/or its affiliates.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   457
 */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   458
public class Object {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   459
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   460
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   461
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   462
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   463
testInnerClass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   464
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   465
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   466
			private class A
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   467
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   468
				public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   469
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   470
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   471
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   472
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   473
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   474
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   475
testInnerClass2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   476
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   477
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   478
			private class A
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   479
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   480
				public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   481
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   482
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   483
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   484
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   485
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   486
testInnerClass3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   487
	^ self
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   488
		assertParse:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   489
			'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   490
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   491
			private class A
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   492
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   493
				public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   494
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   495
			
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   496
			private int foo2() {int i = 9;}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   497
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   498
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   499
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   500
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   501
testInnerClass4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   502
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   503
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   504
			public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   505
			
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   506
			/** class javadoc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   507
			private class A
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   508
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   509
				/* comment */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   510
				public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   511
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   512
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   513
			/**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   514
			 * javadoc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   515
			private int foo2() {int i = 9;}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   516
			/**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   517
			 * javadoc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   518
			private int foo2() {int i = 9;}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   519
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   520
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   521
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   522
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   523
testInnerClass5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   524
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   525
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   526
			private class A
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   527
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   528
				public void foo() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   529
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   530
			int i;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   531
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   532
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   533
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   534
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   535
testInterface1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   536
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   537
public interface MyVisitor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   538
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   539
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   540
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   541
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   542
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   543
testInterface2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   544
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   545
public interface Visitor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   546
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   547
	public void process(Circle c);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   548
	public void process(Square s);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   549
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   550
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   551
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   552
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   553
testInterface3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   554
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   555
public interface MyVisitor extends Visitor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   556
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   557
	public void foo();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   558
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   559
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   560
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   561
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   562
testInterface4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   563
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   564
public interface MyVisitor extends Visitor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   565
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   566
	public void foo() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   567
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   568
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   569
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   570
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   571
testInterface5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   572
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   573
public class MyVisitor implements Visitor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   574
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   575
	public void foo() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   576
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   577
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   578
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   579
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   580
testInterface6
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   581
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   582
public class MyVisitor implements Visitor, Iterator<Foo>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   583
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   584
	public void foo() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   585
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   586
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   587
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   588
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   589
testSubclass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   590
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   591
public class MyVisitor extends Visitor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   592
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   593
	public void foo() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   594
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   595
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   596
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   597
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   598
testSubclass2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   599
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   600
public class MyVisitor extends ArrayList<Foo>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   601
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   602
	public void foo() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   603
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   604
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   605
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   606
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   607
!JavaParserTests methodsFor:'fields'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   608
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   609
testClassWithFields
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   610
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   611
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   612
			int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   613
			
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   614
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   615
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   616
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   617
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   618
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   619
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   620
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   621
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   622
testClassWithFields2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   623
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   624
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   625
			int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   626
			private Object[] o = new Array[3];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   627
			
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   628
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   629
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   630
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   631
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   632
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   633
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   634
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   635
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   636
testClassWithFields3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   637
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   638
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   639
			public static int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   640
			
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   641
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   642
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   643
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   644
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   645
			private Object[] o = new Array[3];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   646
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   647
			public void fooMethod2()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   648
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   649
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   650
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   651
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   652
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   653
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   654
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   655
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   656
testClassWithFields4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   657
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   658
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   659
			private List<Foo> l = new ArrayList<Foo>();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   660
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   661
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   662
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   663
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   664
!JavaParserTests methodsFor:'methods'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   665
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   666
testAbstractMethod
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   667
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   668
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   669
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   670
			public abstract void fooMethod();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   671
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   672
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   673
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   674
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   675
testAbstractMethod2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   676
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   677
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   678
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   679
			public abstract void fooMethod();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   680
			public abstract void fooMethod2();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   681
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   682
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   683
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   684
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   685
testAbstractMethod3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   686
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   687
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   688
			int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   689
			/** javadoc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   690
			public abstract void fooMethod();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   691
			/* another javadoc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   692
			public abstract void fooMethod2();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   693
			
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   694
			public void method() {int b = 3;}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   695
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   696
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   697
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   698
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   699
testAnnotation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   700
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   701
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   702
		     @Override
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   703
			public void fooMethod() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   704
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   705
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   706
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   707
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   708
testAnnotation2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   709
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   710
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   711
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   712
			public @Interface void fooMethod() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   713
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   714
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   715
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   716
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   717
testAnnotation3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   718
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   719
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   720
			@Test
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   721
			public @Interface void fooMethod() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   722
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   723
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   724
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   725
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   726
testClassWithMethod
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   727
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   728
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   729
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   730
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   731
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   732
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   733
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   734
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   735
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   736
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   737
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   738
testClassWithMethod10
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   739
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   740
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   741
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   742
			public java.lang.Object fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   743
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   744
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   745
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   746
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   747
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   748
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   749
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   750
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   751
testClassWithMethod11
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   752
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   753
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   754
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   755
			public java.util.Map<Foo, String> fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   756
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   757
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   758
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   759
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   760
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   761
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   762
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   763
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   764
testClassWithMethod12
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   765
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   766
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   767
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   768
    			public Constructor<?> getConstructors()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   769
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   770
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   771
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   772
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   773
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   774
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   775
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   776
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   777
testClassWithMethod13
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   778
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   779
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   780
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   781
    			public Constructor<?>[] getConstructors()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   782
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   783
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   784
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   785
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   786
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   787
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   788
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   789
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   790
testClassWithMethod14
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   791
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   792
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   793
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   794
    			public Constructor[] getConstructors()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   795
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   796
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   797
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   798
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   799
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   800
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   801
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   802
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   803
testClassWithMethod15
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   804
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   805
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   806
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   807
    			public Constructor<Foo>[] getConstructors()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   808
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   809
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   810
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   811
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   812
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   813
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   814
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   815
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   816
testClassWithMethod16
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   817
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   818
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   819
    public <U> Class<? extends U> asSubclass(Class<U> clazz) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   820
        if (clazz.isAssignableFrom(this))
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   821
            return (Class<? extends U>) this;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   822
        else
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   823
            throw new ClassCastException(this.toString());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   824
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   825
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   826
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   827
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   828
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   829
testClassWithMethod2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   830
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   831
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   832
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   833
			public Object fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   834
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   835
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   836
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   837
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   838
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   839
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   840
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   841
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   842
testClassWithMethod3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   843
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   844
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   845
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   846
			public int fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   847
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   848
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   849
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   850
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   851
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   852
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   853
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   854
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   855
testClassWithMethod4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   856
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   857
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   858
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   859
			public byte fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   860
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   861
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   862
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   863
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   864
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   865
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   866
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   867
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   868
testClassWithMethod5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   869
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   870
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   871
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   872
			public boolean fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   873
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   874
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   875
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   876
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   877
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   878
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   879
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   880
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   881
testClassWithMethod6
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   882
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   883
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   884
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   885
			public float fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   886
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   887
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   888
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   889
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   890
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   891
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   892
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   893
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   894
testClassWithMethod7
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   895
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   896
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   897
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   898
			public double fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   899
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   900
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   901
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   902
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   903
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   904
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   905
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   906
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   907
testClassWithMethod8
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   908
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   909
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   910
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   911
			public double fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   912
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   913
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   914
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   915
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   916
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   917
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   918
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   919
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   920
testClassWithMethod9
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   921
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   922
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   923
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   924
			public List<Foo> fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   925
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   926
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   927
				return new Object();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   928
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   929
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   930
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   931
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   932
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   933
testConstructor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   934
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   935
public class MyVisitor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   936
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   937
	public Myvisitor() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   938
		super();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   939
	}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   940
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   941
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   942
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   943
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   944
testConstructor2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   945
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   946
public class MyVisitor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   947
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   948
	/** this is constructor */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   949
	protected Myvisitor() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   950
		super();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   951
	}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   952
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   953
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   954
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   955
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   956
testConstructor3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   957
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   958
public class MyVisitor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   959
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   960
	/** this is constructor */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   961
	Myvisitor() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   962
		super();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   963
	}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   964
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   965
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   966
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   967
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   968
testConstructor4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   969
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   970
public class MyVisitor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   971
{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   972
	/** this is constructor */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   973
	private Myvisitor() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   974
		super();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   975
	}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   976
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   977
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   978
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   979
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   980
testFinalMethod
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   981
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   982
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   983
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   984
			public final void fooMethod() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   985
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   986
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   987
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   988
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   989
testFinalMethod2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   990
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   991
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   992
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   993
			static final void fooMethod() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   994
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   995
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   996
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   997
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   998
testMethodWithArrayRetval
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   999
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1000
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1001
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1002
			public Object[] fooMethod(Object[] o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1003
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1004
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1005
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1006
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1007
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1008
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1009
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1010
testMethodWithArrayRetval2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1011
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1012
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1013
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1014
			public int[] fooMethod(Object[] o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1015
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1016
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1017
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1018
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1019
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1020
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1021
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1022
testMethodWithComment
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1023
        ^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1024
                public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1025
                        // Some comment
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1026
                        public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1027
                        {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1028
                                int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1029
                        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1030
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1031
    '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1032
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1033
    "Modified: / 29-12-2010 / 20:29:01 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1034
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1035
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1036
testMethodWithJavadoc
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1037
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1038
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1039
			/**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1040
			 * This is a javadoc, isnt it?
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1041
			 */		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1042
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1043
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1044
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1045
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1046
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1047
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1048
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1049
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1050
testMethodWithJavadoc2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1051
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1052
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1053
			/*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1054
			 * This is not a javadoc, but it is before method, is it?
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1055
			 */		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1056
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1057
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1058
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1059
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1060
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1061
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1062
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1063
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1064
testMethodWithJavadoc3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1065
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1066
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1067
			/** constant with javadoc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1068
			private static String MY_CONSTANT = "This is a constant";
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1069
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1070
			/*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1071
			 * This is not a javadoc, but it is before method, is it?
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1072
			 */		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1073
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1074
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1075
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1076
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1077
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1078
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1079
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1080
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1081
testMethodWithJavadoc4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1082
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1083
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1084
			/** constant with javadoc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1085
			private static String MY_CONSTANT = "This is a constant";
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1086
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1087
			/* random comment */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1088
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1089
			/**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1090
			 * This is not a javadoc, but it is before method, is it?
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1091
			 */		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1092
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1093
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1094
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1095
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1096
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1097
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1098
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1099
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1100
testMethodWithJavadoc5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1101
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1102
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1103
			/** constant with javadoc */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1104
			private static String MY_CONSTANT = "This is a constant";
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1105
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1106
			/* random comment */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1107
			int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1108
			/* another random comment */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1109
			
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1110
			/**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1111
			 * This is not a javadoc, but it is before method, is it?
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1112
			 */		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1113
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1114
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1115
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1116
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1117
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1118
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1119
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1120
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1121
testMethodWithJavadoc6
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1122
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1123
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1124
			/**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1125
			 * Multiple Javadoc per methods :)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1126
			 */	
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1127
			/**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1128
			 * This is not a javadoc, but it is before method, is it?
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1129
			 */		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1130
			public void fooMethod()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1131
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1132
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1133
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1134
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1135
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1136
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1137
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1138
testMultipleMethods
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1139
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1140
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1141
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1142
			public void fooMethod(int i, Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1143
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1144
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1145
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1146
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1147
			public void fooMethod2(Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1148
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1149
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1150
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1151
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1152
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1153
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1154
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1155
testMultipleMethods2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1156
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1157
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1158
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1159
			public void fooMethod(int i, Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1160
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1161
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1162
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1163
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1164
			public void fooMethod2(Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1165
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1166
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1167
			}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1168
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1169
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1170
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1171
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1172
testMultipleMethods3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1173
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1174
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1175
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1176
			public void fooMethod(int i, Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1177
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1178
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1179
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1180
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1181
			public void fooMethod2(Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1182
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1183
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1184
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1185
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1186
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1187
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1188
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1189
testMultipleMethods4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1190
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1191
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1192
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1193
			public void fooMethod(int i, Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1194
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1195
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1196
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1197
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1198
			int i = 9;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1199
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1200
			public void fooMethod2(Object o)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1201
			{
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1202
				int i = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1203
			};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1204
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1205
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1206
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1207
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1208
testNativeMethod
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1209
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1210
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1211
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1212
			public native void wait();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1213
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1214
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1215
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1216
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1217
testNativeMethod2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1218
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1219
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1220
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1221
			public native void wait(long millis);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1222
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1223
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1224
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1225
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1226
testNativeMethod3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1227
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1228
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1229
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1230
			private static native Object wait(long millis);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1231
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1232
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1233
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1234
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1235
testSynchronizedMethod
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1236
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1237
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1238
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1239
			public final synchronized void fooMethod() {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1240
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1241
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1242
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1243
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1244
testThrow
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1245
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1246
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1247
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1248
			public void fooMethod() throws MyException;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1249
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1250
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1251
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1252
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1253
testThrow2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1254
	^ self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1255
		public class Foo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1256
		
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1257
			public void fooMethod() throws MyException, YourException;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1258
		}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1259
	'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1260
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1261
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1262
!JavaParserTests methodsFor:'realClasses'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1263
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1264
testJavaLangClass6
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1265
    | res time |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1266
    time := Time millisecondsToRun: [
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1267
    res := self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1268
/*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1269
 * %W% %E%
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1270
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1271
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1272
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1273
 */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1274
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1275
package java.lang;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1276
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1277
import java.lang.reflect.Array;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1278
import java.lang.reflect.GenericArrayType;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1279
import java.lang.reflect.Member;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1280
import java.lang.reflect.Field;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1281
import java.lang.reflect.Method;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1282
import java.lang.reflect.Constructor;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1283
import java.lang.reflect.GenericDeclaration;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1284
import java.lang.reflect.Modifier;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1285
import java.lang.reflect.Type;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1286
import java.lang.reflect.TypeVariable;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1287
import java.lang.reflect.InvocationTargetException;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1288
import java.lang.ref.SoftReference;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1289
import java.io.InputStream;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1290
import java.io.ObjectStreamField;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1291
import java.security.AccessController;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1292
import java.security.PrivilegedAction;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1293
import java.util.ArrayList;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1294
import java.util.Arrays;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1295
import java.util.Collection;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1296
import java.util.HashSet;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1297
import java.util.Iterator;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1298
import java.util.List;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1299
import java.util.LinkedList;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1300
import java.util.LinkedHashSet;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1301
import java.util.Set;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1302
import java.util.Map;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1303
import java.util.HashMap;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1304
import sun.misc.Unsafe;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1305
import sun.reflect.ConstantPool;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1306
import sun.reflect.Reflection;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1307
import sun.reflect.ReflectionFactory;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1308
import sun.reflect.SignatureIterator;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1309
import sun.reflect.generics.factory.CoreReflectionFactory;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1310
import sun.reflect.generics.factory.GenericsFactory;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1311
import sun.reflect.generics.repository.ClassRepository;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1312
import sun.reflect.generics.repository.MethodRepository;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1313
import sun.reflect.generics.repository.ConstructorRepository;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1314
import sun.reflect.generics.scope.ClassScope;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1315
import sun.security.util.SecurityConstants;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1316
import java.lang.annotation.Annotation;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1317
import sun.reflect.annotation.*;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1318
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1319
/**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1320
 * Instances of the class <code>Class</code> represent classes and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1321
 * interfaces in a running Java application.  An enum is a kind of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1322
 * class and an annotation is a kind of interface.  Every array also
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1323
 * belongs to a class that is reflected as a <code>Class</code> object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1324
 * that is shared by all arrays with the same element type and number
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1325
 * of dimensions.  The primitive Java types (<code>boolean</code>,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1326
 * <code>byte</code>, <code>char</code>, <code>short</code>,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1327
 * <code>int</code>, <code>long</code>, <code>float</code>, and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1328
 * <code>double</code>), and the keyword <code>void</code> are also
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1329
 * represented as <code>Class</code> objects.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1330
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1331
 * <p> <code>Class</code> has no public constructor. Instead <code>Class</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1332
 * objects are constructed automatically by the Java Virtual Machine as classes
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1333
 * are loaded and by calls to the <code>defineClass</code> method in the class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1334
 * loader.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1335
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1336
 * <p> The following example uses a <code>Class</code> object to print the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1337
 * class name of an object:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1338
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1339
 * <p> <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1340
 *     void printClassName(Object obj) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1341
 *         System.out.println("The class of " + obj +
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1342
 *                            " is " + obj.getClass().getName());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1343
 *     }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1344
 * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1345
 * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1346
 * <p> It is also possible to get the <code>Class</code> object for a named
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1347
 * type (or for void) using a class literal 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1348
 * (JLS Section <A HREF="http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#251530">15.8.2</A>). 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1349
 * For example:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1350
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1351
 * <p> <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1352
 *     System.out.println("The name of class Foo is: "+Foo.class.getName());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1353
 * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1354
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1355
 * @param <T> the type of the class modeled by this {@code Class}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1356
 * object.  For example, the type of {@code String.class} is {@code
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1357
 * Class<String>}.  Use {@code Class<?>} if the class being modeled is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1358
 * unknown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1359
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1360
 * @author  unascribed
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1361
 * @version %I%, %G%
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1362
 * @see     java.lang.ClassLoader#defineClass(byte[], int, int)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1363
 * @since   JDK1.0
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1364
 */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1365
public final
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1366
    class Class<T> implements java.io.Serializable, 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1367
                              java.lang.reflect.GenericDeclaration, 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1368
                              java.lang.reflect.Type,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1369
                              java.lang.reflect.AnnotatedElement {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1370
    private static final int ANNOTATION= 0x00002000;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1371
    private static final int ENUM      = 0x00004000;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1372
    private static final int SYNTHETIC = 0x00001000;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1373
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1374
    private static native void registerNatives();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1375
    static {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1376
        registerNatives();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1377
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1378
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1379
    /*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1380
     * Constructor. Only the Java Virtual Machine creates Class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1381
     * objects.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1382
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1383
    private Class() {}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1384
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1385
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1386
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1387
     * Converts the object to a string. The string representation is the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1388
     * string "class" or "interface", followed by a space, and then by the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1389
     * fully qualified name of the class in the format returned by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1390
     * <code>getName</code>.  If this <code>Class</code> object represents a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1391
     * primitive type, this method returns the name of the primitive type.  If
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1392
     * this <code>Class</code> object represents void this method returns
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1393
     * "void".
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1394
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1395
     * @return a string representation of this class object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1396
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1397
    public String toString() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1398
        return (isInterface() ? "interface " : (isPrimitive() ? "" : "class "))
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1399
            + getName();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1400
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1401
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1402
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1403
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1404
     * Returns the <code>Class</code> object associated with the class or
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1405
     * interface with the given string name.  Invoking this method is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1406
     * equivalent to:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1407
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1408
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1409
     *  Class.forName(className, true, currentLoader)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1410
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1411
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1412
     * where <code>currentLoader</code> denotes the defining class loader of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1413
     * the current class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1414
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1415
     * <p> For example, the following code fragment returns the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1416
     * runtime <code>Class</code> descriptor for the class named
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1417
     * <code>java.lang.Thread</code>:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1418
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1419
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1420
     *   Class&nbsp;t&nbsp;= Class.forName("java.lang.Thread")
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1421
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1422
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1423
     * A call to <tt>forName("X")</tt> causes the class named 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1424
     * <tt>X</tt> to be initialized.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1425
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1426
     * @param      className   the fully qualified name of the desired class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1427
     * @return     the <code>Class</code> object for the class with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1428
     *             specified name.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1429
     * @exception LinkageError if the linkage fails
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1430
     * @exception ExceptionInInitializerError if the initialization provoked
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1431
     *            by this method fails
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1432
     * @exception ClassNotFoundException if the class cannot be located
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1433
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1434
    public static Class<?> forName(String className) 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1435
                throws ClassNotFoundException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1436
        return forName0(className, true, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1437
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1438
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1439
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1440
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1441
     * Returns the <code>Class</code> object associated with the class or
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1442
     * interface with the given string name, using the given class loader.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1443
     * Given the fully qualified name for a class or interface (in the same
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1444
     * format returned by <code>getName</code>) this method attempts to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1445
     * locate, load, and link the class or interface.  The specified class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1446
     * loader is used to load the class or interface.  If the parameter
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1447
     * <code>loader</code> is null, the class is loaded through the bootstrap
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1448
     * class loader.  The class is initialized only if the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1449
     * <code>initialize</code> parameter is <code>true</code> and if it has
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1450
     * not been initialized earlier.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1451
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1452
     * <p> If <code>name</code> denotes a primitive type or void, an attempt
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1453
     * will be made to locate a user-defined class in the unnamed package whose
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1454
     * name is <code>name</code>. Therefore, this method cannot be used to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1455
     * obtain any of the <code>Class</code> objects representing primitive
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1456
     * types or void.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1457
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1458
     * <p> If <code>name</code> denotes an array class, the component type of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1459
     * the array class is loaded but not initialized.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1460
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1461
     * <p> For example, in an instance method the expression:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1462
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1463
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1464
     *  Class.forName("Foo")
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1465
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1466
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1467
     * is equivalent to:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1468
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1469
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1470
     *  Class.forName("Foo", true, this.getClass().getClassLoader())
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1471
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1472
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1473
     * Note that this method throws errors related to loading, linking or
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1474
     * initializing as specified in Sections 12.2, 12.3 and 12.4 of <em>The
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1475
     * Java Language Specification</em>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1476
     * Note that this method does not check whether the requested class 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1477
     * is accessible to its caller.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1478
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1479
     * <p> If the <code>loader</code> is <code>null</code>, and a security
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1480
     * manager is present, and the caller''s class loader is not null, then this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1481
     * method calls the security manager''s <code>checkPermission</code> method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1482
     * with a <code>RuntimePermission("getClassLoader")</code> permission to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1483
     * ensure it''s ok to access the bootstrap class loader.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1484
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1485
     * @param name       fully qualified name of the desired class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1486
     * @param initialize whether the class must be initialized
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1487
     * @param loader     class loader from which the class must be loaded
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1488
     * @return           class object representing the desired class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1489
     * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1490
     * @exception LinkageError if the linkage fails
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1491
     * @exception ExceptionInInitializerError if the initialization provoked
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1492
     *            by this method fails
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1493
     * @exception ClassNotFoundException if the class cannot be located by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1494
     *            the specified class loader
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1495
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1496
     * @see       java.lang.Class#forName(String) 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1497
     * @see       java.lang.ClassLoader
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1498
     * @since     1.2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1499
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1500
    public static Class<?> forName(String name, boolean initialize,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1501
                                   ClassLoader loader)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1502
        throws ClassNotFoundException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1503
    {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1504
        if (loader == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1505
            SecurityManager sm = System.getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1506
            if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1507
                ClassLoader ccl = ClassLoader.getCallerClassLoader();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1508
                if (ccl !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1509
                    sm.checkPermission(
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1510
                        SecurityConstants.GET_CLASSLOADER_PERMISSION);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1511
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1512
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1513
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1514
        return forName0(name, initialize, loader);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1515
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1516
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1517
    /** Called after security checks have been made. */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1518
    private static native Class forName0(String name, boolean initialize,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1519
                                            ClassLoader loader)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1520
        throws ClassNotFoundException;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1521
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1522
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1523
     * Creates a new instance of the class represented by this <tt>Class</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1524
     * object.  The class is instantiated as if by a <code>new</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1525
     * expression with an empty argument list.  The class is initialized if it
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1526
     * has not already been initialized.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1527
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1528
     * <p>Note that this method propagates any exception thrown by the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1529
     * nullary constructor, including a checked exception.  Use of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1530
     * this method effectively bypasses the compile-time exception
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1531
     * checking that would otherwise be performed by the compiler.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1532
     * The {@link
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1533
     * java.lang.reflect.Constructor#newInstance(java.lang.Object...)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1534
     * Constructor.newInstance} method avoids this problem by wrapping
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1535
     * any exception thrown by the constructor in a (checked) {@link
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1536
     * java.lang.reflect.InvocationTargetException}.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1537
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1538
     * @return     a newly allocated instance of the class represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1539
     *             object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1540
     * @exception  IllegalAccessException  if the class or its nullary 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1541
     *               constructor is not accessible.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1542
     * @exception  InstantiationException 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1543
     *               if this <code>Class</code> represents an abstract class,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1544
     *               an interface, an array class, a primitive type, or void;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1545
     *               or if the class has no nullary constructor;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1546
     *               or if the instantiation fails for some other reason.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1547
     * @exception  ExceptionInInitializerError if the initialization
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1548
     *               provoked by this method fails.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1549
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1550
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1551
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1552
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1553
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1554
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1555
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1556
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1557
     *             s.checkMemberAccess(this, Member.PUBLIC)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1558
     *             creation of new instances of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1559
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1560
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1561
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1562
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1563
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1564
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1565
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1566
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1567
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1568
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1569
    public T newInstance() 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1570
        throws InstantiationException, IllegalAccessException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1571
    {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1572
        if (System.getSecurityManager() !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1573
            checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1574
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1575
        return newInstance0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1576
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1577
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1578
    private T newInstance0()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1579
        throws InstantiationException, IllegalAccessException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1580
    {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1581
        // NOTE: the following code may not be strictly correct under
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1582
        // the current Java memory model.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1583
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1584
        // Constructor lookup
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1585
        if (cachedConstructor == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1586
            if (this == Class.class) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1587
                throw new IllegalAccessException(
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1588
                    "Can not call newInstance() on the Class for java.lang.Class"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1589
                );
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1590
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1591
            try {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1592
                Class[] empty = {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1593
                final Constructor<T> c = getConstructor0(empty, Member.DECLARED);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1594
                // Disable accessibility checks on the constructor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1595
                // since we have to do the security check here anyway
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1596
                // (the stack depth is wrong for the Constructor''s
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1597
                // security check to work)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1598
                java.security.AccessController.doPrivileged
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1599
                    (new java.security.PrivilegedAction() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1600
                            public Object run() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1601
                                c.setAccessible(true);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1602
                                return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1603
                            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1604
                        });
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1605
                cachedConstructor = c;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1606
            } catch (NoSuchMethodException e) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1607
                throw new InstantiationException(getName());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1608
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1609
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1610
        Constructor<T> tmpConstructor = cachedConstructor;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1611
        // Security check (same as in java.lang.reflect.Constructor)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1612
        int modifiers = tmpConstructor.getModifiers();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1613
        if (!!Reflection.quickCheckMemberAccess(this, modifiers)) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1614
            Class caller = Reflection.getCallerClass(3);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1615
            if (newInstanceCallerCache !!= caller) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1616
                Reflection.ensureMemberAccess(caller, this, null, modifiers);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1617
                newInstanceCallerCache = caller;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1618
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1619
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1620
        // Run constructor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1621
        try {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1622
            return tmpConstructor.newInstance((Object[])null);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1623
        } catch (InvocationTargetException e) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1624
            Unsafe.getUnsafe().throwException(e.getTargetException());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1625
            // Not reached
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1626
            return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1627
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1628
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1629
    private volatile transient Constructor<T> cachedConstructor;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1630
    private volatile transient Class       newInstanceCallerCache;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1631
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1632
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1633
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1634
     * Determines if the specified <code>Object</code> is assignment-compatible
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1635
     * with the object represented by this <code>Class</code>.  This method is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1636
     * the dynamic equivalent of the Java language <code>instanceof</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1637
     * operator. The method returns <code>true</code> if the specified
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1638
     * <code>Object</code> argument is non-null and can be cast to the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1639
     * reference type represented by this <code>Class</code> object without
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1640
     * raising a <code>ClassCastException.</code> It returns <code>false</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1641
     * otherwise.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1642
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1643
     * <p> Specifically, if this <code>Class</code> object represents a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1644
     * declared class, this method returns <code>true</code> if the specified
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1645
     * <code>Object</code> argument is an instance of the represented class (or
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1646
     * of any of its subclasses); it returns <code>false</code> otherwise. If
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1647
     * this <code>Class</code> object represents an array class, this method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1648
     * returns <code>true</code> if the specified <code>Object</code> argument
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1649
     * can be converted to an object of the array class by an identity
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1650
     * conversion or by a widening reference conversion; it returns
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1651
     * <code>false</code> otherwise. If this <code>Class</code> object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1652
     * represents an interface, this method returns <code>true</code> if the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1653
     * class or any superclass of the specified <code>Object</code> argument
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1654
     * implements this interface; it returns <code>false</code> otherwise. If
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1655
     * this <code>Class</code> object represents a primitive type, this method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1656
     * returns <code>false</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1657
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1658
     * @param   obj the object to check
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1659
     * @return  true if <code>obj</code> is an instance of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1660
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1661
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1662
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1663
    public native boolean isInstance(Object obj);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1664
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1665
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1666
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1667
     * Determines if the class or interface represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1668
     * <code>Class</code> object is either the same as, or is a superclass or
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1669
     * superinterface of, the class or interface represented by the specified
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1670
     * <code>Class</code> parameter. It returns <code>true</code> if so;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1671
     * otherwise it returns <code>false</code>. If this <code>Class</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1672
     * object represents a primitive type, this method returns
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1673
     * <code>true</code> if the specified <code>Class</code> parameter is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1674
     * exactly this <code>Class</code> object; otherwise it returns
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1675
     * <code>false</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1676
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1677
     * <p> Specifically, this method tests whether the type represented by the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1678
     * specified <code>Class</code> parameter can be converted to the type
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1679
     * represented by this <code>Class</code> object via an identity conversion
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1680
     * or via a widening reference conversion. See <em>The Java Language
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1681
     * Specification</em>, sections 5.1.1 and 5.1.4 , for details.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1682
     * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1683
     * @param cls the <code>Class</code> object to be checked
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1684
     * @return the <code>boolean</code> value indicating whether objects of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1685
     * type <code>cls</code> can be assigned to objects of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1686
     * @exception NullPointerException if the specified Class parameter is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1687
     *            null.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1688
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1689
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1690
    public native boolean isAssignableFrom(Class<?> cls);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1691
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1692
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1693
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1694
     * Determines if the specified <code>Class</code> object represents an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1695
     * interface type.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1696
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1697
     * @return  <code>true</code> if this object represents an interface;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1698
     *          <code>false</code> otherwise.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1699
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1700
    public native boolean isInterface();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1701
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1702
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1703
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1704
     * Determines if this <code>Class</code> object represents an array class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1705
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1706
     * @return  <code>true</code> if this object represents an array class;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1707
     *          <code>false</code> otherwise.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1708
     * @since   JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1709
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1710
    public native boolean isArray();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1711
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1712
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1713
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1714
     * Determines if the specified <code>Class</code> object represents a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1715
     * primitive type.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1716
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1717
     * <p> There are nine predefined <code>Class</code> objects to represent
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1718
     * the eight primitive types and void.  These are created by the Java
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1719
     * Virtual Machine, and have the same names as the primitive types that
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1720
     * they represent, namely <code>boolean</code>, <code>byte</code>,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1721
     * <code>char</code>, <code>short</code>, <code>int</code>,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1722
     * <code>long</code>, <code>float</code>, and <code>double</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1723
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1724
     * <p> These objects may only be accessed via the following public static
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1725
     * final variables, and are the only <code>Class</code> objects for which
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1726
     * this method returns <code>true</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1727
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1728
     * @return true if and only if this class represents a primitive type
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1729
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1730
     * @see     java.lang.Boolean#TYPE
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1731
     * @see     java.lang.Character#TYPE
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1732
     * @see     java.lang.Byte#TYPE
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1733
     * @see     java.lang.Short#TYPE
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1734
     * @see     java.lang.Integer#TYPE
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1735
     * @see     java.lang.Long#TYPE
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1736
     * @see     java.lang.Float#TYPE
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1737
     * @see     java.lang.Double#TYPE
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1738
     * @see     java.lang.Void#TYPE
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1739
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1740
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1741
    public native boolean isPrimitive();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1742
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1743
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1744
     * Returns true if this <tt>Class</tt> object represents an annotation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1745
     * type.  Note that if this method returns true, {@link #isInterface()}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1746
     * would also return true, as all annotation types are also interfaces.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1747
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1748
     * @return <tt>true</tt> if this class object represents an annotation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1749
     *      type; <tt>false</tt> otherwise
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1750
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1751
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1752
    public boolean isAnnotation() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1753
        return (getModifiers() & ANNOTATION) !!= 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1754
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1755
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1756
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1757
     * Returns <tt>true</tt> if this class is a synthetic class;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1758
     * returns <tt>false</tt> otherwise.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1759
     * @return <tt>true</tt> if and only if this class is a synthetic class as
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1760
     *         defined by the Java Language Specification.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1761
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1762
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1763
    public boolean isSynthetic() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1764
        return (getModifiers() & SYNTHETIC) !!= 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1765
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1766
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1767
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1768
     * Returns the  name of the entity (class, interface, array class,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1769
     * primitive type, or void) represented by this <tt>Class</tt> object,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1770
     * as a <tt>String</tt>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1771
     * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1772
     * <p> If this class object represents a reference type that is not an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1773
     * array type then the binary name of the class is returned, as specified
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1774
     * by the Java Language Specification, Second Edition.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1775
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1776
     * <p> If this class object represents a primitive type or void, then the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1777
     * name returned is a <tt>String</tt> equal to the Java language
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1778
     * keyword corresponding to the primitive type or void.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1779
     * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1780
     * <p> If this class object represents a class of arrays, then the internal
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1781
     * form of the name consists of the name of the element type preceded by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1782
     * one or more ''<tt>[</tt>'' characters representing the depth of the array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1783
     * nesting.  The encoding of element type names is as follows:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1784
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1785
     * <blockquote><table summary="Element types and encodings">
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1786
     * <tr><th> Element Type <th> &nbsp;&nbsp;&nbsp; <th> Encoding
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1787
     * <tr><td> boolean      <td> &nbsp;&nbsp;&nbsp; <td align=center> Z
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1788
     * <tr><td> byte         <td> &nbsp;&nbsp;&nbsp; <td align=center> B
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1789
     * <tr><td> char         <td> &nbsp;&nbsp;&nbsp; <td align=center> C
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1790
     * <tr><td> class or interface  
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1791
     *                       <td> &nbsp;&nbsp;&nbsp; <td align=center> L<i>classname</i>;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1792
     * <tr><td> double       <td> &nbsp;&nbsp;&nbsp; <td align=center> D
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1793
     * <tr><td> float        <td> &nbsp;&nbsp;&nbsp; <td align=center> F
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1794
     * <tr><td> int          <td> &nbsp;&nbsp;&nbsp; <td align=center> I
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1795
     * <tr><td> long         <td> &nbsp;&nbsp;&nbsp; <td align=center> J
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1796
     * <tr><td> short        <td> &nbsp;&nbsp;&nbsp; <td align=center> S
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1797
     * </table></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1798
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1799
     * <p> The class or interface name <i>classname</i> is the binary name of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1800
     * the class specified above.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1801
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1802
     * <p> Examples:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1803
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1804
     * String.class.getName()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1805
     *     returns "java.lang.String"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1806
     * byte.class.getName()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1807
     *     returns "byte"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1808
     * (new Object[3]).getClass().getName()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1809
     *     returns "[Ljava.lang.Object;"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1810
     * (new int[3][4][5][6][7][8][9]).getClass().getName()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1811
     *     returns "[[[[[[[I"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1812
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1813
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1814
     * @return  the name of the class or interface
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1815
     *          represented by this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1816
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1817
    public String getName() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1818
        if (name == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1819
            name = getName0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1820
        return name;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1821
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1822
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1823
    // cache the name to reduce the number of calls into the VM
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1824
    private transient String name;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1825
    private native String getName0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1826
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1827
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1828
     * Returns the class loader for the class.  Some implementations may use
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1829
     * null to represent the bootstrap class loader. This method will return
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1830
     * null in such implementations if this class was loaded by the bootstrap
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1831
     * class loader.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1832
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1833
     * <p> If a security manager is present, and the caller''s class loader is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1834
     * not null and the caller''s class loader is not the same as or an ancestor of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1835
     * the class loader for the class whose class loader is requested, then
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1836
     * this method calls the security manager''s <code>checkPermission</code> 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1837
     * method with a <code>RuntimePermission("getClassLoader")</code> 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1838
     * permission to ensure it''s ok to access the class loader for the class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1839
     * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1840
     * <p>If this object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1841
     * represents a primitive type or void, null is returned.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1842
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1843
     * @return  the class loader that loaded the class or interface
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1844
     *          represented by this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1845
     * @throws SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1846
     *    if a security manager exists and its 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1847
     *    <code>checkPermission</code> method denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1848
     *    access to the class loader for the class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1849
     * @see java.lang.ClassLoader
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1850
     * @see SecurityManager#checkPermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1851
     * @see java.lang.RuntimePermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1852
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1853
    public ClassLoader getClassLoader() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1854
        ClassLoader cl = getClassLoader0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1855
        if (cl == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1856
            return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1857
        SecurityManager sm = System.getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1858
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1859
            ClassLoader ccl = ClassLoader.getCallerClassLoader();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1860
            if (ccl !!= null && ccl !!= cl && !!cl.isAncestor(ccl)) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1861
                sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1862
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1863
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1864
        return cl;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1865
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1866
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1867
    // Package-private to allow ClassLoader access
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1868
    native ClassLoader getClassLoader0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1869
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1870
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1871
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1872
     * Returns an array of <tt>TypeVariable</tt> objects that represent the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1873
     * type variables declared by the generic declaration represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1874
     * <tt>GenericDeclaration</tt> object, in declaration order.  Returns an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1875
     * array of length 0 if the underlying generic declaration declares no type
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1876
     * variables.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1877
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1878
     * @return an array of <tt>TypeVariable</tt> objects that represent
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1879
     *     the type variables declared by this generic declaration
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1880
     * @throws GenericSignatureFormatError if the generic
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1881
     *     signature of this generic declaration does not conform to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1882
     *     the format specified in the Java Virtual Machine Specification,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1883
     *     3rd edition
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1884
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1885
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1886
    public TypeVariable<Class<T>>[] getTypeParameters() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1887
        if (getGenericSignature() !!= null) 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1888
            return (TypeVariable<Class<T>>[])getGenericInfo().getTypeParameters();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1889
        else
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1890
            return (TypeVariable<Class<T>>[])new TypeVariable[0];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1891
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1892
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1893
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1894
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1895
     * Returns the <code>Class</code> representing the superclass of the entity
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1896
     * (class, interface, primitive type or void) represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1897
     * <code>Class</code>.  If this <code>Class</code> represents either the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1898
     * <code>Object</code> class, an interface, a primitive type, or void, then
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1899
     * null is returned.  If this object represents an array class then the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1900
     * <code>Class</code> object representing the <code>Object</code> class is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1901
     * returned.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1902
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1903
     * @return the superclass of the class represented by this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1904
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1905
    public native Class<? super T> getSuperclass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1906
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1907
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1908
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1909
     * Returns the <tt>Type</tt> representing the direct superclass of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1910
     * the entity (class, interface, primitive type or void) represented by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1911
     * this <tt>Class</tt>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1912
     * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1913
     * <p>If the superclass is a parameterized type, the <tt>Type</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1914
     * object returned must accurately reflect the actual type
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1915
     * parameters used in the source code. The parameterized type
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1916
     * representing the superclass is created if it had not been
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1917
     * created before. See the declaration of {@link
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1918
     * java.lang.reflect.ParameterizedType ParameterizedType} for the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1919
     * semantics of the creation process for parameterized types.  If
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1920
     * this <tt>Class</tt> represents either the <tt>Object</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1921
     * class, an interface, a primitive type, or void, then null is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1922
     * returned.  If this object represents an array class then the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1923
     * <tt>Class</tt> object representing the <tt>Object</tt> class is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1924
     * returned.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1925
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1926
     * @throws GenericSignatureFormatError if the generic
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1927
     *     class signature does not conform to the format specified in the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1928
     *     Java Virtual Machine Specification, 3rd edition
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1929
     * @throws TypeNotPresentException if the generic superclass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1930
     *     refers to a non-existent type declaration
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1931
     * @throws MalformedParameterizedTypeException if the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1932
     *     generic superclass refers to a parameterized type that cannot be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1933
     *     instantiated  for any reason
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1934
     * @return the superclass of the class represented by this object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1935
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1936
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1937
    public Type getGenericSuperclass() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1938
        if (getGenericSignature() !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1939
            // Historical irregularity:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1940
            // Generic signature marks interfaces with superclass = Object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1941
            // but this API returns null for interfaces
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1942
            if (isInterface())
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1943
                return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1944
            return getGenericInfo().getSuperclass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1945
        } else
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1946
            return getSuperclass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1947
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1948
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1949
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1950
     * Gets the package for this class.  The class loader of this class is used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1951
     * to find the package.  If the class was loaded by the bootstrap class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1952
     * loader the set of packages loaded from CLASSPATH is searched to find the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1953
     * package of the class. Null is returned if no package object was created
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1954
     * by the class loader of this class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1955
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1956
     * <p> Packages have attributes for versions and specifications only if the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1957
     * information was defined in the manifests that accompany the classes, and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1958
     * if the class loader created the package instance with the attributes
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1959
     * from the manifest.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1960
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1961
     * @return the package of the class, or null if no package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1962
     *         information is available from the archive or codebase.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1963
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1964
    public Package getPackage() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1965
        return Package.getPackage(this);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1966
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1967
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1968
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1969
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1970
     * Determines the interfaces implemented by the class or interface
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1971
     * represented by this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1972
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1973
     * <p> If this object represents a class, the return value is an array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1974
     * containing objects representing all interfaces implemented by the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1975
     * class. The order of the interface objects in the array corresponds to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1976
     * the order of the interface names in the <code>implements</code> clause
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1977
     * of the declaration of the class represented by this object. For 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1978
     * example, given the declaration:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1979
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1980
     * class Shimmer implements FloorWax, DessertTopping { ... }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1981
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1982
     * suppose the value of <code>s</code> is an instance of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1983
     * <code>Shimmer</code>; the value of the expression:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1984
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1985
     * s.getClass().getInterfaces()[0]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1986
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1987
     * is the <code>Class</code> object that represents interface 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1988
     * <code>FloorWax</code>; and the value of:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1989
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1990
     * s.getClass().getInterfaces()[1]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1991
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1992
     * is the <code>Class</code> object that represents interface 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1993
     * <code>DessertTopping</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1994
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1995
     * <p> If this object represents an interface, the array contains objects
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1996
     * representing all interfaces extended by the interface. The order of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1997
     * interface objects in the array corresponds to the order of the interface
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1998
     * names in the <code>extends</code> clause of the declaration of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  1999
     * interface represented by this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2000
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2001
     * <p> If this object represents a class or interface that implements no
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2002
     * interfaces, the method returns an array of length 0.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2003
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2004
     * <p> If this object represents a primitive type or void, the method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2005
     * returns an array of length 0.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2006
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2007
     * @return an array of interfaces implemented by this class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2008
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2009
    public native Class<?>[] getInterfaces();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2010
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2011
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2012
     * Returns the <tt>Type</tt>s representing the interfaces 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2013
     * directly implemented by the class or interface represented by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2014
     * this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2015
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2016
     * <p>If a superinterface is a parameterized type, the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2017
     * <tt>Type</tt> object returned for it must accurately reflect
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2018
     * the actual type parameters used in the source code. The
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2019
     * parameterized type representing each superinterface is created
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2020
     * if it had not been created before. See the declaration of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2021
     * {@link java.lang.reflect.ParameterizedType ParameterizedType}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2022
     * for the semantics of the creation process for parameterized
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2023
     * types.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2024
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2025
     * <p> If this object represents a class, the return value is an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2026
     * array containing objects representing all interfaces
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2027
     * implemented by the class. The order of the interface objects in
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2028
     * the array corresponds to the order of the interface names in
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2029
     * the <tt>implements</tt> clause of the declaration of the class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2030
     * represented by this object.  In the case of an array class, the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2031
     * interfaces <tt>Cloneable</tt> and <tt>Serializable</tt> are
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2032
     * returned in that order.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2033
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2034
     * <p>If this object represents an interface, the array contains
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2035
     * objects representing all interfaces directly extended by the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2036
     * interface.  The order of the interface objects in the array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2037
     * corresponds to the order of the interface names in the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2038
     * <tt>extends</tt> clause of the declaration of the interface
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2039
     * represented by this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2040
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2041
     * <p>If this object represents a class or interface that
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2042
     * implements no interfaces, the method returns an array of length
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2043
     * 0.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2044
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2045
     * <p>If this object represents a primitive type or void, the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2046
     * method returns an array of length 0.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2047
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2048
     * @throws GenericSignatureFormatError
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2049
     *     if the generic class signature does not conform to the format
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2050
     *     specified in the Java Virtual Machine Specification, 3rd edition
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2051
     * @throws TypeNotPresentException if any of the generic
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2052
     *     superinterfaces refers to a non-existent type declaration
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2053
     * @throws MalformedParameterizedTypeException if any of the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2054
     *     generic superinterfaces refer to a parameterized type that cannot
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2055
     *     be instantiated  for any reason
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2056
     * @return an array of interfaces implemented by this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2057
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2058
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2059
    public Type[] getGenericInterfaces() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2060
        if (getGenericSignature() !!= null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2061
            return getGenericInfo().getSuperInterfaces();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2062
        else
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2063
            return getInterfaces();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2064
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2065
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2066
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2067
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2068
     * Returns the <code>Class</code> representing the component type of an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2069
     * array.  If this class does not represent an array class this method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2070
     * returns null.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2071
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2072
     * @return the <code>Class</code> representing the component type of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2073
     * class if this class is an array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2074
     * @see     java.lang.reflect.Array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2075
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2076
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2077
    public native Class<?> getComponentType();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2078
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2079
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2080
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2081
     * Returns the Java language modifiers for this class or interface, encoded
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2082
     * in an integer. The modifiers consist of the Java Virtual Machine''s
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2083
     * constants for <code>public</code>, <code>protected</code>,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2084
     * <code>private</code>, <code>final</code>, <code>static</code>,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2085
     * <code>abstract</code> and <code>interface</code>; they should be decoded
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2086
     * using the methods of class <code>Modifier</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2087
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2088
     * <p> If the underlying class is an array class, then its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2089
     * <code>public</code>, <code>private</code> and <code>protected</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2090
     * modifiers are the same as those of its component type.  If this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2091
     * <code>Class</code> represents a primitive type or void, its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2092
     * <code>public</code> modifier is always <code>true</code>, and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2093
     * <code>protected</code> and <code>private</code> modifiers are always
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2094
     * <code>false</code>. If this object represents an array class, a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2095
     * primitive type or void, then its <code>final</code> modifier is always
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2096
     * <code>true</code> and its interface modifier is always
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2097
     * <code>false</code>. The values of its other modifiers are not determined
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2098
     * by this specification.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2099
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2100
     * <p> The modifier encodings are defined in <em>The Java Virtual Machine
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2101
     * Specification</em>, table 4.1.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2102
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2103
     * @return the <code>int</code> representing the modifiers for this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2104
     * @see     java.lang.reflect.Modifier
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2105
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2106
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2107
    public native int getModifiers();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2108
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2109
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2110
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2111
     * Gets the signers of this class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2112
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2113
     * @return  the signers of this class, or null if there are no signers.  In
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2114
     *          particular, this method returns null if this object represents
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2115
     *          a primitive type or void.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2116
     * @since   JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2117
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2118
    public native Object[] getSigners();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2119
        
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2120
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2121
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2122
     * Set the signers of this class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2123
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2124
    native void setSigners(Object[] signers);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2125
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2126
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2127
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2128
     * If this <tt>Class</tt> object represents a local or anonymous
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2129
     * class within a method, returns a {@link
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2130
     * java.lang.reflect.Method Method} object representing the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2131
     * immediately enclosing method of the underlying class. Returns
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2132
     * <tt>null</tt> otherwise.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2133
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2134
     * In particular, this method returns <tt>null</tt> if the underlying
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2135
     * class is a local or anonymous class immediately enclosed by a type
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2136
     * declaration, instance initializer or static initializer.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2137
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2138
     * @return the immediately enclosing method of the underlying class, if
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2139
     *     that class is a local or anonymous class; otherwise <tt>null</tt>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2140
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2141
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2142
    public Method getEnclosingMethod() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2143
        EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2144
        
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2145
        if (enclosingInfo == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2146
            return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2147
        else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2148
            if (!!enclosingInfo.isMethod())
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2149
                return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2150
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2151
            MethodRepository typeInfo = MethodRepository.make(enclosingInfo.getDescriptor(), 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2152
                                                              getFactory());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2153
            Class      returnType       = toClass(typeInfo.getReturnType());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2154
            Type []    parameterTypes   = typeInfo.getParameterTypes();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2155
            Class<?>[] parameterClasses = new Class<?>[parameterTypes.length];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2156
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2157
            // Convert Types to Classes; returned types *should*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2158
            // be class objects since the methodDescriptor''s used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2159
            // don''t have generics information
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2160
            for(int i = 0; i < parameterClasses.length; i++)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2161
                parameterClasses[i] = toClass(parameterTypes[i]);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2162
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2163
            /*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2164
             * Loop over all declared methods; match method name,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2165
             * number of and type of parameters, *and* return
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2166
             * type.  Matching return type is also necessary
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2167
             * because of covariant returns, etc.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2168
             */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2169
            for(Method m: enclosingInfo.getEnclosingClass().getDeclaredMethods()) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2170
                if (m.getName().equals(enclosingInfo.getName()) ) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2171
                    Class<?>[] candidateParamClasses = m.getParameterTypes();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2172
                    if (candidateParamClasses.length == parameterClasses.length) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2173
                        boolean matches = true;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2174
                        for(int i = 0; i < candidateParamClasses.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2175
                            if (!!candidateParamClasses[i].equals(parameterClasses[i])) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2176
                                matches = false;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2177
                                break;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2178
                            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2179
                        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2180
                            
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2181
                        if (matches) { // finally, check return type
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2182
                            if (m.getReturnType().equals(returnType) )
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2183
                                return m;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2184
                        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2185
                    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2186
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2187
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2188
                
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2189
            throw new InternalError("Enclosing method not found");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2190
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2191
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2192
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2193
    private native Object[] getEnclosingMethod0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2194
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2195
    private EnclosingMethodInfo getEnclosingMethodInfo() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2196
        Object[] enclosingInfo = getEnclosingMethod0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2197
        if (enclosingInfo == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2198
            return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2199
        else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2200
            return new EnclosingMethodInfo(enclosingInfo);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2201
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2202
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2203
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2204
    private final static class EnclosingMethodInfo {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2205
        private Class<?> enclosingClass;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2206
        private String name;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2207
        private String descriptor;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2208
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2209
        private EnclosingMethodInfo(Object[] enclosingInfo) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2210
            if (enclosingInfo.length !!= 3)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2211
                throw new InternalError("Malformed enclosing method information");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2212
            try {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2213
                // The array is expected to have three elements:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2214
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2215
                // the immediately enclosing class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2216
                enclosingClass = (Class<?>) enclosingInfo[0];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2217
                assert(enclosingClass !!= null);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2218
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2219
                // the immediately enclosing method or constructor''s
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2220
                // name (can be null).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2221
                name            = (String)   enclosingInfo[1]; 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2222
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2223
                // the immediately enclosing method or constructor''s
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2224
                // descriptor (null iff name is).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2225
                descriptor      = (String)   enclosingInfo[2];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2226
                assert((name !!= null && descriptor !!= null) || name == descriptor);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2227
            } catch (ClassCastException cce) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2228
                throw new InternalError("Invalid type in enclosing method information");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2229
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2230
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2231
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2232
        boolean isPartial() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2233
            return enclosingClass == null || name == null || descriptor == null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2234
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2235
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2236
        boolean isConstructor() { return !!isPartial() && "<init>".equals(name); }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2237
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2238
        boolean isMethod() { return !!isPartial() && !!isConstructor() && !!"<clinit>".equals(name); }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2239
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2240
        Class<?> getEnclosingClass() { return enclosingClass; }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2241
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2242
        String getName() { return name; }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2243
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2244
        String getDescriptor() { return descriptor; }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2245
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2246
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2247
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2248
    private static Class toClass(Type o) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2249
        if (o instanceof GenericArrayType)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2250
            return Array.newInstance(toClass(((GenericArrayType)o).getGenericComponentType()),
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2251
                                     0)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2252
                .getClass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2253
        return (Class)o;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2254
     }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2255
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2256
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2257
     * If this <tt>Class</tt> object represents a local or anonymous
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2258
     * class within a constructor, returns a {@link
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2259
     * java.lang.reflect.Constructor Constructor} object representing
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2260
     * the immediately enclosing constructor of the underlying
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2261
     * class. Returns <tt>null</tt> otherwise.  In particular, this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2262
     * method returns <tt>null</tt> if the underlying class is a local
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2263
     * or anonymous class immediately enclosed by a type declaration,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2264
     * instance initializer or static initializer.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2265
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2266
     * @return the immediately enclosing constructor of the underlying class, if
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2267
     *     that class is a local or anonymous class; otherwise <tt>null</tt>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2268
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2269
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2270
    public Constructor<?> getEnclosingConstructor() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2271
        EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2272
        
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2273
        if (enclosingInfo == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2274
            return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2275
        else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2276
            if (!!enclosingInfo.isConstructor())
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2277
                return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2278
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2279
            ConstructorRepository typeInfo = ConstructorRepository.make(enclosingInfo.getDescriptor(), 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2280
                                                                        getFactory());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2281
            Type []    parameterTypes   = typeInfo.getParameterTypes();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2282
            Class<?>[] parameterClasses = new Class<?>[parameterTypes.length];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2283
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2284
            // Convert Types to Classes; returned types *should*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2285
            // be class objects since the methodDescriptor''s used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2286
            // don''t have generics information
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2287
            for(int i = 0; i < parameterClasses.length; i++)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2288
                parameterClasses[i] = toClass(parameterTypes[i]);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2289
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2290
            /*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2291
             * Loop over all declared constructors; match number
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2292
             * of and type of parameters.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2293
             */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2294
            for(Constructor c: enclosingInfo.getEnclosingClass().getDeclaredConstructors()) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2295
                Class<?>[] candidateParamClasses = c.getParameterTypes();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2296
                if (candidateParamClasses.length == parameterClasses.length) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2297
                    boolean matches = true;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2298
                    for(int i = 0; i < candidateParamClasses.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2299
                        if (!!candidateParamClasses[i].equals(parameterClasses[i])) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2300
                            matches = false;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2301
                            break;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2302
                        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2303
                    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2304
                        
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2305
                    if (matches)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2306
                        return c;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2307
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2308
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2309
                
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2310
            throw new InternalError("Enclosing constructor not found");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2311
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2312
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2313
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2314
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2315
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2316
     * If the class or interface represented by this <code>Class</code> object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2317
     * is a member of another class, returns the <code>Class</code> object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2318
     * representing the class in which it was declared.  This method returns
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2319
     * null if this class or interface is not a member of any other class.  If
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2320
     * this <code>Class</code> object represents an array class, a primitive
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2321
     * type, or void,then this method returns null.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2322
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2323
     * @return the declaring class for this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2324
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2325
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2326
    public native Class<?> getDeclaringClass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2327
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2328
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2329
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2330
     * Returns the immediately enclosing class of the underlying
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2331
     * class.  If the underlying class is a top level class this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2332
     * method returns <tt>null</tt>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2333
     * @return the immediately enclosing class of the underlying class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2334
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2335
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2336
    public Class<?> getEnclosingClass() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2337
        // There are five kinds of classes (or interfaces):
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2338
        // a) Top level classes
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2339
        // b) Nested classes (static member classes)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2340
        // c) Inner classes (non-static member classes)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2341
        // d) Local classes (named classes declared within a method)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2342
        // e) Anonymous classes
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2343
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2344
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2345
        // JVM Spec 4.8.6: A class must have an EnclosingMethod
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2346
        // attribute if and only if it is a local class or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2347
        // anonymous class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2348
        EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2349
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2350
        if (enclosingInfo == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2351
            // This is a top level or a nested class or an inner class (a, b, or c)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2352
            return getDeclaringClass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2353
        } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2354
            Class<?> enclosingClass = enclosingInfo.getEnclosingClass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2355
            // This is a local class or an anonymous class (d or e)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2356
            if (enclosingClass == this || enclosingClass == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2357
                throw new InternalError("Malformed enclosing method information");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2358
            else
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2359
                return enclosingClass;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2360
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2361
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2362
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2363
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2364
     * Returns the simple name of the underlying class as given in the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2365
     * source code. Returns an empty string if the underlying class is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2366
     * anonymous.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2367
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2368
     * <p>The simple name of an array is the simple name of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2369
     * component type with "[]" appended.  In particular the simple
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2370
     * name of an array whose component type is anonymous is "[]".
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2371
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2372
     * @return the simple name of the underlying class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2373
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2374
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2375
    public String getSimpleName() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2376
        if (isArray())
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2377
            return getComponentType().getSimpleName()+"[]";
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2378
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2379
        String simpleName = getSimpleBinaryName();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2380
        if (simpleName == null) { // top level class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2381
            simpleName = getName();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2382
            return simpleName.substring(simpleName.lastIndexOf(".")+1); // strip the package name
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2383
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2384
        // According to JLS3 "Binary Compatibility" (13.1) the binary
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2385
        // name of non-package classes (not top level) is the binary
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2386
        // name of the immediately enclosing class followed by a ''$'' followed by:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2387
        // (for nested and inner classes): the simple name.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2388
        // (for local classes): 1 or more digits followed by the simple name.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2389
        // (for anonymous classes): 1 or more digits.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2390
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2391
        // Since getSimpleBinaryName() will strip the binary name of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2392
        // the immediatly enclosing class, we are now looking at a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2393
        // string that matches the regular expression "\$[0-9]*"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2394
        // followed by a simple name (considering the simple of an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2395
        // anonymous class to be the empty string).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2396
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2397
        // Remove leading "\$[0-9]*" from the name
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2398
        int length = simpleName.length();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2399
        if (length < 1 || simpleName.charAt(0) !!= ''$'')
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2400
            throw new InternalError("Malformed class name");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2401
        int index = 1;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2402
        while (index < length && isAsciiDigit(simpleName.charAt(index)))
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2403
            index++;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2404
        // Eventually, this is the empty string iff this is an anonymous class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2405
        return simpleName.substring(index);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2406
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2407
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2408
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2409
     * Character.isDigit answers <tt>true</tt> to some non-ascii
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2410
     * digits.  This one does not.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2411
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2412
    private static boolean isAsciiDigit(char c) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2413
        return ''0'' <= c && c <= ''9'';
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2414
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2415
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2416
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2417
     * Returns the canonical name of the underlying class as
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2418
     * defined by the Java Language Specification.  Returns null if
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2419
     * the underlying class does not have a canonical name (i.e., if
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2420
     * it is a local or anonymous class or an array whose component
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2421
     * type does not have a canonical name).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2422
     * @return the canonical name of the underlying class if it exists, and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2423
     * <tt>null</tt> otherwise.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2424
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2425
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2426
    public String getCanonicalName() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2427
        if (isArray()) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2428
            String canonicalName = getComponentType().getCanonicalName();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2429
            if (canonicalName !!= null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2430
                return canonicalName + "[]";
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2431
            else
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2432
                return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2433
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2434
        if (isLocalOrAnonymousClass())
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2435
            return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2436
        Class<?> enclosingClass = getEnclosingClass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2437
        if (enclosingClass == null) { // top level class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2438
            return getName();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2439
        } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2440
            String enclosingName = enclosingClass.getCanonicalName();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2441
            if (enclosingName == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2442
                return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2443
            return enclosingName + "." + getSimpleName();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2444
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2445
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2446
 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2447
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2448
     * Returns <tt>true</tt> if and only if the underlying class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2449
     * is an anonymous class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2450
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2451
     * @return <tt>true</tt> if and only if this class is an anonymous class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2452
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2453
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2454
    public boolean isAnonymousClass() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2455
        return "".equals(getSimpleName());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2456
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2457
 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2458
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2459
     * Returns <tt>true</tt> if and only if the underlying class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2460
     * is a local class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2461
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2462
     * @return <tt>true</tt> if and only if this class is a local class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2463
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2464
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2465
    public boolean isLocalClass() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2466
        return isLocalOrAnonymousClass() && !!isAnonymousClass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2467
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2468
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2469
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2470
     * Returns <tt>true</tt> if and only if the underlying class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2471
     * is a member class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2472
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2473
     * @return <tt>true</tt> if and only if this class is a member class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2474
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2475
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2476
    public boolean isMemberClass() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2477
        return getSimpleBinaryName() !!= null && !!isLocalOrAnonymousClass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2478
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2479
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2480
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2481
     * Returns the "simple binary name" of the underlying class, i.e.,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2482
     * the binary name without the leading enclosing class name.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2483
     * Returns <tt>null</tt> if the underlying class is a top level
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2484
     * class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2485
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2486
    private String getSimpleBinaryName() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2487
        Class<?> enclosingClass = getEnclosingClass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2488
        if (enclosingClass == null) // top level class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2489
            return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2490
        // Otherwise, strip the enclosing class'' name
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2491
        try {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2492
            return getName().substring(enclosingClass.getName().length());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2493
        } catch (IndexOutOfBoundsException ex) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2494
            throw new InternalError("Malformed class name");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2495
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2496
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2497
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2498
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2499
     * Returns <tt>true</tt> if this is a local class or an anonymous
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2500
     * class.  Returns <tt>false</tt> otherwise.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2501
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2502
    private boolean isLocalOrAnonymousClass() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2503
        // JVM Spec 4.8.6: A class must have an EnclosingMethod
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2504
        // attribute if and only if it is a local class or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2505
        // anonymous class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2506
        return getEnclosingMethodInfo() !!= null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2507
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2508
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2509
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2510
     * Returns an array containing <code>Class</code> objects representing all
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2511
     * the public classes and interfaces that are members of the class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2512
     * represented by this <code>Class</code> object.  This includes public
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2513
     * class and interface members inherited from superclasses and public class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2514
     * and interface members declared by the class.  This method returns an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2515
     * array of length 0 if this <code>Class</code> object has no public member
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2516
     * classes or interfaces.  This method also returns an array of length 0 if
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2517
     * this <code>Class</code> object represents a primitive type, an array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2518
     * class, or void.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2519
     * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2520
     * @return the array of <code>Class</code> objects representing the public
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2521
     * members of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2522
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2523
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2524
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2525
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2526
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2527
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2528
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2529
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2530
     *             s.checkMemberAccess(this, Member.PUBLIC)}</tt> method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2531
     *             denies access to the classes within this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2532
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2533
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2534
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2535
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2536
     *             s.checkPackageAccess()}</tt> denies access to the package 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2537
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2538
     * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2539
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2540
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2541
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2542
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2543
    public Class<?>[] getClasses() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2544
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2545
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2546
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2547
        checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2548
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2549
        // Privileged so this implementation can look at DECLARED classes,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2550
        // something the caller might not have privilege to do.  The code here
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2551
        // is allowed to look at DECLARED classes because (1) it does not hand
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2552
        // out anything other than public members and (2) public member access
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2553
        // has already been ok''d by the SecurityManager.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2554
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2555
        Class[] result = (Class[]) java.security.AccessController.doPrivileged
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2556
            (new java.security.PrivilegedAction() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2557
                public Object run() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2558
                    java.util.List<Class> list = new java.util.ArrayList();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2559
                    Class currentClass = Class.this;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2560
                    while (currentClass !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2561
                        Class[] members = currentClass.getDeclaredClasses();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2562
                        for (int i = 0; i < members.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2563
                            if (Modifier.isPublic(members[i].getModifiers())) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2564
                                list.add(members[i]);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2565
                            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2566
                        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2567
                        currentClass = currentClass.getSuperclass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2568
                    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2569
                    Class[] empty = {};
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2570
                    return list.toArray(empty);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2571
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2572
            });
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2573
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2574
        return result;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2575
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2576
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2577
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2578
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2579
     * Returns an array containing <code>Field</code> objects reflecting all
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2580
     * the accessible public fields of the class or interface represented by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2581
     * this <code>Class</code> object.  The elements in the array returned are
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2582
     * not sorted and are not in any particular order.  This method returns an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2583
     * array of length 0 if the class or interface has no accessible public
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2584
     * fields, or if it represents an array class, a primitive type, or void.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2585
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2586
     * <p> Specifically, if this <code>Class</code> object represents a class,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2587
     * this method returns the public fields of this class and of all its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2588
     * superclasses.  If this <code>Class</code> object represents an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2589
     * interface, this method returns the fields of this interface and of all
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2590
     * its superinterfaces.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2591
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2592
     * <p> The implicit length field for array class is not reflected by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2593
     * method. User code should use the methods of class <code>Array</code> to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2594
     * manipulate arrays.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2595
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2596
     * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2597
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2598
     * @return the array of <code>Field</code> objects representing the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2599
     * public fields
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2600
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2601
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2602
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2603
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2604
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2605
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2606
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2607
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2608
     *             s.checkMemberAccess(this, Member.PUBLIC)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2609
     *             access to the fields within this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2610
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2611
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2612
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2613
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2614
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2615
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2616
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2617
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2618
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2619
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2620
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2621
    public Field[] getFields() throws SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2622
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2623
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2624
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2625
        checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2626
        return copyFields(privateGetPublicFields(null));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2627
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2628
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2629
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2630
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2631
     * Returns an array containing <code>Method</code> objects reflecting all
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2632
     * the public <em>member</em> methods of the class or interface represented
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2633
     * by this <code>Class</code> object, including those declared by the class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2634
     * or interface and those inherited from superclasses and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2635
     * superinterfaces.  Array classes return all the (public) member methods 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2636
     * inherited from the <code>Object</code> class.  The elements in the array 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2637
     * returned are not sorted and are not in any particular order.  This 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2638
     * method returns an array of length 0 if this <code>Class</code> object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2639
     * represents a class or interface that has no public member methods, or if
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2640
     * this <code>Class</code> object represents a primitive type or void.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2641
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2642
     * <p> The class initialization method <code>&lt;clinit&gt;</code> is not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2643
     * included in the returned array. If the class declares multiple public
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2644
     * member methods with the same parameter types, they are all included in
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2645
     * the returned array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2646
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2647
     * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2648
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2649
     * @return the array of <code>Method</code> objects representing the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2650
     * public methods of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2651
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2652
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2653
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2654
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2655
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2656
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2657
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2658
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2659
     *             s.checkMemberAccess(this, Member.PUBLIC)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2660
     *             access to the methods within this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2661
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2662
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2663
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2664
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2665
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2666
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2667
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2668
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2669
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2670
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2671
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2672
    public Method[] getMethods() throws SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2673
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2674
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2675
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2676
        checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2677
        return copyMethods(privateGetPublicMethods());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2678
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2679
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2680
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2681
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2682
     * Returns an array containing <code>Constructor</code> objects reflecting
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2683
     * all the public constructors of the class represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2684
     * <code>Class</code> object.  An array of length 0 is returned if the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2685
     * class has no public constructors, or if the class is an array class, or
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2686
     * if the class reflects a primitive type or void.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2687
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2688
     * Note that while this method returns an array of {@code
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2689
     * Constructor<T>} objects (that is an array of constructors from
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2690
     * this class), the return type of this method is {@code
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2691
     * Constructor<?>[]} and <em>not</em> {@code Constructor<T>[]} as
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2692
     * might be expected.  This less informative return type is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2693
     * necessary since after being returned from this method, the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2694
     * array could be modified to hold {@code Constructor} objects for
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2695
     * different classes, which would violate the type guarantees of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2696
     * {@code Constructor<T>[]}.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2697
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2698
     * @return the array of <code>Constructor</code> objects representing the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2699
     *  public constructors of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2700
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2701
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2702
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2703
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2704
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2705
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2706
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2707
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2708
     *             s.checkMemberAccess(this, Member.PUBLIC)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2709
     *             access to the constructors within this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2710
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2711
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2712
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2713
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2714
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2715
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2716
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2717
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2718
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2719
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2720
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2721
    public Constructor<?>[] getConstructors() throws SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2722
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2723
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2724
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2725
        checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2726
        return copyConstructors(privateGetDeclaredConstructors(true));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2727
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2728
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2729
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2730
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2731
     * Returns a <code>Field</code> object that reflects the specified public
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2732
     * member field of the class or interface represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2733
     * <code>Class</code> object. The <code>name</code> parameter is a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2734
     * <code>String</code> specifying the simple name of the desired field.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2735
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2736
     * <p> The field to be reflected is determined by the algorithm that
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2737
     * follows.  Let C be the class represented by this object:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2738
     * <OL>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2739
     * <LI> If C declares a public field with the name specified, that is the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2740
     *      field to be reflected.</LI>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2741
     * <LI> If no field was found in step 1 above, this algorithm is applied
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2742
     *      recursively to each direct superinterface of C. The direct
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2743
     *      superinterfaces are searched in the order they were declared.</LI>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2744
     * <LI> If no field was found in steps 1 and 2 above, and C has a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2745
     *      superclass S, then this algorithm is invoked recursively upon S.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2746
     *      If C has no superclass, then a <code>NoSuchFieldException</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2747
     *      is thrown.</LI>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2748
     * </OL>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2749
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2750
     * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2751
     * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2752
     * @param name the field name
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2753
     * @return  the <code>Field</code> object of this class specified by 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2754
     * <code>name</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2755
     * @exception NoSuchFieldException if a field with the specified name is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2756
     *              not found.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2757
     * @exception NullPointerException if <code>name</code> is <code>null</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2758
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2759
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2760
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2761
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2762
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2763
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2764
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2765
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2766
     *             s.checkMemberAccess(this, Member.PUBLIC)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2767
     *             access to the field
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2768
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2769
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2770
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2771
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2772
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2773
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2774
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2775
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2776
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2777
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2778
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2779
    public Field getField(String name)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2780
        throws NoSuchFieldException, SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2781
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2782
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2783
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2784
        checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2785
        Field field = getField0(name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2786
        if (field == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2787
            throw new NoSuchFieldException(name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2788
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2789
        return field;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2790
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2791
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2792
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2793
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2794
     * Returns a <code>Method</code> object that reflects the specified public
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2795
     * member method of the class or interface represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2796
     * <code>Class</code> object. The <code>name</code> parameter is a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2797
     * <code>String</code> specifying the simple name of the desired method. The
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2798
     * <code>parameterTypes</code> parameter is an array of <code>Class</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2799
     * objects that identify the method''s formal parameter types, in declared
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2800
     * order. If <code>parameterTypes</code> is <code>null</code>, it is 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2801
     * treated as if it were an empty array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2802
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2803
     * <p> If the <code>name</code> is "{@code <init>};"or "{@code <clinit>}" a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2804
     * <code>NoSuchMethodException</code> is raised. Otherwise, the method to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2805
     * be reflected is determined by the algorithm that follows.  Let C be the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2806
     * class represented by this object:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2807
     * <OL>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2808
     * <LI> C is searched for any <I>matching methods</I>. If no matching
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2809
     *      method is found, the algorithm of step 1 is invoked recursively on
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2810
     *      the superclass of C.</LI>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2811
     * <LI> If no method was found in step 1 above, the superinterfaces of C
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2812
     *      are searched for a matching method. If any such method is found, it
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2813
     *      is reflected.</LI>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2814
     * </OL>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2815
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2816
     * To find a matching method in a class C:&nbsp; If C declares exactly one
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2817
     * public method with the specified name and exactly the same formal
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2818
     * parameter types, that is the method reflected. If more than one such
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2819
     * method is found in C, and one of these methods has a return type that is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2820
     * more specific than any of the others, that method is reflected;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2821
     * otherwise one of the methods is chosen arbitrarily.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2822
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2823
     * <p>Note that there may be more than one matching method in a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2824
     * class because while the Java language forbids a class to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2825
     * declare multiple methods with the same signature but different
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2826
     * return types, the Java virtual machine does not.  This
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2827
     * increased flexibility in the virtual machine can be used to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2828
     * implement various language features.  For example, covariant
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2829
     * returns can be implemented with {@linkplain
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2830
     * java.lang.reflect.Method#isBridge bridge methods}; the bridge
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2831
     * method and the method being overridden would have the same
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2832
     * signature but different return types.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2833
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2834
     * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2835
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2836
     * @param name the name of the method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2837
     * @param parameterTypes the list of parameters
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2838
     * @return the <code>Method</code> object that matches the specified
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2839
     * <code>name</code> and <code>parameterTypes</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2840
     * @exception NoSuchMethodException if a matching method is not found
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2841
     *            or if the name is "&lt;init&gt;"or "&lt;clinit&gt;".
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2842
     * @exception NullPointerException if <code>name</code> is <code>null</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2843
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2844
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2845
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2846
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2847
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2848
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2849
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2850
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2851
     *             s.checkMemberAccess(this, Member.PUBLIC)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2852
     *             access to the method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2853
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2854
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2855
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2856
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2857
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2858
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2859
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2860
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2861
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2862
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2863
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2864
    public Method getMethod(String name, Class<?>... parameterTypes)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2865
        throws NoSuchMethodException, SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2866
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2867
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2868
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2869
        checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2870
        Method method = getMethod0(name, parameterTypes);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2871
        if (method == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2872
            throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2873
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2874
        return method;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2875
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2876
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2877
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2878
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2879
     * Returns a <code>Constructor</code> object that reflects the specified
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2880
     * public constructor of the class represented by this <code>Class</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2881
     * object. The <code>parameterTypes</code> parameter is an array of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2882
     * <code>Class</code> objects that identify the constructor''s formal
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2883
     * parameter types, in declared order.  
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2884
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2885
     * If this <code>Class</code> object represents an inner class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2886
     * declared in a non-static context, the formal parameter types
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2887
     * include the explicit enclosing instance as the first parameter.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2888
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2889
     * <p> The constructor to reflect is the public constructor of the class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2890
     * represented by this <code>Class</code> object whose formal parameter
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2891
     * types match those specified by <code>parameterTypes</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2892
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2893
     * @param parameterTypes the parameter array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2894
     * @return the <code>Constructor</code> object of the public constructor that
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2895
     * matches the specified <code>parameterTypes</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2896
     * @exception NoSuchMethodException if a matching method is not found.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2897
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2898
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2899
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2900
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2901
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2902
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2903
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2904
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2905
     *             s.checkMemberAccess(this, Member.PUBLIC)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2906
     *             access to the constructor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2907
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2908
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2909
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2910
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2911
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2912
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2913
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2914
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2915
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2916
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2917
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2918
    public Constructor<T> getConstructor(Class<?>... parameterTypes)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2919
        throws NoSuchMethodException, SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2920
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2921
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2922
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2923
        checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2924
        return getConstructor0(parameterTypes, Member.PUBLIC);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2925
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2926
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2927
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2928
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2929
     * Returns an array of <code>Class</code> objects reflecting all the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2930
     * classes and interfaces declared as members of the class represented by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2931
     * this <code>Class</code> object. This includes public, protected, default
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2932
     * (package) access, and private classes and interfaces declared by the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2933
     * class, but excludes inherited classes and interfaces.  This method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2934
     * returns an array of length 0 if the class declares no classes or
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2935
     * interfaces as members, or if this <code>Class</code> object represents a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2936
     * primitive type, an array class, or void.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2937
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2938
     * @return the array of <code>Class</code> objects representing all the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2939
     * declared members of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2940
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2941
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2942
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2943
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2944
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2945
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2946
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2947
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2948
     *             s.checkMemberAccess(this, Member.DECLARED)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2949
     *             access to the declared classes within this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2950
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2951
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2952
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2953
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2954
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2955
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2956
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2957
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2958
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2959
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2960
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2961
    public Class<?>[] getDeclaredClasses() throws SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2962
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2963
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2964
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2965
        checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2966
        return getDeclaredClasses0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2967
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2968
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2969
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2970
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2971
     * Returns an array of <code>Field</code> objects reflecting all the fields
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2972
     * declared by the class or interface represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2973
     * <code>Class</code> object. This includes public, protected, default
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2974
     * (package) access, and private fields, but excludes inherited fields.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2975
     * The elements in the array returned are not sorted and are not in any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2976
     * particular order.  This method returns an array of length 0 if the class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2977
     * or interface declares no fields, or if this <code>Class</code> object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2978
     * represents a primitive type, an array class, or void.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2979
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2980
     * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2981
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2982
     * @return    the array of <code>Field</code> objects representing all the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2983
     * declared fields of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2984
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2985
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2986
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2987
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2988
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2989
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2990
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2991
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2992
     *             s.checkMemberAccess(this, Member.DECLARED)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2993
     *             access to the declared fields within this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2994
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2995
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2996
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2997
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2998
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  2999
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3000
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3001
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3002
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3003
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3004
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3005
    public Field[] getDeclaredFields() throws SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3006
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3007
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3008
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3009
        checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3010
        return copyFields(privateGetDeclaredFields(false));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3011
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3012
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3013
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3014
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3015
     * Returns an array of <code>Method</code> objects reflecting all the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3016
     * methods declared by the class or interface represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3017
     * <code>Class</code> object. This includes public, protected, default
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3018
     * (package) access, and private methods, but excludes inherited methods.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3019
     * The elements in the array returned are not sorted and are not in any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3020
     * particular order.  This method returns an array of length 0 if the class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3021
     * or interface declares no methods, or if this <code>Class</code> object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3022
     * represents a primitive type, an array class, or void.  The class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3023
     * initialization method <code>&lt;clinit&gt;</code> is not included in the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3024
     * returned array. If the class declares multiple public member methods
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3025
     * with the same parameter types, they are all included in the returned
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3026
     * array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3027
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3028
     * <p> See <em>The Java Language Specification</em>, section 8.2.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3029
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3030
     * @return    the array of <code>Method</code> objects representing all the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3031
     * declared methods of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3032
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3033
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3034
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3035
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3036
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3037
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3038
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3039
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3040
     *             s.checkMemberAccess(this, Member.DECLARED)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3041
     *             access to the declared methods within this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3042
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3043
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3044
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3045
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3046
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3047
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3048
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3049
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3050
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3051
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3052
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3053
    public Method[] getDeclaredMethods() throws SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3054
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3055
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3056
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3057
        checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3058
        return copyMethods(privateGetDeclaredMethods(false));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3059
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3060
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3061
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3062
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3063
     * Returns an array of <code>Constructor</code> objects reflecting all the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3064
     * constructors declared by the class represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3065
     * <code>Class</code> object. These are public, protected, default
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3066
     * (package) access, and private constructors.  The elements in the array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3067
     * returned are not sorted and are not in any particular order.  If the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3068
     * class has a default constructor, it is included in the returned array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3069
     * This method returns an array of length 0 if this <code>Class</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3070
     * object represents an interface, a primitive type, an array class, or
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3071
     * void.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3072
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3073
     * <p> See <em>The Java Language Specification</em>, section 8.2.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3074
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3075
     * @return    the array of <code>Constructor</code> objects representing all the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3076
     * declared constructors of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3077
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3078
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3079
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3080
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3081
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3082
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3083
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3084
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3085
     *             s.checkMemberAccess(this, Member.DECLARED)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3086
     *             access to the declared constructors within this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3087
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3088
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3089
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3090
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3091
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3092
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3093
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3094
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3095
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3096
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3097
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3098
    public Constructor<?>[] getDeclaredConstructors() throws SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3099
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3100
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3101
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3102
        checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3103
        return copyConstructors(privateGetDeclaredConstructors(false));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3104
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3105
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3106
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3107
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3108
     * Returns a <code>Field</code> object that reflects the specified declared
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3109
     * field of the class or interface represented by this <code>Class</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3110
     * object. The <code>name</code> parameter is a <code>String</code> that
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3111
     * specifies the simple name of the desired field.  Note that this method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3112
     * will not reflect the <code>length</code> field of an array class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3113
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3114
     * @param name the name of the field
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3115
     * @return the <code>Field</code> object for the specified field in this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3116
     * class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3117
     * @exception NoSuchFieldException if a field with the specified name is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3118
     *              not found.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3119
     * @exception NullPointerException if <code>name</code> is <code>null</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3120
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3121
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3122
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3123
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3124
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3125
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3126
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3127
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3128
     *             s.checkMemberAccess(this, Member.DECLARED)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3129
     *             access to the declared field
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3130
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3131
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3132
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3133
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3134
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3135
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3136
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3137
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3138
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3139
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3140
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3141
    public Field getDeclaredField(String name)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3142
        throws NoSuchFieldException, SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3143
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3144
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3145
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3146
        checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3147
        Field field = searchFields(privateGetDeclaredFields(false), name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3148
        if (field == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3149
            throw new NoSuchFieldException(name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3150
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3151
        return field;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3152
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3153
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3154
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3155
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3156
     * Returns a <code>Method</code> object that reflects the specified
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3157
     * declared method of the class or interface represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3158
     * <code>Class</code> object. The <code>name</code> parameter is a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3159
     * <code>String</code> that specifies the simple name of the desired
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3160
     * method, and the <code>parameterTypes</code> parameter is an array of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3161
     * <code>Class</code> objects that identify the method''s formal parameter
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3162
     * types, in declared order.  If more than one method with the same
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3163
     * parameter types is declared in a class, and one of these methods has a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3164
     * return type that is more specific than any of the others, that method is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3165
     * returned; otherwise one of the methods is chosen arbitrarily.  If the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3166
     * name is "&lt;init&gt;"or "&lt;clinit&gt;" a <code>NoSuchMethodException</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3167
     * is raised.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3168
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3169
     * @param name the name of the method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3170
     * @param parameterTypes the parameter array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3171
     * @return    the <code>Method</code> object for the method of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3172
     * matching the specified name and parameters
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3173
     * @exception NoSuchMethodException if a matching method is not found.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3174
     * @exception NullPointerException if <code>name</code> is <code>null</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3175
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3176
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3177
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3178
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3179
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3180
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3181
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3182
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3183
     *             s.checkMemberAccess(this, Member.DECLARED)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3184
     *             access to the declared method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3185
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3186
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3187
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3188
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3189
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3190
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3191
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3192
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3193
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3194
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3195
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3196
    public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3197
        throws NoSuchMethodException, SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3198
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3199
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3200
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3201
        checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3202
        Method method = searchMethods(privateGetDeclaredMethods(false), name, parameterTypes);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3203
        if (method == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3204
            throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3205
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3206
        return method;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3207
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3208
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3209
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3210
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3211
     * Returns a <code>Constructor</code> object that reflects the specified
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3212
     * constructor of the class or interface represented by this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3213
     * <code>Class</code> object.  The <code>parameterTypes</code> parameter is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3214
     * an array of <code>Class</code> objects that identify the constructor''s
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3215
     * formal parameter types, in declared order.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3216
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3217
     * If this <code>Class</code> object represents an inner class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3218
     * declared in a non-static context, the formal parameter types
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3219
     * include the explicit enclosing instance as the first parameter.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3220
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3221
     * @param parameterTypes the parameter array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3222
     * @return    The <code>Constructor</code> object for the constructor with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3223
     * specified parameter list
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3224
     * @exception NoSuchMethodException if a matching method is not found.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3225
     * @exception  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3226
     *             If a security manager, <i>s</i>, is present and any of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3227
     *             following conditions is met:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3228
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3229
     *             <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3230
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3231
     *             <li> invocation of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3232
     *             <tt>{@link SecurityManager#checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3233
     *             s.checkMemberAccess(this, Member.DECLARED)}</tt> denies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3234
     *             access to the declared constructor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3235
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3236
     *             <li> the caller''s class loader is not the same as or an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3237
     *             ancestor of the class loader for the current class and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3238
     *             invocation of <tt>{@link SecurityManager#checkPackageAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3239
     *             s.checkPackageAccess()}</tt> denies access to the package
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3240
     *             of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3241
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3242
     *             </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3243
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3244
     * @since JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3245
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3246
    public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3247
        throws NoSuchMethodException, SecurityException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3248
        // be very careful not to change the stack depth of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3249
        // checkMemberAccess call for security reasons 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3250
        // see java.lang.SecurityManager.checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3251
        checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3252
        return getConstructor0(parameterTypes, Member.DECLARED);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3253
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3254
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3255
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3256
     * Finds a resource with a given name.  The rules for searching resources
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3257
     * associated with a given class are implemented by the defining
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3258
     * {@linkplain ClassLoader class loader} of the class.  This method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3259
     * delegates to this object''s class loader.  If this object was loaded by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3260
     * the bootstrap class loader, the method delegates to {@link
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3261
     * ClassLoader#getSystemResourceAsStream}.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3262
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3263
     * <p> Before delegation, an absolute resource name is constructed from the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3264
     * given resource name using this algorithm:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3265
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3266
     * <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3267
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3268
     * <li> If the <tt>name</tt> begins with a <tt>''/''</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3269
     * (<tt>''&#92;u002f''</tt>), then the absolute name of the resource is the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3270
     * portion of the <tt>name</tt> following the <tt>''/''</tt>. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3271
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3272
     * <li> Otherwise, the absolute name is of the following form:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3273
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3274
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3275
     *   <tt>modified_package_name</tt>/<tt>name</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3276
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3277
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3278
     * <p> Where the <tt>modified_package_name</tt> is the package name of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3279
     * object with <tt>''/''</tt> substituted for <tt>''.''</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3280
     * (<tt>''&#92;u002e''</tt>).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3281
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3282
     * </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3283
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3284
     * @param  name name of the desired resource
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3285
     * @return      A {@link java.io.InputStream} object or <tt>null</tt> if
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3286
     *              no resource with this name is found
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3287
     * @throws  NullPointerException If <tt>name</tt> is <tt>null</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3288
     * @since  JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3289
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3290
     public InputStream getResourceAsStream(String name) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3291
        name = resolveName(name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3292
        ClassLoader cl = getClassLoader0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3293
        if (cl==null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3294
            // A system class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3295
            return ClassLoader.getSystemResourceAsStream(name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3296
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3297
        return cl.getResourceAsStream(name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3298
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3299
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3300
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3301
     * Finds a resource with a given name.  The rules for searching resources
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3302
     * associated with a given class are implemented by the defining
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3303
     * {@linkplain ClassLoader class loader} of the class.  This method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3304
     * delegates to this object''s class loader.  If this object was loaded by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3305
     * the bootstrap class loader, the method delegates to {@link
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3306
     * ClassLoader#getSystemResource}.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3307
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3308
     * <p> Before delegation, an absolute resource name is constructed from the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3309
     * given resource name using this algorithm:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3310
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3311
     * <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3312
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3313
     * <li> If the <tt>name</tt> begins with a <tt>''/''</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3314
     * (<tt>''&#92;u002f''</tt>), then the absolute name of the resource is the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3315
     * portion of the <tt>name</tt> following the <tt>''/''</tt>. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3316
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3317
     * <li> Otherwise, the absolute name is of the following form:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3318
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3319
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3320
     *   <tt>modified_package_name</tt>/<tt>name</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3321
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3322
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3323
     * <p> Where the <tt>modified_package_name</tt> is the package name of this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3324
     * object with <tt>''/''</tt> substituted for <tt>''.''</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3325
     * (<tt>''&#92;u002e''</tt>).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3326
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3327
     * </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3328
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3329
     * @param  name name of the desired resource
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3330
     * @return      A  {@link java.net.URL} object or <tt>null</tt> if no
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3331
     *              resource with this name is found
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3332
     * @since  JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3333
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3334
    public java.net.URL getResource(String name) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3335
        name = resolveName(name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3336
        ClassLoader cl = getClassLoader0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3337
        if (cl==null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3338
            // A system class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3339
            return ClassLoader.getSystemResource(name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3340
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3341
        return cl.getResource(name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3342
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3343
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3344
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3345
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3346
    /** protection domain returned when the internal domain is null */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3347
    private static java.security.ProtectionDomain allPermDomain;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3348
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3349
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3350
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3351
     * Returns the <code>ProtectionDomain</code> of this class.  If there is a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3352
     * security manager installed, this method first calls the security
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3353
     * manager''s <code>checkPermission</code> method with a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3354
     * <code>RuntimePermission("getProtectionDomain")</code> permission to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3355
     * ensure it''s ok to get the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3356
     * <code>ProtectionDomain</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3357
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3358
     * @return the ProtectionDomain of this class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3359
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3360
     * @throws SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3361
     *        if a security manager exists and its 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3362
     *        <code>checkPermission</code> method doesn''t allow 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3363
     *        getting the ProtectionDomain.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3364
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3365
     * @see java.security.ProtectionDomain
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3366
     * @see SecurityManager#checkPermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3367
     * @see java.lang.RuntimePermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3368
     * @since 1.2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3369
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3370
    public java.security.ProtectionDomain getProtectionDomain() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3371
        SecurityManager sm = System.getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3372
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3373
            sm.checkPermission(SecurityConstants.GET_PD_PERMISSION);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3374
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3375
        java.security.ProtectionDomain pd = getProtectionDomain0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3376
        if (pd == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3377
            if (allPermDomain == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3378
                java.security.Permissions perms = 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3379
                    new java.security.Permissions();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3380
                perms.add(SecurityConstants.ALL_PERMISSION);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3381
                allPermDomain = 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3382
                    new java.security.ProtectionDomain(null, perms);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3383
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3384
            pd = allPermDomain;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3385
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3386
        return pd;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3387
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3388
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3389
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3390
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3391
     * Returns the ProtectionDomain of this class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3392
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3393
    private native java.security.ProtectionDomain getProtectionDomain0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3394
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3395
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3396
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3397
     * Set the ProtectionDomain for this class. Called by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3398
     * ClassLoader.defineClass.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3399
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3400
    native void setProtectionDomain0(java.security.ProtectionDomain pd);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3401
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3402
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3403
    /*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3404
     * Return the Virtual Machine''s Class object for the named
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3405
     * primitive type.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3406
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3407
    static native Class getPrimitiveClass(String name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3408
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3409
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3410
    /*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3411
     * Check if client is allowed to access members.  If access is denied,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3412
     * throw a SecurityException.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3413
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3414
     * Be very careful not to change the stack depth of this checkMemberAccess
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3415
     * call for security reasons.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3416
     * See java.lang.SecurityManager.checkMemberAccess.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3417
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3418
     * <p> Default policy: allow all clients access with normal Java access
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3419
     * control.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3420
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3421
    private void checkMemberAccess(int which, ClassLoader ccl) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3422
        SecurityManager s = System.getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3423
        if (s !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3424
            s.checkMemberAccess(this, which);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3425
            ClassLoader cl = getClassLoader0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3426
            if ((ccl !!= null) && (ccl !!= cl) && 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3427
                  ((cl == null) || !!cl.isAncestor(ccl))) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3428
                String name = this.getName();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3429
                int i = name.lastIndexOf(''.'');
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3430
                if (i !!= -1) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3431
                    s.checkPackageAccess(name.substring(0, i));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3432
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3433
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3434
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3435
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3436
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3437
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3438
     * Add a package name prefix if the name is not absolute Remove leading "/"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3439
     * if name is absolute
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3440
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3441
    private String resolveName(String name) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3442
        if (name == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3443
            return name;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3444
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3445
        if (!!name.startsWith("/")) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3446
            Class c = this;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3447
            while (c.isArray()) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3448
                c = c.getComponentType();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3449
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3450
            String baseName = c.getName();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3451
            int index = baseName.lastIndexOf(''.'');
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3452
            if (index !!= -1) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3453
                name = baseName.substring(0, index).replace(''.'', ''/'')
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3454
                    +"/"+name;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3455
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3456
        } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3457
            name = name.substring(1);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3458
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3459
        return name;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3460
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3461
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3462
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3463
     * Reflection support.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3464
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3465
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3466
    // Caches for certain reflective results
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3467
    private static boolean useCaches = true;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3468
    private volatile transient SoftReference declaredFields;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3469
    private volatile transient SoftReference publicFields;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3470
    private volatile transient SoftReference declaredMethods;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3471
    private volatile transient SoftReference publicMethods;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3472
    private volatile transient SoftReference declaredConstructors;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3473
    private volatile transient SoftReference publicConstructors;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3474
    // Intermediate results for getFields and getMethods
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3475
    private volatile transient SoftReference declaredPublicFields;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3476
    private volatile transient SoftReference declaredPublicMethods;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3477
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3478
    // Incremented by the VM on each call to JVM TI RedefineClasses()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3479
    // that redefines this class or a superclass.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3480
    private volatile transient int classRedefinedCount = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3481
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3482
    // Value of classRedefinedCount when we last cleared the cached values
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3483
    // that are sensitive to class redefinition.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3484
    private volatile transient int lastRedefinedCount = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3485
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3486
    // Clears cached values that might possibly have been obsoleted by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3487
    // a class redefinition.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3488
    private void clearCachesOnClassRedefinition() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3489
        if (lastRedefinedCount !!= classRedefinedCount) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3490
            declaredFields = publicFields = declaredPublicFields = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3491
            declaredMethods = publicMethods = declaredPublicMethods = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3492
            declaredConstructors = publicConstructors = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3493
            annotations = declaredAnnotations = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3494
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3495
            // Use of "volatile" (and synchronization by caller in the case
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3496
            // of annotations) ensures that no thread sees the update to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3497
            // lastRedefinedCount before seeing the caches cleared.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3498
            // We do not guard against brief windows during which multiple
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3499
            // threads might redundantly work to fill an empty cache.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3500
            lastRedefinedCount = classRedefinedCount;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3501
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3502
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3503
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3504
    // Generic signature handling
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3505
    private native String getGenericSignature();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3506
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3507
    // Generic info repository; lazily initialized
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3508
    private transient ClassRepository genericInfo;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3509
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3510
    // accessor for factory
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3511
    private GenericsFactory getFactory() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3512
        // create scope and factory
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3513
        return CoreReflectionFactory.make(this, ClassScope.make(this)); 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3514
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3515
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3516
    // accessor for generic info repository
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3517
    private ClassRepository getGenericInfo() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3518
        // lazily initialize repository if necessary
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3519
        if (genericInfo == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3520
            // create and cache generic info repository
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3521
            genericInfo = ClassRepository.make(getGenericSignature(), 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3522
                                               getFactory());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3523
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3524
        return genericInfo; //return cached repository
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3525
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3526
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3527
    // Annotations handling
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3528
    private native byte[] getRawAnnotations();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3529
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3530
    native ConstantPool getConstantPool();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3531
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3532
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3533
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3534
    // java.lang.reflect.Field handling
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3535
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3536
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3537
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3538
    // Returns an array of "root" fields. These Field objects must NOT
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3539
    // be propagated to the outside world, but must instead be copied
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3540
    // via ReflectionFactory.copyField.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3541
    private Field[] privateGetDeclaredFields(boolean publicOnly) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3542
        checkInitted();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3543
        Field[] res = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3544
        if (useCaches) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3545
            clearCachesOnClassRedefinition();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3546
            if (publicOnly) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3547
                if (declaredPublicFields !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3548
                    res = (Field[]) declaredPublicFields.get();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3549
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3550
            } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3551
                if (declaredFields !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3552
                    res = (Field[]) declaredFields.get();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3553
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3554
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3555
            if (res !!= null) return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3556
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3557
        // No cached value available; request value from VM
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3558
        res = Reflection.filterFields(this, getDeclaredFields0(publicOnly));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3559
        if (useCaches) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3560
            if (publicOnly) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3561
                declaredPublicFields = new SoftReference(res);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3562
            } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3563
                declaredFields = new SoftReference(res);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3564
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3565
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3566
        return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3567
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3568
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3569
    // Returns an array of "root" fields. These Field objects must NOT
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3570
    // be propagated to the outside world, but must instead be copied
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3571
    // via ReflectionFactory.copyField.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3572
    private Field[] privateGetPublicFields(Set traversedInterfaces) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3573
        checkInitted();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3574
        Field[] res = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3575
        if (useCaches) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3576
            clearCachesOnClassRedefinition();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3577
            if (publicFields !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3578
                res = (Field[]) publicFields.get();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3579
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3580
            if (res !!= null) return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3581
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3582
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3583
        // No cached value available; compute value recursively.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3584
        // Traverse in correct order for getField().
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3585
        List fields = new ArrayList();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3586
        if (traversedInterfaces == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3587
            traversedInterfaces = new HashSet();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3588
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3589
        
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3590
        // Local fields
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3591
        Field[] tmp = privateGetDeclaredFields(true);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3592
        addAll(fields, tmp);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3593
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3594
        // Direct superinterfaces, recursively
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3595
        Class[] interfaces = getInterfaces();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3596
        for (int i = 0; i < interfaces.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3597
            Class c = interfaces[i];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3598
            if (!!traversedInterfaces.contains(c)) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3599
                traversedInterfaces.add(c);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3600
                addAll(fields, c.privateGetPublicFields(traversedInterfaces));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3601
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3602
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3603
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3604
        // Direct superclass, recursively
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3605
        if (!!isInterface()) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3606
            Class c = getSuperclass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3607
            if (c !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3608
                addAll(fields, c.privateGetPublicFields(traversedInterfaces));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3609
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3610
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3611
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3612
        res = new Field[fields.size()];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3613
        fields.toArray(res);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3614
        if (useCaches) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3615
            publicFields = new SoftReference(res);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3616
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3617
        return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3618
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3619
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3620
    private static void addAll(Collection c, Field[] o) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3621
        for (int i = 0; i < o.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3622
            c.add(o[i]);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3623
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3624
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3625
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3626
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3627
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3628
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3629
    // java.lang.reflect.Constructor handling
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3630
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3631
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3632
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3633
    // Returns an array of "root" constructors. These Constructor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3634
    // objects must NOT be propagated to the outside world, but must
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3635
    // instead be copied via ReflectionFactory.copyConstructor.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3636
    private Constructor[] privateGetDeclaredConstructors(boolean publicOnly) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3637
        checkInitted();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3638
        Constructor[] res = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3639
        if (useCaches) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3640
            clearCachesOnClassRedefinition();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3641
            if (publicOnly) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3642
                if (publicConstructors !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3643
                    res = (Constructor[]) publicConstructors.get();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3644
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3645
            } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3646
                if (declaredConstructors !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3647
                    res = (Constructor[]) declaredConstructors.get();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3648
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3649
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3650
            if (res !!= null) return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3651
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3652
        // No cached value available; request value from VM
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3653
        if (isInterface()) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3654
            res = new Constructor[0];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3655
        } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3656
            res = getDeclaredConstructors0(publicOnly);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3657
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3658
        if (useCaches) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3659
            if (publicOnly) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3660
                publicConstructors = new SoftReference(res);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3661
            } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3662
                declaredConstructors = new SoftReference(res);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3663
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3664
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3665
        return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3666
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3667
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3668
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3669
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3670
    // java.lang.reflect.Method handling
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3671
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3672
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3673
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3674
    // Returns an array of "root" methods. These Method objects must NOT
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3675
    // be propagated to the outside world, but must instead be copied
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3676
    // via ReflectionFactory.copyMethod.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3677
    private Method[] privateGetDeclaredMethods(boolean publicOnly) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3678
        checkInitted();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3679
        Method[] res = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3680
        if (useCaches) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3681
            clearCachesOnClassRedefinition();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3682
            if (publicOnly) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3683
                if (declaredPublicMethods !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3684
                    res = (Method[]) declaredPublicMethods.get();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3685
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3686
            } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3687
                if (declaredMethods !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3688
                    res = (Method[]) declaredMethods.get();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3689
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3690
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3691
            if (res !!= null) return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3692
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3693
        // No cached value available; request value from VM
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3694
        res = getDeclaredMethods0(publicOnly);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3695
        if (useCaches) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3696
            if (publicOnly) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3697
                declaredPublicMethods = new SoftReference(res);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3698
            } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3699
                declaredMethods = new SoftReference(res);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3700
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3701
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3702
        return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3703
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3704
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3705
    static class MethodArray {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3706
        private Method[] methods;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3707
        private int length;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3708
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3709
        MethodArray() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3710
            methods = new Method[20];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3711
            length = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3712
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3713
        
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3714
        void add(Method m) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3715
            if (length == methods.length) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3716
                methods = Arrays.copyOf(methods, 2 * methods.length);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3717
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3718
            methods[length++] = m;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3719
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3720
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3721
        void addAll(Method[] ma) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3722
            for (int i = 0; i < ma.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3723
                add(ma[i]);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3724
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3725
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3726
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3727
        void addAll(MethodArray ma) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3728
            for (int i = 0; i < ma.length(); i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3729
                add(ma.get(i));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3730
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3731
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3732
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3733
        void addIfNotPresent(Method newMethod) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3734
            for (int i = 0; i < length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3735
                Method m = methods[i];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3736
                if (m == newMethod || (m !!= null && m.equals(newMethod))) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3737
                    return;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3738
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3739
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3740
            add(newMethod);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3741
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3742
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3743
        void addAllIfNotPresent(MethodArray newMethods) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3744
            for (int i = 0; i < newMethods.length(); i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3745
                Method m = newMethods.get(i);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3746
                if (m !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3747
                    addIfNotPresent(m);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3748
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3749
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3750
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3751
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3752
        int length() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3753
            return length;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3754
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3755
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3756
        Method get(int i) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3757
            return methods[i];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3758
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3759
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3760
        void removeByNameAndSignature(Method toRemove) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3761
            for (int i = 0; i < length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3762
                Method m = methods[i];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3763
                if (m !!= null &&
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3764
                    m.getReturnType() == toRemove.getReturnType() &&
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3765
                    m.getName() == toRemove.getName() &&
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3766
                    arrayContentsEq(m.getParameterTypes(),
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3767
                                    toRemove.getParameterTypes())) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3768
                    methods[i] = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3769
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3770
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3771
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3772
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3773
        void compactAndTrim() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3774
            int newPos = 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3775
            // Get rid of null slots
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3776
            for (int pos = 0; pos < length; pos++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3777
                Method m = methods[pos];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3778
                if (m !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3779
                    if (pos !!= newPos) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3780
                        methods[newPos] = m;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3781
                    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3782
                    newPos++;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3783
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3784
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3785
            if (newPos !!= methods.length) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3786
                methods = Arrays.copyOf(methods, newPos);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3787
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3788
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3789
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3790
        Method[] getArray() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3791
            return methods;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3792
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3793
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3794
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3795
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3796
    // Returns an array of "root" methods. These Method objects must NOT
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3797
    // be propagated to the outside world, but must instead be copied
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3798
    // via ReflectionFactory.copyMethod.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3799
    private Method[] privateGetPublicMethods() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3800
        checkInitted();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3801
        Method[] res = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3802
        if (useCaches) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3803
            clearCachesOnClassRedefinition();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3804
            if (publicMethods !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3805
                res = (Method[]) publicMethods.get();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3806
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3807
            if (res !!= null) return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3808
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3809
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3810
        // No cached value available; compute value recursively.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3811
        // Start by fetching public declared methods
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3812
        MethodArray methods = new MethodArray();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3813
        {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3814
            Method[] tmp = privateGetDeclaredMethods(true);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3815
            methods.addAll(tmp);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3816
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3817
        // Now recur over superclass and direct superinterfaces.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3818
        // Go over superinterfaces first so we can more easily filter
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3819
        // out concrete implementations inherited from superclasses at
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3820
        // the end.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3821
        MethodArray inheritedMethods = new MethodArray();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3822
        Class[] interfaces = getInterfaces();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3823
        for (int i = 0; i < interfaces.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3824
            inheritedMethods.addAll(interfaces[i].privateGetPublicMethods());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3825
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3826
        if (!!isInterface()) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3827
            Class c = getSuperclass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3828
            if (c !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3829
                MethodArray supers = new MethodArray();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3830
                supers.addAll(c.privateGetPublicMethods());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3831
                // Filter out concrete implementations of any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3832
                // interface methods
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3833
                for (int i = 0; i < supers.length(); i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3834
                    Method m = supers.get(i);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3835
                    if (m !!= null && !!Modifier.isAbstract(m.getModifiers())) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3836
                        inheritedMethods.removeByNameAndSignature(m);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3837
                    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3838
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3839
                // Insert superclass''s inherited methods before
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3840
                // superinterfaces'' to satisfy getMethod''s search
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3841
                // order
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3842
                supers.addAll(inheritedMethods);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3843
                inheritedMethods = supers;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3844
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3845
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3846
        // Filter out all local methods from inherited ones
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3847
        for (int i = 0; i < methods.length(); i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3848
            Method m = methods.get(i);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3849
            inheritedMethods.removeByNameAndSignature(m);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3850
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3851
        methods.addAllIfNotPresent(inheritedMethods);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3852
        methods.compactAndTrim();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3853
        res = methods.getArray();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3854
        if (useCaches) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3855
            publicMethods = new SoftReference(res);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3856
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3857
        return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3858
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3859
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3860
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3861
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3862
    // Helpers for fetchers of one field, method, or constructor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3863
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3864
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3865
    private Field searchFields(Field[] fields, String name) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3866
        String internedName = name.intern();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3867
        for (int i = 0; i < fields.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3868
            if (fields[i].getName() == internedName) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3869
                return getReflectionFactory().copyField(fields[i]);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3870
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3871
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3872
        return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3873
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3874
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3875
    private Field getField0(String name) throws NoSuchFieldException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3876
        // Note: the intent is that the search algorithm this routine
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3877
        // uses be equivalent to the ordering imposed by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3878
        // privateGetPublicFields(). It fetches only the declared
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3879
        // public fields for each class, however, to reduce the number
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3880
        // of Field objects which have to be created for the common
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3881
        // case where the field being requested is declared in the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3882
        // class which is being queried.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3883
        Field res = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3884
        // Search declared public fields
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3885
        if ((res = searchFields(privateGetDeclaredFields(true), name)) !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3886
            return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3887
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3888
        // Direct superinterfaces, recursively
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3889
        Class[] interfaces = getInterfaces();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3890
        for (int i = 0; i < interfaces.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3891
            Class c = interfaces[i];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3892
            if ((res = c.getField0(name)) !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3893
                return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3894
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3895
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3896
        // Direct superclass, recursively
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3897
        if (!!isInterface()) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3898
            Class c = getSuperclass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3899
            if (c !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3900
                if ((res = c.getField0(name)) !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3901
                    return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3902
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3903
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3904
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3905
        return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3906
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3907
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3908
    private static Method searchMethods(Method[] methods,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3909
                                        String name,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3910
                                        Class[] parameterTypes)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3911
    {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3912
        Method res = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3913
        String internedName = name.intern();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3914
        for (int i = 0; i < methods.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3915
            Method m = methods[i];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3916
            if (m.getName() == internedName
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3917
                && arrayContentsEq(parameterTypes, m.getParameterTypes())
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3918
                && (res == null
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3919
                    || res.getReturnType().isAssignableFrom(m.getReturnType())))
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3920
                res = m;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3921
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3922
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3923
        return (res == null ? res : getReflectionFactory().copyMethod(res));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3924
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3925
  
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3926
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3927
    private Method getMethod0(String name, Class[] parameterTypes) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3928
        // Note: the intent is that the search algorithm this routine
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3929
        // uses be equivalent to the ordering imposed by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3930
        // privateGetPublicMethods(). It fetches only the declared
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3931
        // public methods for each class, however, to reduce the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3932
        // number of Method objects which have to be created for the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3933
        // common case where the method being requested is declared in
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3934
        // the class which is being queried.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3935
        Method res = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3936
        // Search declared public methods
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3937
        if ((res = searchMethods(privateGetDeclaredMethods(true),
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3938
                                 name,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3939
                                 parameterTypes)) !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3940
            return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3941
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3942
        // Search superclass''s methods
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3943
        if (!!isInterface()) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3944
            Class c = getSuperclass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3945
            if (c !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3946
                if ((res = c.getMethod0(name, parameterTypes)) !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3947
                    return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3948
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3949
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3950
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3951
        // Search superinterfaces'' methods
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3952
        Class[] interfaces = getInterfaces();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3953
        for (int i = 0; i < interfaces.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3954
            Class c = interfaces[i];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3955
            if ((res = c.getMethod0(name, parameterTypes)) !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3956
                return res;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3957
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3958
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3959
        // Not found
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3960
        return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3961
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3962
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3963
    private Constructor<T> getConstructor0(Class[] parameterTypes,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3964
                                        int which) throws NoSuchMethodException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3965
    {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3966
        Constructor[] constructors = privateGetDeclaredConstructors((which == Member.PUBLIC));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3967
        for (int i = 0; i < constructors.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3968
            if (arrayContentsEq(parameterTypes,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3969
                                constructors[i].getParameterTypes())) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3970
                return getReflectionFactory().copyConstructor(constructors[i]);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3971
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3972
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3973
        throw new NoSuchMethodException(getName() + ".<init>" + argumentTypesToString(parameterTypes));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3974
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3975
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3976
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3977
    // Other helpers and base implementation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3978
    //
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3979
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3980
    private static boolean arrayContentsEq(Object[] a1, Object[] a2) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3981
        if (a1 == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3982
            return a2 == null || a2.length == 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3983
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3984
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3985
        if (a2 == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3986
            return a1.length == 0;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3987
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3988
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3989
        if (a1.length !!= a2.length) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3990
            return false;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3991
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3992
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3993
        for (int i = 0; i < a1.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3994
            if (a1[i] !!= a2[i]) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3995
                return false;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3996
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3997
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3998
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  3999
        return true;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4000
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4001
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4002
    private static Field[] copyFields(Field[] arg) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4003
        Field[] out = new Field[arg.length];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4004
        ReflectionFactory fact = getReflectionFactory();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4005
        for (int i = 0; i < arg.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4006
            out[i] = fact.copyField(arg[i]);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4007
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4008
        return out;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4009
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4010
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4011
    private static Method[] copyMethods(Method[] arg) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4012
        Method[] out = new Method[arg.length];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4013
        ReflectionFactory fact = getReflectionFactory();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4014
        for (int i = 0; i < arg.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4015
            out[i] = fact.copyMethod(arg[i]);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4016
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4017
        return out;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4018
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4019
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4020
    private static Constructor[] copyConstructors(Constructor[] arg) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4021
        Constructor[] out = new Constructor[arg.length];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4022
        ReflectionFactory fact = getReflectionFactory();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4023
        for (int i = 0; i < arg.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4024
            out[i] = fact.copyConstructor(arg[i]);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4025
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4026
        return out;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4027
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4028
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4029
    private native Field[]       getDeclaredFields0(boolean publicOnly);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4030
    private native Method[]      getDeclaredMethods0(boolean publicOnly);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4031
    private native Constructor[] getDeclaredConstructors0(boolean publicOnly);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4032
    private native Class[]   getDeclaredClasses0();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4033
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4034
    private static String        argumentTypesToString(Class[] argTypes) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4035
        StringBuilder buf = new StringBuilder();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4036
        buf.append("(");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4037
        if (argTypes !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4038
            for (int i = 0; i < argTypes.length; i++) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4039
                if (i > 0) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4040
                    buf.append(", ");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4041
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4042
                Class c = argTypes[i];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4043
                buf.append((c == null) ? "null" : c.getName());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4044
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4045
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4046
        buf.append(")");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4047
        return buf.toString();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4048
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4049
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4050
    /** use serialVersionUID from JDK 1.1 for interoperability */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4051
    private static final long serialVersionUID = 3206093459760846163L;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4052
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4053
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4054
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4055
     * Class Class is special cased within the Serialization Stream Protocol. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4056
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4057
     * A Class instance is written initially into an ObjectOutputStream in the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4058
     * following format:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4059
     * <pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4060
     *      <code>TC_CLASS</code> ClassDescriptor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4061
     *      A ClassDescriptor is a special cased serialization of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4062
     *      a <code>java.io.ObjectStreamClass</code> instance. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4063
     * </pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4064
     * A new handle is generated for the initial time the class descriptor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4065
     * is written into the stream. Future references to the class descriptor
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4066
     * are written as references to the initial class descriptor instance.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4067
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4068
     * @see java.io.ObjectStreamClass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4069
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4070
    private static final ObjectStreamField[] serialPersistentFields = 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4071
        new ObjectStreamField[0];
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4072
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4073
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4074
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4075
     * Returns the assertion status that would be assigned to this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4076
     * class if it were to be initialized at the time this method is invoked.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4077
     * If this class has had its assertion status set, the most recent
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4078
     * setting will be returned; otherwise, if any package default assertion
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4079
     * status pertains to this class, the most recent setting for the most
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4080
     * specific pertinent package default assertion status is returned;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4081
     * otherwise, if this class is not a system class (i.e., it has a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4082
     * class loader) its class loader''s default assertion status is returned;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4083
     * otherwise, the system class default assertion status is returned.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4084
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4085
     * Few programmers will have any need for this method; it is provided
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4086
     * for the benefit of the JRE itself.  (It allows a class to determine at
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4087
     * the time that it is initialized whether assertions should be enabled.)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4088
     * Note that this method is not guaranteed to return the actual
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4089
     * assertion status that was (or will be) associated with the specified
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4090
     * class when it was (or will be) initialized.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4091
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4092
     * @return the desired assertion status of the specified class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4093
     * @see    java.lang.ClassLoader#setClassAssertionStatus
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4094
     * @see    java.lang.ClassLoader#setPackageAssertionStatus
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4095
     * @see    java.lang.ClassLoader#setDefaultAssertionStatus
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4096
     * @since  1.4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4097
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4098
    public boolean desiredAssertionStatus() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4099
        ClassLoader loader = getClassLoader();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4100
        // If the loader is null this is a system class, so ask the VM
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4101
        if (loader == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4102
            return desiredAssertionStatus0(this);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4103
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4104
        synchronized(loader) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4105
            // If the classloader has been initialized with
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4106
            // the assertion directives, ask it. Otherwise,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4107
            // ask the VM.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4108
            return (loader.classAssertionStatus == null ?
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4109
                    desiredAssertionStatus0(this) :
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4110
                    loader.desiredAssertionStatus(getName()));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4111
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4112
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4113
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4114
    // Retrieves the desired assertion status of this class from the VM
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4115
    private static native boolean desiredAssertionStatus0(Class clazz);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4116
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4117
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4118
     * Returns true if and only if this class was declared as an enum in the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4119
     * source code.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4120
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4121
     * @return true if and only if this class was declared as an enum in the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4122
     *     source code
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4123
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4124
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4125
    public boolean isEnum() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4126
        // An enum must both directly extend java.lang.Enum and have
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4127
        // the ENUM bit set; classes for specialized enum constants
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4128
        // don''t do the former.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4129
        return (this.getModifiers() & ENUM) !!= 0 && 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4130
        this.getSuperclass() == java.lang.Enum.class;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4131
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4132
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4133
    // Fetches the factory for reflective objects
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4134
    private static ReflectionFactory getReflectionFactory() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4135
        if (reflectionFactory == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4136
            reflectionFactory =  (ReflectionFactory)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4137
                java.security.AccessController.doPrivileged
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4138
                    (new sun.reflect.ReflectionFactory.GetReflectionFactoryAction());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4139
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4140
        return reflectionFactory;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4141
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4142
    private static ReflectionFactory reflectionFactory;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4143
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4144
    // To be able to query system properties as soon as they''re available
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4145
    private static boolean initted = false;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4146
    private static void checkInitted() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4147
        if (initted) return;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4148
        AccessController.doPrivileged(new PrivilegedAction() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4149
                public Object run() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4150
                    // Tests to ensure the system properties table is fully
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4151
                    // initialized. This is needed because reflection code is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4152
                    // called very early in the initialization process (before
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4153
                    // command-line arguments have been parsed and therefore
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4154
                    // these user-settable properties installed.) We assume that
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4155
                    // if System.out is non-null then the System class has been
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4156
                    // fully initialized and that the bulk of the startup code
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4157
                    // has been run.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4158
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4159
                    if (System.out == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4160
                        // java.lang.System not yet fully initialized
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4161
                        return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4162
                    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4163
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4164
                    String val =
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4165
                        System.getProperty("sun.reflect.noCaches");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4166
                    if (val !!= null && val.equals("true")) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4167
                        useCaches = false;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4168
                    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4169
          
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4170
                    initted = true;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4171
                    return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4172
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4173
            });
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4174
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4175
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4176
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4177
     * Returns the elements of this enum class or null if this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4178
     * Class object does not represent an enum type.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4179
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4180
     * @return an array containing the values comprising the enum class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4181
     *     represented by this Class object in the order they''re
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4182
     *     declared, or null if this Class object does not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4183
     *     represent an enum type
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4184
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4185
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4186
    public T[] getEnumConstants() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4187
        T[] values = getEnumConstantsShared();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4188
        return (values !!= null) ? values.clone() : null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4189
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4190
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4191
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4192
     * Returns the elements of this enum class or null if this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4193
     * Class object does not represent an enum type;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4194
     * identical to getEnumConstantsShared except that
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4195
     * the result is uncloned, cached, and shared by all callers.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4196
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4197
    T[] getEnumConstantsShared() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4198
        if (enumConstants == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4199
            if (!!isEnum()) return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4200
            try {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4201
                final Method values = getMethod("values");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4202
                java.security.AccessController.doPrivileged
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4203
                    (new java.security.PrivilegedAction() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4204
                            public Object run() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4205
                                values.setAccessible(true);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4206
                                return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4207
                            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4208
                        });
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4209
                enumConstants = (T[])values.invoke(null);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4210
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4211
            // These can happen when users concoct enum-like classes
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4212
            // that don''t comply with the enum spec.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4213
            catch (InvocationTargetException ex) { return null; }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4214
            catch (NoSuchMethodException ex) { return null; }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4215
            catch (IllegalAccessException ex) { return null; }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4216
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4217
        return enumConstants;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4218
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4219
    private volatile transient T[] enumConstants = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4220
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4221
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4222
     * Returns a map from simple name to enum constant.  This package-private
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4223
     * method is used internally by Enum to implement 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4224
     *     public static <T extends Enum<T>> T valueOf(Class<T>, String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4225
     * efficiently.  Note that the map is returned by this method is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4226
     * created lazily on first use.  Typically it won''t ever get created.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4227
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4228
    Map<String, T> enumConstantDirectory() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4229
        if (enumConstantDirectory == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4230
            T[] universe = getEnumConstantsShared();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4231
            if (universe == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4232
                throw new IllegalArgumentException(
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4233
                    getName() + " is not an enum type");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4234
            Map<String, T> m = new HashMap<String, T>(2 * universe.length);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4235
            for (T constant : universe)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4236
                m.put(((Enum)constant).name(), constant);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4237
            enumConstantDirectory = m;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4238
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4239
        return enumConstantDirectory;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4240
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4241
    private volatile transient Map<String, T> enumConstantDirectory = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4242
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4243
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4244
     * Casts an object to the class or interface represented
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4245
     * by this <tt>Class</tt> object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4246
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4247
     * @param obj the object to be cast
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4248
     * @return the object after casting, or null if obj is null
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4249
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4250
     * @throws ClassCastException if the object is not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4251
     * null and is not assignable to the type T.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4252
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4253
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4254
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4255
    public T cast(Object obj) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4256
        if (obj !!= null && !!isInstance(obj))
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4257
            throw new ClassCastException();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4258
        return (T) obj;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4259
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4260
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4261
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4262
     * Casts this <tt>Class</tt> object to represent a subclass of the class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4263
     * represented by the specified class object.  Checks that that the cast
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4264
     * is valid, and throws a <tt>ClassCastException</tt> if it is not.  If
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4265
     * this method succeeds, it always returns a reference to this class object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4266
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4267
     * <p>This method is useful when a client needs to "narrow" the type of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4268
     * a <tt>Class</tt> object to pass it to an API that restricts the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4269
     * <tt>Class</tt> objects that it is willing to accept.  A cast would
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4270
     * generate a compile-time warning, as the correctness of the cast
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4271
     * could not be checked at runtime (because generic types are implemented
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4272
     * by erasure).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4273
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4274
     * @return this <tt>Class</tt> object, cast to represent a subclass of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4275
     *    the specified class object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4276
     * @throws ClassCastException if this <tt>Class</tt> object does not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4277
     *    represent a subclass of the specified class (here "subclass" includes
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4278
     *    the class itself).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4279
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4280
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4281
    public <U> Class<? extends U> asSubclass(Class<U> clazz) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4282
        if (clazz.isAssignableFrom(this))
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4283
            return (Class<? extends U>) this;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4284
        else
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4285
            throw new ClassCastException(this.toString());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4286
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4287
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4288
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4289
     * @throws NullPointerException {@inheritDoc}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4290
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4291
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4292
    public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4293
        if (annotationClass == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4294
            throw new NullPointerException();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4295
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4296
        initAnnotationsIfNecessary();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4297
        return (A) annotations.get(annotationClass);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4298
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4299
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4300
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4301
     * @throws NullPointerException {@inheritDoc}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4302
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4303
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4304
    public boolean isAnnotationPresent(
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4305
        Class<? extends Annotation> annotationClass) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4306
        if (annotationClass == null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4307
            throw new NullPointerException();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4308
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4309
        return getAnnotation(annotationClass) !!= null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4310
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4311
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4312
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4313
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4314
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4315
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4316
    public Annotation[] getAnnotations() { 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4317
        initAnnotationsIfNecessary();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4318
        return AnnotationParser.toArray(annotations);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4319
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4320
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4321
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4322
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4323
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4324
    public Annotation[] getDeclaredAnnotations()  {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4325
        initAnnotationsIfNecessary();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4326
        return AnnotationParser.toArray(declaredAnnotations);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4327
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4328
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4329
    // Annotations cache
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4330
    private transient Map<Class, Annotation> annotations;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4331
    private transient Map<Class, Annotation> declaredAnnotations;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4332
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4333
    private synchronized void initAnnotationsIfNecessary() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4334
        clearCachesOnClassRedefinition();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4335
        if (annotations !!= null)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4336
            return;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4337
        declaredAnnotations = AnnotationParser.parseAnnotations(
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4338
            getRawAnnotations(), getConstantPool(), this);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4339
        Class<?> superClass = getSuperclass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4340
        if (superClass == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4341
            annotations = declaredAnnotations;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4342
        } else {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4343
            annotations = new HashMap<Class, Annotation>();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4344
            superClass.initAnnotationsIfNecessary();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4345
            for (Map.Entry<Class, Annotation> e : superClass.annotations.entrySet()) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4346
                Class annotationClass = e.getKey();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4347
                if (AnnotationType.getInstance(annotationClass).isInherited())
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4348
                    annotations.put(annotationClass, e.getValue());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4349
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4350
            annotations.putAll(declaredAnnotations);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4351
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4352
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4353
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4354
    // Annotation types cache their internal (AnnotationType) form
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4355
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4356
    private AnnotationType annotationType;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4357
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4358
    void setAnnotationType(AnnotationType type) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4359
        annotationType = type;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4360
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4361
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4362
    AnnotationType getAnnotationType() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4363
        return annotationType;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4364
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4365
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4366
'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4367
].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4368
    Transcript showCR: 'java.lang.Class parsed in ', time asString, ' miliseconds'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4369
    ^ res.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4370
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4371
    "Modified: / 30-12-2010 / 11:39:50 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4372
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4373
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4374
testJavaLangObject6
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4375
    | res time |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4376
    time := Time millisecondsToRun: [
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4377
    res := self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4378
/*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4379
 * %W% %E%
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4380
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4381
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4382
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4383
 */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4384
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4385
package java.lang;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4386
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4387
/**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4388
 * Class <code>Object</code> is the root of the class hierarchy. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4389
 * Every class has <code>Object</code> as a superclass. All objects, 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4390
 * including arrays, implement the methods of this class. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4391
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4392
 * @author  unascribed
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4393
 * @version %I%, %G%
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4394
 * @see     java.lang.Class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4395
 * @since   JDK1.0
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4396
 */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4397
public class Object {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4398
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4399
    private static native void registerNatives();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4400
    static {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4401
        registerNatives();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4402
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4403
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4404
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4405
     * Returns the runtime class of this {@code Object}. The returned
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4406
     * {@code Class} object is the object that is locked by {@code
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4407
     * static synchronized} methods of the represented class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4408
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4409
     * <p><b>The actual result type is {@code Class<? extends |X|>}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4410
     * where {@code |X|} is the erasure of the static type of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4411
     * expression on which {@code getClass} is called.</b> For
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4412
     * example, no cast is required in this code fragment:</p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4413
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4414
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4415
     * {@code Number n = 0;                             }<br>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4416
     * {@code Class<? extends Number> c = n.getClass(); }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4417
     * </p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4418
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4419
     * @return The {@code Class} object that represents the runtime
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4420
     *         class of this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4421
     * @see    <a href="http://java.sun.com/docs/books/jls/">The Java
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4422
     *         Language Specification, Third Edition (15.8.2 Class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4423
     *         Literals)</a>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4424
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4425
    public final native Class<?> getClass();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4426
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4427
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4428
     * Returns a hash code value for the object. This method is 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4429
     * supported for the benefit of hashtables such as those provided by 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4430
     * <code>java.util.Hashtable</code>. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4431
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4432
     * The general contract of <code>hashCode</code> is: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4433
     * <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4434
     * <li>Whenever it is invoked on the same object more than once during 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4435
     *     an execution of a Java application, the <tt>hashCode</tt> method 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4436
     *     must consistently return the same integer, provided no information 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4437
     *     used in <tt>equals</tt> comparisons on the object is modified.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4438
     *     This integer need not remain consistent from one execution of an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4439
     *     application to another execution of the same application. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4440
     * <li>If two objects are equal according to the <tt>equals(Object)</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4441
     *     method, then calling the <code>hashCode</code> method on each of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4442
     *     the two objects must produce the same integer result. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4443
     * <li>It is <em>not</em> required that if two objects are unequal 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4444
     *     according to the {@link java.lang.Object#equals(java.lang.Object)} 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4445
     *     method, then calling the <tt>hashCode</tt> method on each of the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4446
     *     two objects must produce distinct integer results.  However, the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4447
     *     programmer should be aware that producing distinct integer results 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4448
     *     for unequal objects may improve the performance of hashtables.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4449
     * </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4450
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4451
     * As much as is reasonably practical, the hashCode method defined by 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4452
     * class <tt>Object</tt> does return distinct integers for distinct 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4453
     * objects. (This is typically implemented by converting the internal 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4454
     * address of the object into an integer, but this implementation 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4455
     * technique is not required by the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4456
     * Java<font size="-2"><sup>TM</sup></font> programming language.)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4457
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4458
     * @return  a hash code value for this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4459
     * @see     java.lang.Object#equals(java.lang.Object)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4460
     * @see     java.util.Hashtable
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4461
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4462
    public native int hashCode();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4463
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4464
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4465
     * Indicates whether some other object is "equal to" this one.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4466
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4467
     * The <code>equals</code> method implements an equivalence relation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4468
     * on non-null object references:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4469
     * <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4470
     * <li>It is <i>reflexive</i>: for any non-null reference value
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4471
     *     <code>x</code>, <code>x.equals(x)</code> should return
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4472
     *     <code>true</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4473
     * <li>It is <i>symmetric</i>: for any non-null reference values
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4474
     *     <code>x</code> and <code>y</code>, <code>x.equals(y)</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4475
     *     should return <code>true</code> if and only if
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4476
     *     <code>y.equals(x)</code> returns <code>true</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4477
     * <li>It is <i>transitive</i>: for any non-null reference values
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4478
     *     <code>x</code>, <code>y</code>, and <code>z</code>, if
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4479
     *     <code>x.equals(y)</code> returns <code>true</code> and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4480
     *     <code>y.equals(z)</code> returns <code>true</code>, then
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4481
     *     <code>x.equals(z)</code> should return <code>true</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4482
     * <li>It is <i>consistent</i>: for any non-null reference values
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4483
     *     <code>x</code> and <code>y</code>, multiple invocations of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4484
     *     <tt>x.equals(y)</tt> consistently return <code>true</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4485
     *     or consistently return <code>false</code>, provided no
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4486
     *     information used in <code>equals</code> comparisons on the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4487
     *     objects is modified.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4488
     * <li>For any non-null reference value <code>x</code>,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4489
     *     <code>x.equals(null)</code> should return <code>false</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4490
     * </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4491
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4492
     * The <tt>equals</tt> method for class <code>Object</code> implements 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4493
     * the most discriminating possible equivalence relation on objects; 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4494
     * that is, for any non-null reference values <code>x</code> and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4495
     * <code>y</code>, this method returns <code>true</code> if and only
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4496
     * if <code>x</code> and <code>y</code> refer to the same object
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4497
     * (<code>x == y</code> has the value <code>true</code>).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4498
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4499
     * Note that it is generally necessary to override the <tt>hashCode</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4500
     * method whenever this method is overridden, so as to maintain the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4501
     * general contract for the <tt>hashCode</tt> method, which states
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4502
     * that equal objects must have equal hash codes. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4503
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4504
     * @param   obj   the reference object with which to compare.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4505
     * @return  <code>true</code> if this object is the same as the obj
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4506
     *          argument; <code>false</code> otherwise.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4507
     * @see     #hashCode()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4508
     * @see     java.util.Hashtable
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4509
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4510
    public boolean equals(Object obj) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4511
        return (this == obj);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4512
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4513
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4514
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4515
     * Creates and returns a copy of this object.  The precise meaning 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4516
     * of "copy" may depend on the class of the object. The general 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4517
     * intent is that, for any object <tt>x</tt>, the expression:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4518
     * <blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4519
     * <pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4520
     * x.clone() !!= x</pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4521
     * will be true, and that the expression:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4522
     * <blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4523
     * <pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4524
     * x.clone().getClass() == x.getClass()</pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4525
     * will be <tt>true</tt>, but these are not absolute requirements. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4526
     * While it is typically the case that:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4527
     * <blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4528
     * <pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4529
     * x.clone().equals(x)</pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4530
     * will be <tt>true</tt>, this is not an absolute requirement. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4531
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4532
     * By convention, the returned object should be obtained by calling
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4533
     * <tt>super.clone</tt>.  If a class and all of its superclasses (except
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4534
     * <tt>Object</tt>) obey this convention, it will be the case that
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4535
     * <tt>x.clone().getClass() == x.getClass()</tt>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4536
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4537
     * By convention, the object returned by this method should be independent
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4538
     * of this object (which is being cloned).  To achieve this independence,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4539
     * it may be necessary to modify one or more fields of the object returned
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4540
     * by <tt>super.clone</tt> before returning it.  Typically, this means
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4541
     * copying any mutable objects that comprise the internal "deep structure"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4542
     * of the object being cloned and replacing the references to these
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4543
     * objects with references to the copies.  If a class contains only
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4544
     * primitive fields or references to immutable objects, then it is usually
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4545
     * the case that no fields in the object returned by <tt>super.clone</tt>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4546
     * need to be modified.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4547
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4548
     * The method <tt>clone</tt> for class <tt>Object</tt> performs a 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4549
     * specific cloning operation. First, if the class of this object does 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4550
     * not implement the interface <tt>Cloneable</tt>, then a 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4551
     * <tt>CloneNotSupportedException</tt> is thrown. Note that all arrays 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4552
     * are considered to implement the interface <tt>Cloneable</tt>. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4553
     * Otherwise, this method creates a new instance of the class of this 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4554
     * object and initializes all its fields with exactly the contents of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4555
     * the corresponding fields of this object, as if by assignment; the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4556
     * contents of the fields are not themselves cloned. Thus, this method 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4557
     * performs a "shallow copy" of this object, not a "deep copy" operation.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4558
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4559
     * The class <tt>Object</tt> does not itself implement the interface 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4560
     * <tt>Cloneable</tt>, so calling the <tt>clone</tt> method on an object 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4561
     * whose class is <tt>Object</tt> will result in throwing an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4562
     * exception at run time.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4563
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4564
     * @return     a clone of this instance.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4565
     * @exception  CloneNotSupportedException  if the object''s class does not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4566
     *               support the <code>Cloneable</code> interface. Subclasses
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4567
     *               that override the <code>clone</code> method can also
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4568
     *               throw this exception to indicate that an instance cannot
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4569
     *               be cloned.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4570
     * @see java.lang.Cloneable
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4571
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4572
    protected native Object clone() throws CloneNotSupportedException;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4573
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4574
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4575
     * Returns a string representation of the object. In general, the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4576
     * <code>toString</code> method returns a string that 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4577
     * "textually represents" this object. The result should 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4578
     * be a concise but informative representation that is easy for a 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4579
     * person to read.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4580
     * It is recommended that all subclasses override this method.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4581
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4582
     * The <code>toString</code> method for class <code>Object</code> 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4583
     * returns a string consisting of the name of the class of which the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4584
     * object is an instance, the at-sign character `<code>@</code>`, and 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4585
     * the unsigned hexadecimal representation of the hash code of the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4586
     * object. In other words, this method returns a string equal to the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4587
     * value of:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4588
     * <blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4589
     * <pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4590
     * getClass().getName() + `@` + Integer.toHexString(hashCode())
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4591
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4592
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4593
     * @return  a string representation of the object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4594
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4595
    public String toString() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4596
        return getClass().getName() + "@" + Integer.toHexString(hashCode());
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4597
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4598
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4599
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4600
     * Wakes up a single thread that is waiting on this objects 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4601
     * monitor. If any threads are waiting on this object, one of them 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4602
     * is chosen to be awakened. The choice is arbitrary and occurs at 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4603
     * the discretion of the implementation. A thread waits on an objects 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4604
     * monitor by calling one of the <code>wait</code> methods.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4605
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4606
     * The awakened thread will not be able to proceed until the current 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4607
     * thread relinquishes the lock on this object. The awakened thread will 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4608
     * compete in the usual manner with any other threads that might be 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4609
     * actively competing to synchronize on this object; for example, the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4610
     * awakened thread enjoys no reliable privilege or disadvantage in being 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4611
     * the next thread to lock this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4612
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4613
     * This method should only be called by a thread that is the owner 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4614
     * of this object`s monitor. A thread becomes the owner of the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4615
     * object`s monitor in one of three ways: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4616
     * <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4617
     * <li>By executing a synchronized instance method of that object. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4618
     * <li>By executing the body of a <code>synchronized</code> statement 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4619
     *     that synchronizes on the object. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4620
     * <li>For objects of type <code>Class,</code> by executing a 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4621
     *     synchronized static method of that class. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4622
     * </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4623
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4624
     * Only one thread at a time can own an object''s monitor. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4625
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4626
     * @exception  IllegalMonitorStateException  if the current thread is not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4627
     *               the owner of this object''s monitor.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4628
     * @see        java.lang.Object#notifyAll()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4629
     * @see        java.lang.Object#wait()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4630
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4631
    public final native void notify();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4632
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4633
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4634
     * Wakes up all threads that are waiting on this object`s monitor. A 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4635
     * thread waits on an object`s monitor by calling one of the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4636
     * <code>wait</code> methods.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4637
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4638
     * The awakened threads will not be able to proceed until the current 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4639
     * thread relinquishes the lock on this object. The awakened threads 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4640
     * will compete in the usual manner with any other threads that might 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4641
     * be actively competing to synchronize on this object; for example, 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4642
     * the awakened threads enjoy no reliable privilege or disadvantage in 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4643
     * being the next thread to lock this object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4644
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4645
     * This method should only be called by a thread that is the owner 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4646
     * of this object`s monitor. See the <code>notify</code> method for a 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4647
     * description of the ways in which a thread can become the owner of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4648
     * a monitor. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4649
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4650
     * @exception  IllegalMonitorStateException  if the current thread is not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4651
     *               the owner of this object`s monitor.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4652
     * @see        java.lang.Object#notify()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4653
     * @see        java.lang.Object#wait()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4654
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4655
    public final native void notifyAll();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4656
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4657
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4658
     * Causes the current thread to wait until either another thread invokes the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4659
     * {@link java.lang.Object#notify()} method or the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4660
     * {@link java.lang.Object#notifyAll()} method for this object, or a 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4661
     * specified amount of time has elapsed. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4662
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4663
     * The current thread must own this object`s monitor. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4664
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4665
     * This method causes the current thread (call it <var>T</var>) to 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4666
     * place itself in the wait set for this object and then to relinquish 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4667
     * any and all synchronization claims on this object. Thread <var>T</var> 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4668
     * becomes disabled for thread scheduling purposes and lies dormant 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4669
     * until one of four things happens:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4670
     * <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4671
     * <li>Some other thread invokes the <tt>notify</tt> method for this 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4672
     * object and thread <var>T</var> happens to be arbitrarily chosen as 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4673
     * the thread to be awakened. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4674
     * <li>Some other thread invokes the <tt>notifyAll</tt> method for this 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4675
     * object. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4676
     * <li>Some other thread {@linkplain Thread#interrupt() interrupts} 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4677
     * thread <var>T</var>. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4678
     * <li>The specified amount of real time has elapsed, more or less.  If 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4679
     * <tt>timeout</tt> is zero, however, then real time is not taken into 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4680
     * consideration and the thread simply waits until notified. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4681
     * </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4682
     * The thread <var>T</var> is then removed from the wait set for this 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4683
     * object and re-enabled for thread scheduling. It then competes in the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4684
     * usual manner with other threads for the right to synchronize on the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4685
     * object; once it has gained control of the object, all its 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4686
     * synchronization claims on the object are restored to the status quo 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4687
     * ante - that is, to the situation as of the time that the <tt>wait</tt> 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4688
     * method was invoked. Thread <var>T</var> then returns from the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4689
     * invocation of the <tt>wait</tt> method. Thus, on return from the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4690
     * <tt>wait</tt> method, the synchronization state of the object and of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4691
     * thread <tt>T</tt> is exactly as it was when the <tt>wait</tt> method 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4692
     * was invoked. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4693
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4694
     * A thread can also wake up without being notified, interrupted, or
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4695
     * timing out, a so-called <i>spurious wakeup</i>.  While this will rarely
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4696
     * occur in practice, applications must guard against it by testing for
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4697
     * the condition that should have caused the thread to be awakened, and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4698
     * continuing to wait if the condition is not satisfied.  In other words,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4699
     * waits should always occur in loops, like this one:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4700
     * <pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4701
     *     synchronized (obj) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4702
     *         while (&lt;condition does not hold&gt;)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4703
     *             obj.wait(timeout);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4704
     *         ... // Perform action appropriate to condition
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4705
     *     }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4706
     * </pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4707
     * (For more information on this topic, see Section 3.2.3 in Doug Lea`s
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4708
     * "Concurrent Programming in Java (Second Edition)" (Addison-Wesley,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4709
     * 2000), or Item 50 in Joshua Bloch`s "Effective Java Programming
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4710
     * Language Guide" (Addison-Wesley, 2001).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4711
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4712
     * <p>If the current thread is {@linkplain java.lang.Thread#interrupt()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4713
     * interrupted} by any thread before or while it is waiting, then an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4714
     * <tt>InterruptedException</tt> is thrown.  This exception is not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4715
     * thrown until the lock status of this object has been restored as
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4716
     * described above.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4717
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4718
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4719
     * Note that the <tt>wait</tt> method, as it places the current thread 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4720
     * into the wait set for this object, unlocks only this object; any 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4721
     * other objects on which the current thread may be synchronized remain 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4722
     * locked while the thread waits.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4723
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4724
     * This method should only be called by a thread that is the owner 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4725
     * of this object`s monitor. See the <code>notify</code> method for a 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4726
     * description of the ways in which a thread can become the owner of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4727
     * a monitor. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4728
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4729
     * @param      timeout   the maximum time to wait in milliseconds.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4730
     * @exception  IllegalArgumentException      if the value of timeout is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4731
     *               negative.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4732
     * @exception  IllegalMonitorStateException  if the current thread is not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4733
     *               the owner of the object`s monitor.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4734
     * @exception  InterruptedException if any thread interrupted the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4735
     *             current thread before or while the current thread
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4736
     *             was waiting for a notification.  The <i>interrupted
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4737
     *             status</i> of the current thread is cleared when
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4738
     *             this exception is thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4739
     * @see        java.lang.Object#notify()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4740
     * @see        java.lang.Object#notifyAll()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4741
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4742
    public final native void wait(long timeout) throws InterruptedException;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4743
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4744
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4745
     * Causes the current thread to wait until another thread invokes the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4746
     * {@link java.lang.Object#notify()} method or the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4747
     * {@link java.lang.Object#notifyAll()} method for this object, or 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4748
     * some other thread interrupts the current thread, or a certain 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4749
     * amount of real time has elapsed. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4750
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4751
     * This method is similar to the <code>wait</code> method of one 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4752
     * argument, but it allows finer control over the amount of time to 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4753
     * wait for a notification before giving up. The amount of real time, 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4754
     * measured in nanoseconds, is given by:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4755
     * <blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4756
     * <pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4757
     * 1000000*timeout+nanos</pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4758
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4759
     * In all other respects, this method does the same thing as the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4760
     * method {@link #wait(long)} of one argument. In particular, 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4761
     * <tt>wait(0, 0)</tt> means the same thing as <tt>wait(0)</tt>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4762
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4763
     * The current thread must own this object`s monitor. The thread 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4764
     * releases ownership of this monitor and waits until either of the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4765
     * following two conditions has occurred: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4766
     * <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4767
     * <li>Another thread notifies threads waiting on this object`s monitor 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4768
     *     to wake up either through a call to the <code>notify</code> method 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4769
     *     or the <code>notifyAll</code> method. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4770
     * <li>The timeout period, specified by <code>timeout</code> 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4771
     *     milliseconds plus <code>nanos</code> nanoseconds arguments, has 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4772
     *     elapsed. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4773
     * </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4774
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4775
     * The thread then waits until it can re-obtain ownership of the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4776
     * monitor and resumes execution.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4777
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4778
     * As in the one argument version, interrupts and spurious wakeups are
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4779
     * possible, and this method should always be used in a loop:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4780
     * <pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4781
     *     synchronized (obj) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4782
     *         while (&lt;condition does not hold&gt;)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4783
     *             obj.wait(timeout, nanos);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4784
     *         ... // Perform action appropriate to condition
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4785
     *     }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4786
     * </pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4787
     * This method should only be called by a thread that is the owner 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4788
     * of this object`s monitor. See the <code>notify</code> method for a 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4789
     * description of the ways in which a thread can become the owner of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4790
     * a monitor. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4791
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4792
     * @param      timeout   the maximum time to wait in milliseconds.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4793
     * @param      nanos      additional time, in nanoseconds range
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4794
     *                       0-999999.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4795
     * @exception  IllegalArgumentException      if the value of timeout is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4796
     *                      negative or the value of nanos is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4797
     *                      not in the range 0-999999.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4798
     * @exception  IllegalMonitorStateException  if the current thread is not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4799
     *               the owner of this object`s monitor.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4800
     * @exception  InterruptedException if any thread interrupted the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4801
     *             current thread before or while the current thread
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4802
     *             was waiting for a notification.  The <i>interrupted
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4803
     *             status</i> of the current thread is cleared when
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4804
     *             this exception is thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4805
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4806
    public final void wait(long timeout, int nanos) throws InterruptedException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4807
        if (timeout < 0) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4808
            throw new IllegalArgumentException("timeout value is negative");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4809
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4810
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4811
        if (nanos < 0 || nanos > 999999) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4812
            throw new IllegalArgumentException(
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4813
                                "nanosecond timeout value out of range");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4814
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4815
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4816
        if (nanos >= 500000 || (nanos !!= 0 && timeout == 0)) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4817
            timeout++;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4818
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4819
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4820
        wait(timeout);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4821
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4822
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4823
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4824
     * Causes the current thread to wait until another thread invokes the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4825
     * {@link java.lang.Object#notify()} method or the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4826
     * {@link java.lang.Object#notifyAll()} method for this object. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4827
     * In other words, this method behaves exactly as if it simply 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4828
     * performs the call <tt>wait(0)</tt>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4829
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4830
     * The current thread must own this object`s monitor. The thread 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4831
     * releases ownership of this monitor and waits until another thread 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4832
     * notifies threads waiting on this object`s monitor to wake up 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4833
     * either through a call to the <code>notify</code> method or the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4834
     * <code>notifyAll</code> method. The thread then waits until it can 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4835
     * re-obtain ownership of the monitor and resumes execution. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4836
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4837
     * As in the one argument version, interrupts and spurious wakeups are
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4838
     * possible, and this method should always be used in a loop:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4839
     * <pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4840
     *     synchronized (obj) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4841
     *         while (&lt;condition does not hold&gt;)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4842
     *             obj.wait();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4843
     *         ... // Perform action appropriate to condition
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4844
     *     }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4845
     * </pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4846
     * This method should only be called by a thread that is the owner 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4847
     * of this object`s monitor. See the <code>notify</code> method for a 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4848
     * description of the ways in which a thread can become the owner of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4849
     * a monitor. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4850
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4851
     * @exception  IllegalMonitorStateException  if the current thread is not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4852
     *               the owner of the object`s monitor.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4853
     * @exception  InterruptedException if any thread interrupted the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4854
     *             current thread before or while the current thread
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4855
     *             was waiting for a notification.  The <i>interrupted
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4856
     *             status</i> of the current thread is cleared when
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4857
     *             this exception is thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4858
     * @see        java.lang.Object#notify()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4859
     * @see        java.lang.Object#notifyAll()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4860
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4861
    public final void wait() throws InterruptedException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4862
        wait(0);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4863
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4864
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4865
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4866
     * Called by the garbage collector on an object when garbage collection
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4867
     * determines that there are no more references to the object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4868
     * A subclass overrides the <code>finalize</code> method to dispose of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4869
     * system resources or to perform other cleanup. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4870
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4871
     * The general contract of <tt>finalize</tt> is that it is invoked 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4872
     * if and when the Java<font size="-2"><sup>TM</sup></font> virtual 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4873
     * machine has determined that there is no longer any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4874
     * means by which this object can be accessed by any thread that has
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4875
     * not yet died, except as a result of an action taken by the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4876
     * finalization of some other object or class which is ready to be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4877
     * finalized. The <tt>finalize</tt> method may take any action, including
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4878
     * making this object available again to other threads; the usual purpose
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4879
     * of <tt>finalize</tt>, however, is to perform cleanup actions before 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4880
     * the object is irrevocably discarded. For example, the finalize method 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4881
     * for an object that represents an input/output connection might perform
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4882
     * explicit I/O transactions to break the connection before the object is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4883
     * permanently discarded. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4884
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4885
     * The <tt>finalize</tt> method of class <tt>Object</tt> performs no 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4886
     * special action; it simply returns normally. Subclasses of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4887
     * <tt>Object</tt> may override this definition.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4888
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4889
     * The Java programming language does not guarantee which thread will 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4890
     * invoke the <tt>finalize</tt> method for any given object. It is 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4891
     * guaranteed, however, that the thread that invokes finalize will not 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4892
     * be holding any user-visible synchronization locks when finalize is 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4893
     * invoked. If an uncaught exception is thrown by the finalize method, 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4894
     * the exception is ignored and finalization of that object terminates.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4895
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4896
     * After the <tt>finalize</tt> method has been invoked for an object, no 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4897
     * further action is taken until the Java virtual machine has again 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4898
     * determined that there is no longer any means by which this object can 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4899
     * be accessed by any thread that has not yet died, including possible
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4900
     * actions by other objects or classes which are ready to be finalized, 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4901
     * at which point the object may be discarded.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4902
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4903
     * The <tt>finalize</tt> method is never invoked more than once by a Java
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4904
     * virtual machine for any given object.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4905
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4906
     * Any exception thrown by the <code>finalize</code> method causes 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4907
     * the finalization of this object to be halted, but is otherwise 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4908
     * ignored. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4909
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4910
     * @throws Throwable the <code>Exception</code> raised by this method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4911
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4912
    protected void finalize() throws Throwable { }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4913
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4914
        '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4915
].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4916
    Transcript showCR: 'java.lang.Object parsed in ', time asString, ' miliseconds'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4917
    ^ res.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4918
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4919
    "Modified: / 30-12-2010 / 11:39:56 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4920
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4921
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4922
testJavaLangSystem6
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4923
    | res time |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4924
    time := Time millisecondsToRun: [
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4925
    res := self assertParse: '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4926
/*
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4927
 * %W% %E%
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4928
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4929
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4930
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4931
 */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4932
package java.lang;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4933
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4934
import java.io.*;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4935
import java.util.Properties;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4936
import java.util.PropertyPermission;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4937
import java.util.StringTokenizer;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4938
import java.security.AccessController;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4939
import java.security.PrivilegedAction;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4940
import java.security.AllPermission;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4941
import java.nio.channels.Channel;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4942
import java.nio.channels.spi.SelectorProvider;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4943
import sun.nio.ch.Interruptible;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4944
import sun.reflect.Reflection;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4945
import sun.security.util.SecurityConstants;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4946
import sun.reflect.annotation.AnnotationType;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4947
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4948
/**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4949
 * The <code>System</code> class contains several useful class fields
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4950
 * and methods. It cannot be instantiated.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4951
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4952
 * <p>Among the facilities provided by the <code>System</code> class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4953
 * are standard input, standard output, and error output streams;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4954
 * access to externally defined properties and environment
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4955
 * variables; a means of loading files and libraries; and a utility
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4956
 * method for quickly copying a portion of an array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4957
 *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4958
 * @author  unascribed
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4959
 * @version 1.162, 04/01/09
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4960
 * @since   JDK1.0
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4961
 */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4962
public final class System {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4963
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4964
    /* First thing---register the natives */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4965
    private static native void registerNatives();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4966
    static {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4967
        registerNatives();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4968
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4969
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4970
    /** Don''t let anyone instantiate this class */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4971
    private System() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4972
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4973
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4974
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4975
     * The "standard" input stream. This stream is already
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4976
     * open and ready to supply input data. Typically this stream
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4977
     * corresponds to keyboard input or another input source specified by
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4978
     * the host environment or user.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4979
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4980
    public final static InputStream in = nullInputStream();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4981
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4982
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4983
     * The "standard" output stream. This stream is already
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4984
     * open and ready to accept output data. Typically this stream
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4985
     * corresponds to display output or another output destination
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4986
     * specified by the host environment or user.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4987
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4988
     * For simple stand-alone Java applications, a typical way to write
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4989
     * a line of output data is:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4990
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4991
     *     System.out.println(data)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4992
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4993
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4994
     * See the <code>println</code> methods in class <code>PrintStream</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4995
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4996
     * @see     java.io.PrintStream#println()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4997
     * @see     java.io.PrintStream#println(boolean)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4998
     * @see     java.io.PrintStream#println(char)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  4999
     * @see     java.io.PrintStream#println(char[])
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5000
     * @see     java.io.PrintStream#println(double)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5001
     * @see     java.io.PrintStream#println(float)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5002
     * @see     java.io.PrintStream#println(int)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5003
     * @see     java.io.PrintStream#println(long)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5004
     * @see     java.io.PrintStream#println(java.lang.Object)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5005
     * @see     java.io.PrintStream#println(java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5006
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5007
    public final static PrintStream out = nullPrintStream();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5008
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5009
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5010
     * The "standard" error output stream. This stream is already
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5011
     * open and ready to accept output data.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5012
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5013
     * Typically this stream corresponds to display output or another
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5014
     * output destination specified by the host environment or user. By
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5015
     * convention, this output stream is used to display error messages
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5016
     * or other information that should come to the immediate attention
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5017
     * of a user even if the principal output stream, the value of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5018
     * variable <code>out</code>, has been redirected to a file or other
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5019
     * destination that is typically not continuously monitored.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5020
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5021
    public final static PrintStream err = nullPrintStream();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5022
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5023
    /* The security manager for the system.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5024
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5025
    private static volatile SecurityManager security = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5026
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5027
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5028
     * Reassigns the "standard" input stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5029
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5030
     * <p>First, if there is a security manager, its <code>checkPermission</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5031
     * method is called with a <code>RuntimePermission("setIO")</code> permission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5032
     *  to see if it''s ok to reassign the "standard" input stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5033
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5034
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5035
     * @param in the new standard input stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5036
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5037
     * @throws SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5038
     *        if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5039
     *        <code>checkPermission</code> method doesn''t allow
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5040
     *        reassigning of the standard input stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5041
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5042
     * @see SecurityManager#checkPermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5043
     * @see java.lang.RuntimePermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5044
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5045
     * @since   JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5046
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5047
    public static void setIn(InputStream in) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5048
        checkIO();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5049
        setIn0(in);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5050
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5051
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5052
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5053
     * Reassigns the "standard" output stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5054
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5055
     * <p>First, if there is a security manager, its <code>checkPermission</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5056
     * method is called with a <code>RuntimePermission("setIO")</code> permission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5057
     *  to see if it''s ok to reassign the "standard" output stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5058
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5059
     * @param out the new standard output stream
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5060
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5061
     * @throws SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5062
     *        if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5063
     *        <code>checkPermission</code> method doesn''t allow
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5064
     *        reassigning of the standard output stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5065
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5066
     * @see SecurityManager#checkPermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5067
     * @see java.lang.RuntimePermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5068
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5069
     * @since   JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5070
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5071
    public static void setOut(PrintStream out) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5072
        checkIO();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5073
        setOut0(out);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5074
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5075
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5076
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5077
     * Reassigns the "standard" error output stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5078
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5079
     * <p>First, if there is a security manager, its <code>checkPermission</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5080
     * method is called with a <code>RuntimePermission("setIO")</code> permission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5081
     *  to see if it''s ok to reassign the "standard" error output stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5082
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5083
     * @param err the new standard error output stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5084
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5085
     * @throws SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5086
     *        if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5087
     *        <code>checkPermission</code> method doesn''t allow
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5088
     *        reassigning of the standard error output stream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5089
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5090
     * @see SecurityManager#checkPermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5091
     * @see java.lang.RuntimePermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5092
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5093
     * @since   JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5094
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5095
    public static void setErr(PrintStream err) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5096
        checkIO();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5097
        setErr0(err);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5098
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5099
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5100
    private static volatile Console cons = null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5101
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5102
     * Returns the unique {@link java.io.Console Console} object associated
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5103
     * with the current Java virtual machine, if any.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5104
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5105
     * @return  The system console, if any, otherwise <tt>null</tt>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5106
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5107
     * @since   1.6
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5108
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5109
     public static Console console() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5110
         if (cons == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5111
             synchronized (System.class) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5112
                 cons = sun.misc.SharedSecrets.getJavaIOAccess().console();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5113
             }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5114
         }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5115
         return cons;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5116
     }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5117
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5118
    /** 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5119
     * Returns the channel inherited from the entity that created this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5120
     * Java virtual machine.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5121
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5122
     * <p> This method returns the channel obtained by invoking the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5123
     * {@link java.nio.channels.spi.SelectorProvider#inheritedChannel
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5124
     * inheritedChannel} method of the system-wide default
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5125
     * {@link java.nio.channels.spi.SelectorProvider} object. </p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5126
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5127
     * <p> In addition to the network-oriented channels described in
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5128
     * {@link java.nio.channels.spi.SelectorProvider#inheritedChannel
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5129
     * inheritedChannel}, this method may return other kinds of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5130
     * channels in the future.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5131
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5132
     * @return  The inherited channel, if any, otherwise <tt>null</tt>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5133
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5134
     * @throws  IOException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5135
     *          If an I/O error occurs
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5136
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5137
     * @throws  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5138
     *          If a security manager is present and it does not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5139
     *          permit access to the channel.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5140
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5141
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5142
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5143
    public static Channel inheritedChannel() throws IOException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5144
        return SelectorProvider.provider().inheritedChannel();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5145
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5146
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5147
    private static void checkIO() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5148
        SecurityManager sm = getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5149
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5150
            sm.checkPermission(new RuntimePermission("setIO"));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5151
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5152
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5153
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5154
    private static native void setIn0(InputStream in);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5155
    private static native void setOut0(PrintStream out);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5156
    private static native void setErr0(PrintStream err);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5157
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5158
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5159
     * Sets the System security.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5160
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5161
     * <p> If there is a security manager already installed, this method first
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5162
     * calls the security manager''s <code>checkPermission</code> method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5163
     * with a <code>RuntimePermission("setSecurityManager")</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5164
     * permission to ensure it''s ok to replace the existing
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5165
     * security manager.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5166
     * This may result in throwing a <code>SecurityException</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5167
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5168
     * <p> Otherwise, the argument is established as the current
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5169
     * security manager. If the argument is <code>null</code> and no
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5170
     * security manager has been established, then no action is taken and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5171
     * the method simply returns.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5172
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5173
     * @param      s   the security manager.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5174
     * @exception  SecurityException  if the security manager has already
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5175
     *             been set and its <code>checkPermission</code> method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5176
     *             doesn''t allow it to be replaced.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5177
     * @see #getSecurityManager
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5178
     * @see SecurityManager#checkPermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5179
     * @see java.lang.RuntimePermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5180
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5181
    public static
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5182
    void setSecurityManager(final SecurityManager s) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5183
        try {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5184
            s.checkPackageAccess("java.lang");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5185
        } catch (Exception e) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5186
            // no-op
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5187
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5188
        setSecurityManager0(s);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5189
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5190
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5191
    private static synchronized
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5192
    void setSecurityManager0(final SecurityManager s) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5193
        SecurityManager sm = getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5194
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5195
            // ask the currently installed security manager if we
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5196
            // can replace it.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5197
            sm.checkPermission(new RuntimePermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5198
                                     ("setSecurityManager"));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5199
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5200
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5201
        if ((s !!= null) && (s.getClass().getClassLoader() !!= null)) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5202
            // New security manager class is not on bootstrap classpath.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5203
            // Cause policy to get initialized before we install the new
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5204
            // security manager, in order to prevent infinite loops when
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5205
            // trying to initialize the policy (which usually involves
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5206
            // accessing some security and/or system properties, which in turn
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5207
            // calls the installed security manager''s checkPermission method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5208
            // which will loop infinitely if there is a non-system class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5209
            // (in this case: the new security manager class) on the stack).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5210
            AccessController.doPrivileged(new PrivilegedAction() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5211
                public Object run() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5212
                    s.getClass().getProtectionDomain().implies
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5213
                        (SecurityConstants.ALL_PERMISSION);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5214
                    return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5215
                }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5216
            });
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5217
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5218
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5219
        security = s;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5220
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5221
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5222
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5223
     * Gets the system security interface.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5224
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5225
     * @return  if a security manager has already been established for the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5226
     *          current application, then that security manager is returned;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5227
     *          otherwise, <code>null</code> is returned.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5228
     * @see     #setSecurityManager
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5229
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5230
    public static SecurityManager getSecurityManager() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5231
        return security;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5232
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5233
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5234
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5235
     * Returns the current time in milliseconds.  Note that
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5236
     * while the unit of time of the return value is a millisecond,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5237
     * the granularity of the value depends on the underlying
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5238
     * operating system and may be larger.  For example, many
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5239
     * operating systems measure time in units of tens of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5240
     * milliseconds.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5241
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5242
     * <p> See the description of the class <code>Date</code> for
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5243
     * a discussion of slight discrepancies that may arise between
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5244
     * "computer time" and coordinated universal time (UTC).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5245
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5246
     * @return  the difference, measured in milliseconds, between
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5247
     *          the current time and midnight, January 1, 1970 UTC.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5248
     * @see     java.util.Date
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5249
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5250
    public static native long currentTimeMillis();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5251
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5252
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5253
     * Returns the current value of the most precise available system
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5254
     * timer, in nanoseconds.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5255
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5256
     * <p>This method can only be used to measure elapsed time and is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5257
     * not related to any other notion of system or wall-clock time.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5258
     * The value returned represents nanoseconds since some fixed but
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5259
     * arbitrary time (perhaps in the future, so values may be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5260
     * negative).  This method provides nanosecond precision, but not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5261
     * necessarily nanosecond accuracy. No guarantees are made about
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5262
     * how frequently values change. Differences in successive calls
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5263
     * that span greater than approximately 292 years (2<sup>63</sup>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5264
     * nanoseconds) will not accurately compute elapsed time due to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5265
     * numerical overflow.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5266
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5267
     * <p> For example, to measure how long some code takes to execute:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5268
     * <pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5269
     *   long startTime = System.nanoTime();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5270
     *   // ... the code being measured ...
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5271
     *   long estimatedTime = System.nanoTime() - startTime;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5272
     * </pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5273
     * 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5274
     * @return The current value of the system timer, in nanoseconds.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5275
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5276
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5277
    public static native long nanoTime();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5278
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5279
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5280
     * Copies an array from the specified source array, beginning at the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5281
     * specified position, to the specified position of the destination array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5282
     * A subsequence of array components are copied from the source
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5283
     * array referenced by <code>src</code> to the destination array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5284
     * referenced by <code>dest</code>. The number of components copied is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5285
     * equal to the <code>length</code> argument. The components at
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5286
     * positions <code>srcPos</code> through
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5287
     * <code>srcPos+length-1</code> in the source array are copied into
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5288
     * positions <code>destPos</code> through
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5289
     * <code>destPos+length-1</code>, respectively, of the destination
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5290
     * array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5291
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5292
     * If the <code>src</code> and <code>dest</code> arguments refer to the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5293
     * same array object, then the copying is performed as if the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5294
     * components at positions <code>srcPos</code> through
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5295
     * <code>srcPos+length-1</code> were first copied to a temporary
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5296
     * array with <code>length</code> components and then the contents of
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5297
     * the temporary array were copied into positions
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5298
     * <code>destPos</code> through <code>destPos+length-1</code> of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5299
     * destination array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5300
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5301
     * If <code>dest</code> is <code>null</code>, then a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5302
     * <code>NullPointerException</code> is thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5303
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5304
     * If <code>src</code> is <code>null</code>, then a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5305
     * <code>NullPointerException</code> is thrown and the destination
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5306
     * array is not modified.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5307
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5308
     * Otherwise, if any of the following is true, an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5309
     * <code>ArrayStoreException</code> is thrown and the destination is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5310
     * not modified:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5311
     * <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5312
     * <li>The <code>src</code> argument refers to an object that is not an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5313
     *     array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5314
     * <li>The <code>dest</code> argument refers to an object that is not an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5315
     *     array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5316
     * <li>The <code>src</code> argument and <code>dest</code> argument refer
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5317
     *     to arrays whose component types are different primitive types.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5318
     * <li>The <code>src</code> argument refers to an array with a primitive
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5319
     *    component type and the <code>dest</code> argument refers to an array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5320
     *     with a reference component type.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5321
     * <li>The <code>src</code> argument refers to an array with a reference
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5322
     *    component type and the <code>dest</code> argument refers to an array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5323
     *     with a primitive component type.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5324
     * </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5325
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5326
     * Otherwise, if any of the following is true, an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5327
     * <code>IndexOutOfBoundsException</code> is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5328
     * thrown and the destination is not modified:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5329
     * <ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5330
     * <li>The <code>srcPos</code> argument is negative.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5331
     * <li>The <code>destPos</code> argument is negative.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5332
     * <li>The <code>length</code> argument is negative.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5333
     * <li><code>srcPos+length</code> is greater than
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5334
     *     <code>src.length</code>, the length of the source array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5335
     * <li><code>destPos+length</code> is greater than
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5336
     *     <code>dest.length</code>, the length of the destination array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5337
     * </ul>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5338
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5339
     * Otherwise, if any actual component of the source array from
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5340
     * position <code>srcPos</code> through
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5341
     * <code>srcPos+length-1</code> cannot be converted to the component
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5342
     * type of the destination array by assignment conversion, an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5343
     * <code>ArrayStoreException</code> is thrown. In this case, let
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5344
     * <b><i>k</i></b> be the smallest nonnegative integer less than
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5345
     * length such that <code>src[srcPos+</code><i>k</i><code>]</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5346
     * cannot be converted to the component type of the destination
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5347
     * array; when the exception is thrown, source array components from
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5348
     * positions <code>srcPos</code> through
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5349
     * <code>srcPos+</code><i>k</i><code>-1</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5350
     * will already have been copied to destination array positions
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5351
     * <code>destPos</code> through
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5352
     * <code>destPos+</code><i>k</I><code>-1</code> and no other
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5353
     * positions of the destination array will have been modified.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5354
     * (Because of the restrictions already itemized, this
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5355
     * paragraph effectively applies only to the situation where both
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5356
     * arrays have component types that are reference types.)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5357
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5358
     * @param      src      the source array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5359
     * @param      srcPos   starting position in the source array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5360
     * @param      dest     the destination array.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5361
     * @param      destPos  starting position in the destination data.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5362
     * @param      length   the number of array elements to be copied.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5363
     * @exception  IndexOutOfBoundsException  if copying would cause
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5364
     *               access of data outside array bounds.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5365
     * @exception  ArrayStoreException  if an element in the <code>src</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5366
     *               array could not be stored into the <code>dest</code> array
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5367
     *               because of a type mismatch.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5368
     * @exception  NullPointerException if either <code>src</code> or
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5369
     *               <code>dest</code> is <code>null</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5370
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5371
    public static native void arraycopy(Object src,  int  srcPos,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5372
                                        Object dest, int destPos,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5373
                                        int length);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5374
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5375
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5376
     * Returns the same hash code for the given object as
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5377
     * would be returned by the default method hashCode(),
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5378
     * whether or not the given object''s class overrides
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5379
     * hashCode().
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5380
     * The hash code for the null reference is zero.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5381
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5382
     * @param x object for which the hashCode is to be calculated
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5383
     * @return  the hashCode
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5384
     * @since   JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5385
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5386
    public static native int identityHashCode(Object x);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5387
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5388
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5389
     * System properties. The following properties are guaranteed to be defined:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5390
     * <dl>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5391
     * <dt>java.version         <dd>Java version number
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5392
     * <dt>java.vendor          <dd>Java vendor specific string
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5393
     * <dt>java.vendor.url      <dd>Java vendor URL
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5394
     * <dt>java.home            <dd>Java installation directory
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5395
     * <dt>java.class.version   <dd>Java class version number
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5396
     * <dt>java.class.path      <dd>Java classpath
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5397
     * <dt>os.name              <dd>Operating System Name
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5398
     * <dt>os.arch              <dd>Operating System Architecture
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5399
     * <dt>os.version           <dd>Operating System Version
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5400
     * <dt>file.separator       <dd>File separator ("/" on Unix)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5401
     * <dt>path.separator       <dd>Path separator (":" on Unix)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5402
     * <dt>line.separator       <dd>Line separator ("\n" on Unix)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5403
     * <dt>user.name            <dd>User account name
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5404
     * <dt>user.home            <dd>User home directory
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5405
     * <dt>user.dir             <dd>User''s current working directory
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5406
     * </dl>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5407
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5408
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5409
    private static Properties props;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5410
    private static native Properties initProperties(Properties props);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5411
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5412
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5413
     * Determines the current system properties.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5414
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5415
     * First, if there is a security manager, its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5416
     * <code>checkPropertiesAccess</code> method is called with no
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5417
     * arguments. This may result in a security exception.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5418
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5419
     * The current set of system properties for use by the 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5420
     * {@link #getProperty(String)} method is returned as a 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5421
     * <code>Properties</code> object. If there is no current set of 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5422
     * system properties, a set of system properties is first created and 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5423
     * initialized. This set of system properties always includes values 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5424
     * for the following keys: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5425
     * <table summary="Shows property keys and associated values">
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5426
     * <tr><th>Key</th>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5427
     *     <th>Description of Associated Value</th></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5428
     * <tr><td><code>java.version</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5429
     *     <td>Java Runtime Environment version</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5430
     * <tr><td><code>java.vendor</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5431
     *     <td>Java Runtime Environment vendor</td></tr
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5432
     * <tr><td><code>java.vendor.url</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5433
     *     <td>Java vendor URL</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5434
     * <tr><td><code>java.home</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5435
     *     <td>Java installation directory</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5436
     * <tr><td><code>java.vm.specification.version</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5437
     *     <td>Java Virtual Machine specification version</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5438
     * <tr><td><code>java.vm.specification.vendor</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5439
     *     <td>Java Virtual Machine specification vendor</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5440
     * <tr><td><code>java.vm.specification.name</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5441
     *     <td>Java Virtual Machine specification name</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5442
     * <tr><td><code>java.vm.version</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5443
     *     <td>Java Virtual Machine implementation version</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5444
     * <tr><td><code>java.vm.vendor</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5445
     *     <td>Java Virtual Machine implementation vendor</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5446
     * <tr><td><code>java.vm.name</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5447
     *     <td>Java Virtual Machine implementation name</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5448
     * <tr><td><code>java.specification.version</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5449
     *     <td>Java Runtime Environment specification  version</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5450
     * <tr><td><code>java.specification.vendor</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5451
     *     <td>Java Runtime Environment specification  vendor</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5452
     * <tr><td><code>java.specification.name</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5453
     *     <td>Java Runtime Environment specification  name</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5454
     * <tr><td><code>java.class.version</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5455
     *     <td>Java class format version number</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5456
     * <tr><td><code>java.class.path</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5457
     *     <td>Java class path</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5458
     * <tr><td><code>java.library.path</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5459
     *     <td>List of paths to search when loading libraries</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5460
     * <tr><td><code>java.io.tmpdir</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5461
     *     <td>Default temp file path</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5462
     * <tr><td><code>java.compiler</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5463
     *     <td>Name of JIT compiler to use</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5464
     * <tr><td><code>java.ext.dirs</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5465
     *     <td>Path of extension directory or directories</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5466
     * <tr><td><code>os.name</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5467
     *     <td>Operating system name</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5468
     * <tr><td><code>os.arch</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5469
     *     <td>Operating system architecture</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5470
     * <tr><td><code>os.version</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5471
     *     <td>Operating system version</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5472
     * <tr><td><code>file.separator</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5473
     *     <td>File separator ("/" on UNIX)</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5474
     * <tr><td><code>path.separator</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5475
     *     <td>Path separator (":" on UNIX)</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5476
     * <tr><td><code>line.separator</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5477
     *     <td>Line separator ("\n" on UNIX)</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5478
     * <tr><td><code>user.name</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5479
     *     <td>User''s account name</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5480
     * <tr><td><code>user.home</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5481
     *     <td>User''s home directory</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5482
     * <tr><td><code>user.dir</code></td>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5483
     *     <td>User''s current working directory</td></tr>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5484
     * </table>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5485
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5486
     * Multiple paths in a system property value are separated by the path
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5487
     * separator character of the platform.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5488
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5489
     * Note that even if the security manager does not permit the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5490
     * <code>getProperties</code> operation, it may choose to permit the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5491
     * {@link #getProperty(String)} operation.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5492
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5493
     * @return     the system properties
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5494
     * @exception  SecurityException  if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5495
     *             <code>checkPropertiesAccess</code> method doesn''t allow access
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5496
     *              to the system properties.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5497
     * @see        #setProperties
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5498
     * @see        java.lang.SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5499
     * @see        java.lang.SecurityManager#checkPropertiesAccess()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5500
     * @see        java.util.Properties
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5501
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5502
    public static Properties getProperties() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5503
        SecurityManager sm = getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5504
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5505
            sm.checkPropertiesAccess();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5506
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5507
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5508
        return props;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5509
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5510
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5511
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5512
     * Sets the system properties to the <code>Properties</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5513
     * argument.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5514
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5515
     * First, if there is a security manager, its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5516
     * <code>checkPropertiesAccess</code> method is called with no
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5517
     * arguments. This may result in a security exception.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5518
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5519
     * The argument becomes the current set of system properties for use
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5520
     * by the {@link #getProperty(String)} method. If the argument is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5521
     * <code>null</code>, then the current set of system properties is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5522
     * forgotten.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5523
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5524
     * @param      props   the new system properties.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5525
     * @exception  SecurityException  if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5526
     *             <code>checkPropertiesAccess</code> method doesn''t allow access
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5527
     *              to the system properties.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5528
     * @see        #getProperties
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5529
     * @see        java.util.Properties
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5530
     * @see        java.lang.SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5531
     * @see        java.lang.SecurityManager#checkPropertiesAccess()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5532
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5533
    public static void setProperties(Properties props) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5534
        SecurityManager sm = getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5535
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5536
            sm.checkPropertiesAccess();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5537
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5538
        if (props == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5539
            props = new Properties();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5540
            initProperties(props);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5541
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5542
        System.props = props;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5543
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5544
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5545
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5546
     * Gets the system property indicated by the specified key.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5547
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5548
     * First, if there is a security manager, its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5549
     * <code>checkPropertyAccess</code> method is called with the key as
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5550
     * its argument. This may result in a SecurityException.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5551
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5552
     * If there is no current set of system properties, a set of system
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5553
     * properties is first created and initialized in the same manner as
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5554
     * for the <code>getProperties</code> method.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5555
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5556
     * @param      key   the name of the system property.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5557
     * @return     the string value of the system property,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5558
     *             or <code>null</code> if there is no property with that key.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5559
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5560
     * @exception  SecurityException  if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5561
     *             <code>checkPropertyAccess</code> method doesn''t allow
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5562
     *              access to the specified system property.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5563
     * @exception  NullPointerException if <code>key</code> is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5564
     *             <code>null</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5565
     * @exception  IllegalArgumentException if <code>key</code> is empty.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5566
     * @see        #setProperty
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5567
     * @see        java.lang.SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5568
     * @see        java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5569
     * @see        java.lang.System#getProperties()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5570
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5571
    public static String getProperty(String key) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5572
        checkKey(key);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5573
        SecurityManager sm = getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5574
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5575
            sm.checkPropertyAccess(key);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5576
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5577
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5578
        return props.getProperty(key);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5579
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5580
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5581
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5582
     * Gets the system property indicated by the specified key.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5583
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5584
     * First, if there is a security manager, its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5585
     * <code>checkPropertyAccess</code> method is called with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5586
     * <code>key</code> as its argument.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5587
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5588
     * If there is no current set of system properties, a set of system
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5589
     * properties is first created and initialized in the same manner as
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5590
     * for the <code>getProperties</code> method.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5591
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5592
     * @param      key   the name of the system property.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5593
     * @param      def   a default value.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5594
     * @return     the string value of the system property,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5595
     *             or the default value if there is no property with that key.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5596
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5597
     * @exception  SecurityException  if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5598
     *             <code>checkPropertyAccess</code> method doesn''t allow
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5599
     *             access to the specified system property.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5600
     * @exception  NullPointerException if <code>key</code> is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5601
     *             <code>null</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5602
     * @exception  IllegalArgumentException if <code>key</code> is empty.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5603
     * @see        #setProperty
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5604
     * @see        java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5605
     * @see        java.lang.System#getProperties()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5606
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5607
    public static String getProperty(String key, String def) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5608
        checkKey(key);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5609
        SecurityManager sm = getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5610
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5611
            sm.checkPropertyAccess(key);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5612
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5613
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5614
        return props.getProperty(key, def);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5615
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5616
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5617
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5618
     * Sets the system property indicated by the specified key.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5619
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5620
     * First, if a security manager exists, its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5621
     * <code>SecurityManager.checkPermission</code> method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5622
     * is called with a <code>PropertyPermission(key, "write")</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5623
     * permission. This may result in a SecurityException being thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5624
     * If no exception is thrown, the specified property is set to the given
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5625
     * value.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5626
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5627
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5628
     * @param      key   the name of the system property.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5629
     * @param      value the value of the system property.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5630
     * @return     the previous value of the system property,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5631
     *             or <code>null</code> if it did not have one.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5632
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5633
     * @exception  SecurityException  if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5634
     *             <code>checkPermission</code> method doesn''t allow
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5635
     *             setting of the specified property.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5636
     * @exception  NullPointerException if <code>key</code> or 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5637
     *             <code>value</code> is <code>null</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5638
     * @exception  IllegalArgumentException if <code>key</code> is empty.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5639
     * @see        #getProperty
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5640
     * @see        java.lang.System#getProperty(java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5641
     * @see        java.lang.System#getProperty(java.lang.String, java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5642
     * @see        java.util.PropertyPermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5643
     * @see        SecurityManager#checkPermission
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5644
     * @since      1.2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5645
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5646
    public static String setProperty(String key, String value) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5647
        checkKey(key);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5648
        SecurityManager sm = getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5649
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5650
            sm.checkPermission(new PropertyPermission(key,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5651
                SecurityConstants.PROPERTY_WRITE_ACTION));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5652
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5653
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5654
        return (String) props.setProperty(key, value);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5655
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5656
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5657
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5658
     * Removes the system property indicated by the specified key. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5659
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5660
     * First, if a security manager exists, its 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5661
     * <code>SecurityManager.checkPermission</code> method
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5662
     * is called with a <code>PropertyPermission(key, "write")</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5663
     * permission. This may result in a SecurityException being thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5664
     * If no exception is thrown, the specified property is removed.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5665
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5666
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5667
     * @param      key   the name of the system property to be removed. 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5668
     * @return     the previous string value of the system property,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5669
     *             or <code>null</code> if there was no property with that key.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5670
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5671
     * @exception  SecurityException  if a security manager exists and its  
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5672
     *             <code>checkPropertyAccess</code> method doesn''t allow
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5673
     *              access to the specified system property.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5674
     * @exception  NullPointerException if <code>key</code> is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5675
     *             <code>null</code>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5676
     * @exception  IllegalArgumentException if <code>key</code> is empty.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5677
     * @see        #getProperty
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5678
     * @see        #setProperty
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5679
     * @see        java.util.Properties
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5680
     * @see        java.lang.SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5681
     * @see        java.lang.SecurityManager#checkPropertiesAccess()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5682
     * @since 1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5683
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5684
    public static String clearProperty(String key) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5685
        checkKey(key);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5686
        SecurityManager sm = getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5687
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5688
            sm.checkPermission(new PropertyPermission(key, "write"));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5689
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5690
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5691
        return (String) props.remove(key);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5692
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5693
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5694
    private static void checkKey(String key) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5695
        if (key == null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5696
            throw new NullPointerException("key can''t be null");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5697
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5698
        if (key.equals("")) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5699
            throw new IllegalArgumentException("key can''t be empty");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5700
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5701
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5702
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5703
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5704
     * Gets the value of the specified environment variable. An
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5705
     * environment variable is a system-dependent external named
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5706
     * value.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5707
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5708
     * <p>If a security manager exists, its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5709
     * {@link SecurityManager#checkPermission checkPermission}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5710
     * method is called with a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5711
     * <code>{@link RuntimePermission}("getenv."+name)</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5712
     * permission.  This may result in a {@link SecurityException}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5713
     * being thrown.  If no exception is thrown the value of the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5714
     * variable <code>name</code> is returned.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5715
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5716
     * <p><a name="EnvironmentVSSystemProperties"><i>System
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5717
     * properties</i> and <i>environment variables</i></a> are both
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5718
     * conceptually mappings between names and values.  Both
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5719
     * mechanisms can be used to pass user-defined information to a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5720
     * Java process.  Environment variables have a more global effect,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5721
     * because they are visible to all descendants of the process
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5722
     * which defines them, not just the immediate Java subprocess.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5723
     * They can have subtly different semantics, such as case
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5724
     * insensitivity, on different operating systems.  For these
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5725
     * reasons, environment variables are more likely to have
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5726
     * unintended side effects.  It is best to use system properties
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5727
     * where possible.  Environment variables should be used when a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5728
     * global effect is desired, or when an external system interface
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5729
     * requires an environment variable (such as <code>PATH</code>).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5730
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5731
     * <p>On UNIX systems the alphabetic case of <code>name</code> is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5732
     * typically significant, while on Microsoft Windows systems it is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5733
     * typically not.  For example, the expression
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5734
     * <code>System.getenv("FOO").equals(System.getenv("foo"))</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5735
     * is likely to be true on Microsoft Windows.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5736
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5737
     * @param  name the name of the environment variable
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5738
     * @return the string value of the variable, or <code>null</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5739
     *         if the variable is not defined in the system environment
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5740
     * @throws NullPointerException if <code>name</code> is <code>null</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5741
     * @throws SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5742
     *         if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5743
     *         {@link SecurityManager#checkPermission checkPermission}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5744
     *         method doesn''t allow access to the environment variable
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5745
     *         <code>name</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5746
     * @see    #getenv()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5747
     * @see    ProcessBuilder#environment()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5748
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5749
    public static String getenv(String name) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5750
        SecurityManager sm = getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5751
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5752
            sm.checkPermission(new RuntimePermission("getenv."+name));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5753
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5754
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5755
        return ProcessEnvironment.getenv(name);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5756
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5757
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5758
    
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5759
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5760
     * Returns an unmodifiable string map view of the current system environment.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5761
     * The environment is a system-dependent mapping from names to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5762
     * values which is passed from parent to child processes.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5763
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5764
     * <p>If the system does not support environment variables, an
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5765
     * empty map is returned.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5766
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5767
     * <p>The returned map will never contain null keys or values.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5768
     * Attempting to query the presence of a null key or value will
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5769
     * throw a {@link NullPointerException}.  Attempting to query
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5770
     * the presence of a key or value which is not of type
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5771
     * {@link String} will throw a {@link ClassCastException}.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5772
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5773
     * <p>The returned map and its collection views may not obey the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5774
     * general contract of the {@link Object#equals} and
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5775
     * {@link Object#hashCode} methods.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5776
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5777
     * <p>The returned map is typically case-sensitive on all platforms.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5778
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5779
     * <p>If a security manager exists, its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5780
     * {@link SecurityManager#checkPermission checkPermission}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5781
     * method is called with a
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5782
     * <code>{@link RuntimePermission}("getenv.*")</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5783
     * permission.  This may result in a {@link SecurityException} being
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5784
     * thrown.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5785
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5786
     * <p>When passing information to a Java subprocess,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5787
     * <a href=#EnvironmentVSSystemProperties>system properties</a>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5788
     * are generally preferred over environment variables.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5789
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5790
     * @return the environment as a map of variable names to values
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5791
     * @throws SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5792
     *         if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5793
     *         {@link SecurityManager#checkPermission checkPermission}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5794
     *         method doesn''t allow access to the process environment
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5795
     * @see    #getenv(String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5796
     * @see    ProcessBuilder#environment()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5797
     * @since  1.5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5798
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5799
    public static java.util.Map<String,String> getenv() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5800
        SecurityManager sm = getSecurityManager();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5801
        if (sm !!= null) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5802
            sm.checkPermission(new RuntimePermission("getenv.*"));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5803
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5804
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5805
        return ProcessEnvironment.getenv();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5806
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5807
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5808
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5809
     * Terminates the currently running Java Virtual Machine. The
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5810
     * argument serves as a status code; by convention, a nonzero status
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5811
     * code indicates abnormal termination.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5812
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5813
     * This method calls the <code>exit</code> method in class
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5814
     * <code>Runtime</code>. This method never returns normally.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5815
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5816
     * The call <code>System.exit(n)</code> is effectively equivalent to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5817
     * the call:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5818
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5819
     * Runtime.getRuntime().exit(n)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5820
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5821
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5822
     * @param      status   exit status.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5823
     * @throws  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5824
     *        if a security manager exists and its <code>checkExit</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5825
     *        method doesn''t allow exit with the specified status.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5826
     * @see        java.lang.Runtime#exit(int)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5827
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5828
    public static void exit(int status) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5829
        Runtime.getRuntime().exit(status);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5830
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5831
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5832
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5833
     * Runs the garbage collector.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5834
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5835
     * Calling the <code>gc</code> method suggests that the Java Virtual
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5836
     * Machine expend effort toward recycling unused objects in order to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5837
     * make the memory they currently occupy available for quick reuse.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5838
     * When control returns from the method call, the Java Virtual
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5839
     * Machine has made a best effort to reclaim space from all discarded
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5840
     * objects.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5841
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5842
     * The call <code>System.gc()</code> is effectively equivalent to the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5843
     * call:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5844
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5845
     * Runtime.getRuntime().gc()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5846
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5847
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5848
     * @see     java.lang.Runtime#gc()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5849
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5850
    public static void gc() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5851
        Runtime.getRuntime().gc();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5852
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5853
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5854
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5855
     * Runs the finalization methods of any objects pending finalization.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5856
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5857
     * Calling this method suggests that the Java Virtual Machine expend
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5858
     * effort toward running the <code>finalize</code> methods of objects
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5859
     * that have been found to be discarded but whose <code>finalize</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5860
     * methods have not yet been run. When control returns from the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5861
     * method call, the Java Virtual Machine has made a best effort to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5862
     * complete all outstanding finalizations.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5863
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5864
     * The call <code>System.runFinalization()</code> is effectively
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5865
     * equivalent to the call:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5866
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5867
     * Runtime.getRuntime().runFinalization()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5868
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5869
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5870
     * @see     java.lang.Runtime#runFinalization()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5871
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5872
    public static void runFinalization() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5873
        Runtime.getRuntime().runFinalization();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5874
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5875
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5876
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5877
     * Enable or disable finalization on exit; doing so specifies that the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5878
     * finalizers of all objects that have finalizers that have not yet been
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5879
     * automatically invoked are to be run before the Java runtime exits.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5880
     * By default, finalization on exit is disabled.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5881
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5882
     * <p>If there is a security manager,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5883
     * its <code>checkExit</code> method is first called
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5884
     * with 0 as its argument to ensure the exit is allowed.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5885
     * This could result in a SecurityException.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5886
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5887
     * @deprecated  This method is inherently unsafe.  It may result in
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5888
     *      finalizers being called on live objects while other threads are
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5889
     *      concurrently manipulating those objects, resulting in erratic
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5890
     *      behavior or deadlock.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5891
     * @param value indicating enabling or disabling of finalization
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5892
     * @throws  SecurityException
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5893
     *        if a security manager exists and its <code>checkExit</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5894
     *        method doesn''t allow the exit.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5895
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5896
     * @see     java.lang.Runtime#exit(int)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5897
     * @see     java.lang.Runtime#gc()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5898
     * @see     java.lang.SecurityManager#checkExit(int)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5899
     * @since   JDK1.1
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5900
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5901
    @Deprecated
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5902
    public static void runFinalizersOnExit(boolean value) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5903
        Runtime.getRuntime().runFinalizersOnExit(value);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5904
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5905
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5906
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5907
     * Loads a code file with the specified filename from the local file
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5908
     * system as a dynamic library. The filename
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5909
     * argument must be a complete path name.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5910
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5911
     * The call <code>System.load(name)</code> is effectively equivalent
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5912
     * to the call:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5913
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5914
     * Runtime.getRuntime().load(name)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5915
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5916
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5917
     * @param      filename   the file to load.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5918
     * @exception  SecurityException  if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5919
     *             <code>checkLink</code> method doesn''t allow
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5920
     *             loading of the specified dynamic library
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5921
     * @exception  UnsatisfiedLinkError  if the file does not exist.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5922
     * @exception  NullPointerException if <code>filename</code> is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5923
     *             <code>null</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5924
     * @see        java.lang.Runtime#load(java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5925
     * @see        java.lang.SecurityManager#checkLink(java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5926
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5927
    public static void load(String filename) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5928
        Runtime.getRuntime().load0(getCallerClass(), filename);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5929
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5930
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5931
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5932
     * Loads the system library specified by the <code>libname</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5933
     * argument. The manner in which a library name is mapped to the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5934
     * actual system library is system dependent.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5935
     * <p>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5936
     * The call <code>System.loadLibrary(name)</code> is effectively
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5937
     * equivalent to the call
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5938
     * <blockquote><pre>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5939
     * Runtime.getRuntime().loadLibrary(name)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5940
     * </pre></blockquote>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5941
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5942
     * @param      libname   the name of the library.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5943
     * @exception  SecurityException  if a security manager exists and its
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5944
     *             <code>checkLink</code> method doesn''t allow
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5945
     *             loading of the specified dynamic library
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5946
     * @exception  UnsatisfiedLinkError  if the library does not exist.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5947
     * @exception  NullPointerException if <code>libname</code> is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5948
     *             <code>null</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5949
     * @see        java.lang.Runtime#loadLibrary(java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5950
     * @see        java.lang.SecurityManager#checkLink(java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5951
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5952
    public static void loadLibrary(String libname) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5953
        Runtime.getRuntime().loadLibrary0(getCallerClass(), libname);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5954
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5955
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5956
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5957
     * Maps a library name into a platform-specific string representing
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5958
     * a native library.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5959
     *
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5960
     * @param      libname the name of the library.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5961
     * @return     a platform-dependent native library name.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5962
     * @exception  NullPointerException if <code>libname</code> is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5963
     *             <code>null</code>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5964
     * @see        java.lang.System#loadLibrary(java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5965
     * @see        java.lang.ClassLoader#findLibrary(java.lang.String)
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5966
     * @since      1.2
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5967
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5968
    public static native String mapLibraryName(String libname);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5969
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5970
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5971
     * The following two methods exist because in, out, and err must be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5972
     * initialized to null.  The compiler, however, cannot be permitted to
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5973
     * inline access to them, since they are later set to more sensible values
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5974
     * by initializeSystemClass().
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5975
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5976
    private static InputStream nullInputStream() throws NullPointerException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5977
        if (currentTimeMillis() > 0) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5978
            return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5979
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5980
        throw new NullPointerException();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5981
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5982
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5983
    private static PrintStream nullPrintStream() throws NullPointerException {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5984
        if (currentTimeMillis() > 0) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5985
            return null;
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5986
        }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5987
        throw new NullPointerException();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5988
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5989
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5990
    /**
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5991
     * Initialize the system class.  Called after thread initialization.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5992
     */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5993
    private static void initializeSystemClass() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5994
        props = new Properties();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5995
        initProperties(props);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5996
        sun.misc.Version.init();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5997
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5998
        // Workaround until DownloadManager initialization is revisited.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  5999
        // Make JavaLangAccess available early enough for internal
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6000
        // Shutdown hooks to be registered
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6001
        setJavaLangAccess();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6002
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6003
        // Gets and removes system properties that configure the Integer
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6004
        // cache used to support the object identity semantics of autoboxing.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6005
        // At this time, the size of the cache may be controlled by the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6006
        // vm option -XX:AutoBoxCacheMax=<size>.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6007
        Integer.getAndRemoveCacheProperties();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6008
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6009
        // Load the zip library now in order to keep java.util.zip.ZipFile
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6010
        // from trying to use itself to load this library later.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6011
        loadLibrary("zip");
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6012
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6013
        FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6014
        FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6015
        FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6016
        setIn0(new BufferedInputStream(fdIn));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6017
        setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6018
        setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128), true));
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6019
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6020
        // Setup Java signal handlers for HUP, TERM, and INT (where available).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6021
        Terminator.setup();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6022
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6023
        // Initialize any miscellenous operating system settings that need to be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6024
        // set for the class libraries. Currently this is no-op everywhere except
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6025
        // for Windows where the process-wide error mode is set before the java.io
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6026
        // classes are used.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6027
        sun.misc.VM.initializeOSEnvironment();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6028
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6029
        // Set the maximum amount of direct memory.  This value is controlled
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6030
        // by the vm option -XX:MaxDirectMemorySize=<size>.  This method acts
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6031
        // as an initializer only if it is called before sun.misc.VM.booted().
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6032
        sun.misc.VM.maxDirectMemory();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6033
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6034
        // Set a boolean to determine whether ClassLoader.loadClass accepts
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6035
        // array syntax.  This value is controlled by the system property
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6036
        // "sun.lang.ClassLoader.allowArraySyntax".  This method acts as
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6037
        // an initializer only if it is called before sun.misc.VM.booted().
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6038
        sun.misc.VM.allowArraySyntax();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6039
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6040
        // Subsystems that are invoked during initialization can invoke
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6041
        // sun.misc.VM.isBooted() in order to avoid doing things that should
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6042
        // wait until the application class loader has been set up.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6043
        sun.misc.VM.booted();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6044
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6045
        // The main thread is not added to its thread group in the same
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6046
        // way as other threads; we must do it ourselves here.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6047
        Thread current = Thread.currentThread();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6048
        current.getThreadGroup().add(current);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6049
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6050
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6051
    private static void setJavaLangAccess() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6052
        // Allow privileged classes outside of java.lang
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6053
        sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6054
            public sun.reflect.ConstantPool getConstantPool(Class klass) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6055
                return klass.getConstantPool();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6056
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6057
            public void setAnnotationType(Class klass, AnnotationType type) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6058
                klass.setAnnotationType(type);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6059
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6060
            public AnnotationType getAnnotationType(Class klass) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6061
                return klass.getAnnotationType();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6062
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6063
            public <E extends Enum<E>>
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6064
                    E[] getEnumConstantsShared(Class<E> klass) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6065
                return klass.getEnumConstantsShared();
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6066
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6067
            public void blockedOn(Thread t, Interruptible b) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6068
                t.blockedOn(b);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6069
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6070
            public void registerShutdownHook(int slot, Runnable r) {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6071
                Shutdown.add(slot, r);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6072
            }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6073
        });
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6074
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6075
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6076
    /* returns the class of the caller. */
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6077
    static Class getCallerClass() {
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6078
        // NOTE use of more generic Reflection.getCallerClass()
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6079
        return Reflection.getCallerClass(3);
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6080
    }
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6081
}
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6082
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6083
        '
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6084
].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6085
    Transcript showCR: 'java.lang.System parsed in ', time asString, ' miliseconds'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6086
    ^ res.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6087
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6088
    "Modified: / 30-12-2010 / 11:40:03 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6089
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6090
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6091
!JavaParserTests class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6092
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
  6093
version_SVN
2152
1cbdfbcc685c Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 749
diff changeset
  6094
    ^ '$Id: JavaParserTests.st,v 1.1 2011-08-18 19:06:53 vrany Exp $'
1cbdfbcc685c Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 749
diff changeset
  6095
! !