Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
45ed04f5
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
45ed04f5
编写于
10月 08, 2008
作者:
E
emcmanus
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6757225: MXBean: Incorrect type names for parametrized types, dealing with arrays
Reviewed-by: sjiang
上级
e9ae111a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
167 addition
and
38 deletion
+167
-38
src/share/classes/com/sun/jmx/mbeanserver/MXBeanIntrospector.java
...e/classes/com/sun/jmx/mbeanserver/MXBeanIntrospector.java
+26
-1
src/share/classes/javax/management/event/EventClient.java
src/share/classes/javax/management/event/EventClient.java
+16
-8
src/share/classes/javax/management/event/FetchingEventRelay.java
...re/classes/javax/management/event/FetchingEventRelay.java
+20
-20
src/share/classes/javax/management/monitor/Monitor.java
src/share/classes/javax/management/monitor/Monitor.java
+2
-2
src/share/classes/javax/management/remote/rmi/RMIConnector.java
...are/classes/javax/management/remote/rmi/RMIConnector.java
+6
-7
test/javax/management/mxbean/TypeNameTest.java
test/javax/management/mxbean/TypeNameTest.java
+97
-0
未找到文件。
src/share/classes/com/sun/jmx/mbeanserver/MXBeanIntrospector.java
浏览文件 @
45ed04f5
...
@@ -32,6 +32,7 @@ import java.lang.ref.WeakReference;
...
@@ -32,6 +32,7 @@ import java.lang.ref.WeakReference;
import
java.lang.reflect.GenericArrayType
;
import
java.lang.reflect.GenericArrayType
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
import
java.lang.reflect.Type
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.WeakHashMap
;
import
java.util.WeakHashMap
;
...
@@ -390,7 +391,31 @@ class MXBeanIntrospector extends MBeanIntrospector<ConvertingMethod> {
...
@@ -390,7 +391,31 @@ class MXBeanIntrospector extends MBeanIntrospector<ConvertingMethod> {
if
(
type
instanceof
Class
)
if
(
type
instanceof
Class
)
return
((
Class
)
type
).
getName
();
return
((
Class
)
type
).
getName
();
else
else
return
type
.
toString
();
return
genericTypeString
(
type
);
}
private
static
String
genericTypeString
(
Type
type
)
{
if
(
type
instanceof
Class
<?>)
{
Class
<?>
c
=
(
Class
<?>)
type
;
if
(
c
.
isArray
())
return
genericTypeString
(
c
.
getComponentType
())
+
"[]"
;
else
return
c
.
getName
();
}
else
if
(
type
instanceof
GenericArrayType
)
{
GenericArrayType
gat
=
(
GenericArrayType
)
type
;
return
genericTypeString
(
gat
.
getGenericComponentType
())
+
"[]"
;
}
else
if
(
type
instanceof
ParameterizedType
)
{
ParameterizedType
pt
=
(
ParameterizedType
)
type
;
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
genericTypeString
(
pt
.
getRawType
())).
append
(
"<"
);
String
sep
=
""
;
for
(
Type
t
:
pt
.
getActualTypeArguments
())
{
sb
.
append
(
sep
).
append
(
genericTypeString
(
t
));
sep
=
", "
;
}
return
sb
.
append
(
">"
).
toString
();
}
else
return
"???"
;
}
}
private
final
PerInterfaceMap
<
ConvertingMethod
>
private
final
PerInterfaceMap
<
ConvertingMethod
>
...
...
src/share/classes/javax/management/event/EventClient.java
浏览文件 @
45ed04f5
...
@@ -265,12 +265,20 @@ public class EventClient implements EventConsumer, NotificationManager {
...
@@ -265,12 +265,20 @@ public class EventClient implements EventConsumer, NotificationManager {
public
ScheduledThreadPoolExecutor
createThreadPool
(
ThreadGroup
group
)
{
public
ScheduledThreadPoolExecutor
createThreadPool
(
ThreadGroup
group
)
{
ThreadFactory
daemonThreadFactory
=
new
DaemonThreadFactory
(
ThreadFactory
daemonThreadFactory
=
new
DaemonThreadFactory
(
"JMX EventClient lease renewer %d"
);
"JMX EventClient lease renewer %d"
);
ScheduledThreadPoolExecutor
exec
=
new
ScheduledThreadPoolExecutor
(
ScheduledThreadPoolExecutor
executor
=
20
,
daemonThreadFactory
);
new
ScheduledThreadPoolExecutor
(
20
,
daemonThreadFactory
);
exec
.
setKeepAliveTime
(
1
,
TimeUnit
.
SECONDS
);
executor
.
setKeepAliveTime
(
1
,
TimeUnit
.
SECONDS
);
exec
.
allowCoreThreadTimeOut
(
true
);
executor
.
allowCoreThreadTimeOut
(
true
);
exec
.
setRemoveOnCancelPolicy
(
true
);
executor
.
setRemoveOnCancelPolicy
(
true
);
return
exec
;
// By default, a ScheduledThreadPoolExecutor will keep jobs
// in its queue even after they have been cancelled. They
// will only be removed when their scheduled time arrives.
// Since the job references the LeaseRenewer which references
// this EventClient, this can lead to a moderately large number
// of objects remaining referenced until the renewal time
// arrives. Hence the above call, which removes the job from
// the queue as soon as it is cancelled.
return
executor
;
}
}
};
};
return
leaseRenewerThreadPool
.
getThreadPoolExecutor
(
create
);
return
leaseRenewerThreadPool
.
getThreadPoolExecutor
(
create
);
...
@@ -381,7 +389,7 @@ public class EventClient implements EventConsumer, NotificationManager {
...
@@ -381,7 +389,7 @@ public class EventClient implements EventConsumer, NotificationManager {
listenerId
=
listenerId
=
eventClientDelegate
.
addListener
(
clientId
,
name
,
filter
);
eventClientDelegate
.
addListener
(
clientId
,
name
,
filter
);
}
catch
(
EventClientNotFoundException
ecnfe
)
{
}
catch
(
EventClientNotFoundException
ecnfe
)
{
final
IOException
ioe
=
new
IOException
();
final
IOException
ioe
=
new
IOException
(
ecnfe
.
getMessage
()
);
ioe
.
initCause
(
ecnfe
);
ioe
.
initCause
(
ecnfe
);
throw
ioe
;
throw
ioe
;
}
}
...
@@ -488,7 +496,7 @@ public class EventClient implements EventConsumer, NotificationManager {
...
@@ -488,7 +496,7 @@ public class EventClient implements EventConsumer, NotificationManager {
listenerId
=
listenerId
=
eventClientDelegate
.
addSubscriber
(
clientId
,
name
,
filter
);
eventClientDelegate
.
addSubscriber
(
clientId
,
name
,
filter
);
}
catch
(
EventClientNotFoundException
ecnfe
)
{
}
catch
(
EventClientNotFoundException
ecnfe
)
{
final
IOException
ioe
=
new
IOException
();
final
IOException
ioe
=
new
IOException
(
ecnfe
.
getMessage
()
);
ioe
.
initCause
(
ecnfe
);
ioe
.
initCause
(
ecnfe
);
throw
ioe
;
throw
ioe
;
}
}
...
...
src/share/classes/javax/management/event/FetchingEventRelay.java
浏览文件 @
45ed04f5
...
@@ -91,7 +91,7 @@ public class FetchingEventRelay implements EventRelay {
...
@@ -91,7 +91,7 @@ public class FetchingEventRelay implements EventRelay {
* the fetching.
* the fetching.
*
*
* @param delegate The {@code EventClientDelegateMBean} to work with.
* @param delegate The {@code EventClientDelegateMBean} to work with.
* @param
e
xecutor Used to do the fetching. A new thread is created if
* @param
fetchE
xecutor Used to do the fetching. A new thread is created if
* {@code null}.
* {@code null}.
* @throws IOException If failed to work with the {@code delegate}.
* @throws IOException If failed to work with the {@code delegate}.
* @throws MBeanException if unable to add a client to the remote
* @throws MBeanException if unable to add a client to the remote
...
@@ -101,12 +101,12 @@ public class FetchingEventRelay implements EventRelay {
...
@@ -101,12 +101,12 @@ public class FetchingEventRelay implements EventRelay {
* @throws IllegalArgumentException If {@code delegate} is {@code null}.
* @throws IllegalArgumentException If {@code delegate} is {@code null}.
*/
*/
public
FetchingEventRelay
(
EventClientDelegateMBean
delegate
,
public
FetchingEventRelay
(
EventClientDelegateMBean
delegate
,
Executor
e
xecutor
)
throws
IOException
,
MBeanException
{
Executor
fetchE
xecutor
)
throws
IOException
,
MBeanException
{
this
(
delegate
,
this
(
delegate
,
DEFAULT_BUFFER_SIZE
,
DEFAULT_BUFFER_SIZE
,
DEFAULT_WAITING_TIMEOUT
,
DEFAULT_WAITING_TIMEOUT
,
DEFAULT_MAX_NOTIFICATIONS
,
DEFAULT_MAX_NOTIFICATIONS
,
e
xecutor
);
fetchE
xecutor
);
}
}
/**
/**
...
@@ -120,7 +120,7 @@ public class FetchingEventRelay implements EventRelay {
...
@@ -120,7 +120,7 @@ public class FetchingEventRelay implements EventRelay {
* @param timeout The waiting time in millseconds when fetching
* @param timeout The waiting time in millseconds when fetching
* notifications from an {@code EventClientDelegateMBean}.
* notifications from an {@code EventClientDelegateMBean}.
* @param maxNotifs The maximum notifications to fetch every time.
* @param maxNotifs The maximum notifications to fetch every time.
* @param
e
xecutor Used to do the fetching. A new thread is created if
* @param
fetchE
xecutor Used to do the fetching. A new thread is created if
* {@code null}.
* {@code null}.
* @throws IOException if failed to communicate with the {@code delegate}.
* @throws IOException if failed to communicate with the {@code delegate}.
* @throws MBeanException if unable to add a client to the remote
* @throws MBeanException if unable to add a client to the remote
...
@@ -133,12 +133,12 @@ public class FetchingEventRelay implements EventRelay {
...
@@ -133,12 +133,12 @@ public class FetchingEventRelay implements EventRelay {
int
bufferSize
,
int
bufferSize
,
long
timeout
,
long
timeout
,
int
maxNotifs
,
int
maxNotifs
,
Executor
e
xecutor
)
throws
IOException
,
MBeanException
{
Executor
fetchE
xecutor
)
throws
IOException
,
MBeanException
{
this
(
delegate
,
this
(
delegate
,
bufferSize
,
bufferSize
,
timeout
,
timeout
,
maxNotifs
,
maxNotifs
,
e
xecutor
,
fetchE
xecutor
,
FetchingEventForwarder
.
class
.
getName
(),
FetchingEventForwarder
.
class
.
getName
(),
new
Object
[]
{
bufferSize
},
new
Object
[]
{
bufferSize
},
new
String
[]
{
int
.
class
.
getName
()});
new
String
[]
{
int
.
class
.
getName
()});
...
@@ -155,7 +155,7 @@ public class FetchingEventRelay implements EventRelay {
...
@@ -155,7 +155,7 @@ public class FetchingEventRelay implements EventRelay {
* @param timeout The waiting time in millseconds when fetching
* @param timeout The waiting time in millseconds when fetching
* notifications from an {@code EventClientDelegateMBean}.
* notifications from an {@code EventClientDelegateMBean}.
* @param maxNotifs The maximum notifications to fetch every time.
* @param maxNotifs The maximum notifications to fetch every time.
* @param
e
xecutor Used to do the fetching.
* @param
fetchE
xecutor Used to do the fetching.
* @param forwarderName the class name of a user specific EventForwarder
* @param forwarderName the class name of a user specific EventForwarder
* to create in server to forward notifications to this object. The class
* to create in server to forward notifications to this object. The class
* should be a subclass of the class {@link FetchingEventForwarder}.
* should be a subclass of the class {@link FetchingEventForwarder}.
...
@@ -174,7 +174,7 @@ public class FetchingEventRelay implements EventRelay {
...
@@ -174,7 +174,7 @@ public class FetchingEventRelay implements EventRelay {
int
bufferSize
,
int
bufferSize
,
long
timeout
,
long
timeout
,
int
maxNotifs
,
int
maxNotifs
,
Executor
e
xecutor
,
Executor
fetchE
xecutor
,
String
forwarderName
,
String
forwarderName
,
Object
[]
params
,
Object
[]
params
,
String
[]
sig
)
throws
IOException
,
MBeanException
{
String
[]
sig
)
throws
IOException
,
MBeanException
{
...
@@ -184,11 +184,11 @@ public class FetchingEventRelay implements EventRelay {
...
@@ -184,11 +184,11 @@ public class FetchingEventRelay implements EventRelay {
bufferSize
+
" "
+
bufferSize
+
" "
+
timeout
+
" "
+
timeout
+
" "
+
maxNotifs
+
" "
+
maxNotifs
+
" "
+
e
xecutor
+
" "
+
fetchE
xecutor
+
" "
+
forwarderName
+
" "
);
forwarderName
+
" "
);
}
}
if
(
delegate
==
null
)
{
if
(
delegate
==
null
)
{
throw
new
NullPointerException
(
"Null EventClientDelegateMBean!"
);
throw
new
NullPointerException
(
"Null EventClientDelegateMBean!"
);
}
}
...
@@ -212,16 +212,16 @@ public class FetchingEventRelay implements EventRelay {
...
@@ -212,16 +212,16 @@ public class FetchingEventRelay implements EventRelay {
this
.
timeout
=
timeout
;
this
.
timeout
=
timeout
;
this
.
maxNotifs
=
maxNotifs
;
this
.
maxNotifs
=
maxNotifs
;
if
(
e
xecutor
==
null
)
{
if
(
fetchE
xecutor
==
null
)
{
ScheduledThreadPoolExecutor
stpe
=
new
ScheduledThreadPoolExecutor
(
1
,
ScheduledThreadPoolExecutor
executor
=
daemonThreadFactory
);
new
ScheduledThreadPoolExecutor
(
1
,
daemonThreadFactory
);
stpe
.
setKeepAliveTime
(
1
,
TimeUnit
.
SECONDS
);
executor
.
setKeepAliveTime
(
1
,
TimeUnit
.
SECONDS
);
stpe
.
allowCoreThreadTimeOut
(
true
);
executor
.
allowCoreThreadTimeOut
(
true
);
executor
=
stpe
;
fetchExecutor
=
executor
;
this
.
defaultExecutor
=
stpe
;
this
.
defaultExecutor
=
executor
;
}
else
}
else
this
.
defaultExecutor
=
null
;
this
.
defaultExecutor
=
null
;
this
.
executor
=
e
xecutor
;
this
.
fetchExecutor
=
fetchE
xecutor
;
startSequenceNumber
=
0
;
startSequenceNumber
=
0
;
fetchingJob
=
new
MyJob
();
fetchingJob
=
new
MyJob
();
...
@@ -258,7 +258,7 @@ public class FetchingEventRelay implements EventRelay {
...
@@ -258,7 +258,7 @@ public class FetchingEventRelay implements EventRelay {
private
class
MyJob
extends
RepeatedSingletonJob
{
private
class
MyJob
extends
RepeatedSingletonJob
{
public
MyJob
()
{
public
MyJob
()
{
super
(
e
xecutor
);
super
(
fetchE
xecutor
);
}
}
public
boolean
isSuspended
()
{
public
boolean
isSuspended
()
{
...
@@ -368,7 +368,7 @@ public class FetchingEventRelay implements EventRelay {
...
@@ -368,7 +368,7 @@ public class FetchingEventRelay implements EventRelay {
private
String
clientId
;
private
String
clientId
;
private
boolean
stopped
=
false
;
private
boolean
stopped
=
false
;
private
final
Executor
e
xecutor
;
private
final
Executor
fetchE
xecutor
;
private
final
ExecutorService
defaultExecutor
;
private
final
ExecutorService
defaultExecutor
;
private
final
MyJob
fetchingJob
;
private
final
MyJob
fetchingJob
;
...
...
src/share/classes/javax/management/monitor/Monitor.java
浏览文件 @
45ed04f5
...
@@ -181,7 +181,7 @@ public abstract class Monitor
...
@@ -181,7 +181,7 @@ public abstract class Monitor
/**
/**
* Executor Service.
* Executor Service.
*/
*/
private
static
final
ExecutorService
executor
;
private
static
final
ThreadPoolExecutor
executor
;
static
{
static
{
final
String
maximumPoolSizeSysProp
=
"jmx.x.monitor.maximum.pool.size"
;
final
String
maximumPoolSizeSysProp
=
"jmx.x.monitor.maximum.pool.size"
;
final
String
maximumPoolSizeStr
=
AccessController
.
doPrivileged
(
final
String
maximumPoolSizeStr
=
AccessController
.
doPrivileged
(
...
@@ -218,7 +218,7 @@ public abstract class Monitor
...
@@ -218,7 +218,7 @@ public abstract class Monitor
TimeUnit
.
SECONDS
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(),
new
LinkedBlockingQueue
<
Runnable
>(),
new
DaemonThreadFactory
(
"Executor"
));
new
DaemonThreadFactory
(
"Executor"
));
((
ThreadPoolExecutor
)
executor
)
.
allowCoreThreadTimeOut
(
true
);
executor
.
allowCoreThreadTimeOut
(
true
);
}
}
/**
/**
...
...
src/share/classes/javax/management/remote/rmi/RMIConnector.java
浏览文件 @
45ed04f5
...
@@ -71,9 +71,8 @@ import java.util.Map;
...
@@ -71,9 +71,8 @@ import java.util.Map;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.WeakHashMap
;
import
java.util.WeakHashMap
;
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.LinkedBlocking
Deq
ue
;
import
java.util.concurrent.LinkedBlocking
Que
ue
;
import
java.util.concurrent.ThreadFactory
;
import
java.util.concurrent.ThreadFactory
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -421,12 +420,12 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
...
@@ -421,12 +420,12 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
public
ThreadPoolExecutor
createThreadPool
(
ThreadGroup
group
)
{
public
ThreadPoolExecutor
createThreadPool
(
ThreadGroup
group
)
{
ThreadFactory
daemonThreadFactory
=
new
DaemonThreadFactory
(
ThreadFactory
daemonThreadFactory
=
new
DaemonThreadFactory
(
"JMX RMIConnector listener dispatch %d"
);
"JMX RMIConnector listener dispatch %d"
);
ThreadPoolExecutor
exec
=
new
ThreadPoolExecutor
(
ThreadPoolExecutor
exec
utor
=
new
ThreadPoolExecutor
(
1
,
10
,
1
,
TimeUnit
.
SECONDS
,
1
,
10
,
1
,
TimeUnit
.
SECONDS
,
new
LinkedBlocking
Deq
ue
<
Runnable
>(),
new
LinkedBlocking
Que
ue
<
Runnable
>(),
daemonThreadFactory
);
daemonThreadFactory
);
exec
.
allowCoreThreadTimeOut
(
true
);
exec
utor
.
allowCoreThreadTimeOut
(
true
);
return
exec
;
return
exec
utor
;
}
}
};
};
return
listenerDispatchThreadPool
.
getThreadPoolExecutor
(
create
);
return
listenerDispatchThreadPool
.
getThreadPoolExecutor
(
create
);
...
@@ -1503,7 +1502,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
...
@@ -1503,7 +1502,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
super
(
period
);
super
(
period
);
}
}
public
void
gotIOException
(
IOException
ioe
)
throws
IOException
{
public
void
gotIOException
(
IOException
ioe
)
throws
IOException
{
if
(
ioe
instanceof
NoSuchObjectException
)
{
if
(
ioe
instanceof
NoSuchObjectException
)
{
// need to restart
// need to restart
super
.
gotIOException
(
ioe
);
super
.
gotIOException
(
ioe
);
...
...
test/javax/management/mxbean/TypeNameTest.java
0 → 100644
浏览文件 @
45ed04f5
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6757225
* @summary Test that type names in MXBeans match their spec.
* @author Eamonn McManus
*/
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationHandler
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Proxy
;
import
java.util.List
;
import
java.util.Map
;
import
javax.management.MBeanAttributeInfo
;
import
javax.management.MBeanInfo
;
import
javax.management.MBeanServer
;
import
javax.management.MBeanServerFactory
;
import
javax.management.ObjectName
;
import
javax.management.StandardMBean
;
public
class
TypeNameTest
{
public
static
interface
TestMXBean
{
public
int
getInt
();
public
String
IntName
=
"int"
;
public
Map
<
String
,
Integer
>
getMapSI
();
public
String
MapSIName
=
"java.util.Map<java.lang.String, java.lang.Integer>"
;
public
Map
<
String
,
int
[]>
getMapSInts
();
public
String
MapSIntsName
=
"java.util.Map<java.lang.String, int[]>"
;
public
List
<
List
<
int
[]>>
getListListInts
();
public
String
ListListIntsName
=
"java.util.List<java.util.List<int[]>>"
;
}
private
static
InvocationHandler
nullIH
=
new
InvocationHandler
()
{
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
throws
Throwable
{
return
null
;
}
};
static
String
failure
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
TestMXBean
testImpl
=
(
TestMXBean
)
Proxy
.
newProxyInstance
(
TestMXBean
.
class
.
getClassLoader
(),
new
Class
<?>[]
{
TestMXBean
.
class
},
nullIH
);
Object
mxbean
=
new
StandardMBean
(
testImpl
,
TestMXBean
.
class
,
true
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
ObjectName
name
=
new
ObjectName
(
"a:b=c"
);
mbs
.
registerMBean
(
mxbean
,
name
);
MBeanInfo
mbi
=
mbs
.
getMBeanInfo
(
name
);
MBeanAttributeInfo
[]
mbais
=
mbi
.
getAttributes
();
for
(
MBeanAttributeInfo
mbai
:
mbais
)
{
String
attrName
=
mbai
.
getName
();
String
attrTypeName
=
(
String
)
mbai
.
getDescriptor
().
getFieldValue
(
"originalType"
);
String
fieldName
=
attrName
+
"Name"
;
Field
nameField
=
TestMXBean
.
class
.
getField
(
fieldName
);
String
expectedTypeName
=
(
String
)
nameField
.
get
(
null
);
if
(
expectedTypeName
.
equals
(
attrTypeName
))
{
System
.
out
.
println
(
"OK: "
+
attrName
+
": "
+
attrTypeName
);
}
else
{
failure
=
"For attribute "
+
attrName
+
" expected type name \""
+
expectedTypeName
+
"\", found type name \""
+
attrTypeName
+
"\""
;
System
.
out
.
println
(
"FAIL: "
+
failure
);
}
}
if
(
failure
==
null
)
System
.
out
.
println
(
"TEST PASSED"
);
else
throw
new
Exception
(
"TEST FAILED: "
+
failure
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录