1 /* |
1 /* |
2 * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
33 |
33 |
34 import java.awt.Component; |
34 import java.awt.Component; |
35 |
35 |
36 import java.lang.ref.Reference; |
36 import java.lang.ref.Reference; |
37 import java.lang.ref.SoftReference; |
37 import java.lang.ref.SoftReference; |
|
38 import java.lang.reflect.Constructor; |
38 import java.lang.reflect.Method; |
39 import java.lang.reflect.Method; |
39 import java.lang.reflect.Type; |
40 import java.lang.reflect.Type; |
40 |
41 |
41 import java.util.Map; |
42 import java.util.Map; |
42 import java.util.ArrayList; |
43 import java.util.ArrayList; |
|
44 import java.util.Arrays; |
43 import java.util.HashMap; |
45 import java.util.HashMap; |
44 import java.util.Iterator; |
46 import java.util.Iterator; |
45 import java.util.EventObject; |
47 import java.util.EventObject; |
46 import java.util.List; |
48 import java.util.List; |
47 import java.util.TreeMap; |
49 import java.util.TreeMap; |
|
50 import sun.misc.JavaBeansAccess; |
48 |
51 |
49 import sun.misc.SharedSecrets; |
52 import sun.misc.SharedSecrets; |
50 import sun.reflect.misc.ReflectUtil; |
53 import sun.reflect.misc.ReflectUtil; |
51 |
54 |
52 /** |
55 /** |
144 static final String SET_PREFIX = "set"; |
147 static final String SET_PREFIX = "set"; |
145 static final String IS_PREFIX = "is"; |
148 static final String IS_PREFIX = "is"; |
146 |
149 |
147 // register with SharedSecrets for JMX usage |
150 // register with SharedSecrets for JMX usage |
148 static { |
151 static { |
149 SharedSecrets.setJavaBeansIntrospectorAccess((clazz, property) -> { |
152 SharedSecrets.setJavaBeansAccess(new JavaBeansAccess() { |
150 BeanInfo bi = Introspector.getBeanInfo(clazz); |
153 @Override |
151 PropertyDescriptor[] pds = bi.getPropertyDescriptors(); |
154 public Method getReadMethod(Class<?> clazz, String property) throws Exception { |
152 for (PropertyDescriptor pd: pds) { |
155 BeanInfo bi = Introspector.getBeanInfo(clazz); |
153 if (pd.getName().equals(property)) { |
156 PropertyDescriptor[] pds = bi.getPropertyDescriptors(); |
154 return pd.getReadMethod(); |
157 for (PropertyDescriptor pd: pds) { |
155 } |
158 if (pd.getName().equals(property)) { |
156 } |
159 return pd.getReadMethod(); |
157 return null; |
160 } |
|
161 } |
|
162 return null; |
|
163 } |
|
164 |
|
165 @Override |
|
166 public String[] getConstructorPropertiesValue(Constructor<?> ctr) { |
|
167 ConstructorProperties cp = ctr.getAnnotation(ConstructorProperties.class); |
|
168 String [] ret = cp != null ? cp.value() : null; |
|
169 return ret; |
|
170 } |
158 }); |
171 }); |
159 } |
172 } |
160 |
173 |
161 //====================================================================== |
174 //====================================================================== |
162 // Public methods |
175 // Public methods |