java.beans.MethodDescriptor Java Examples

The following examples show how to use java.beans.MethodDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventSetDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_EventSetDescriptor_Constructor() throws Exception {
    EventSetDescriptor eventSetDescriptor = new EventSetDescriptor(
            (String) null, (Class<?>) null, new MethodDescriptor[] { null,
                    null }, (Method) null, (Method) null);
    assertNull(eventSetDescriptor.getName());
    assertNull(eventSetDescriptor.getListenerType());
    assertNull(eventSetDescriptor.getAddListenerMethod());
    assertNull(eventSetDescriptor.getRemoveListenerMethod());

    try {
        eventSetDescriptor.getListenerMethods();
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
 
Example #2
Source File: DefaultWidgetIntrospector.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
	Introspector.flushFromCaches(beanClass);
	BeanInfo bi = Introspector.getBeanInfo(beanClass);
	BeanDescriptor bd = bi.getBeanDescriptor();
	MethodDescriptor mds[] = bi.getMethodDescriptors();
	EventSetDescriptor esds[] = bi.getEventSetDescriptors();
	PropertyDescriptor pds[] = bi.getPropertyDescriptors();

	List<PropertyDescriptor> filteredPDList = new ArrayList<PropertyDescriptor>();
	
	List<String> nonPropList = Arrays.asList(getNonProperties());
	for(PropertyDescriptor pd : pds){
		if(!nonPropList.contains(pd.getName()) && pd.getWriteMethod() != null && pd.getReadMethod() != null)
			filteredPDList.add(pd);
	}
	
	int defaultEvent = bi.getDefaultEventIndex();
	int defaultProperty = bi.getDefaultPropertyIndex();

     return new GenericBeanInfo(bd, esds, defaultEvent, 
    		 filteredPDList.toArray(new PropertyDescriptor[filteredPDList.size()]),
			defaultProperty, mds, null);
	
}
 
Example #3
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testGetBeanInfo_StaticMethods() throws Exception {
    BeanInfo beanInfo = Introspector.getBeanInfo(StaticClazz.class);
    PropertyDescriptor[] propertyDescriptors = beanInfo
            .getPropertyDescriptors();
    assertEquals(1, propertyDescriptors.length);
    assertTrue(contains("class", Class.class, propertyDescriptors));
    MethodDescriptor[] methodDescriptors = beanInfo.getMethodDescriptors();
    assertTrue(contains("getStaticMethod", methodDescriptors));
    assertTrue(contains("setStaticMethod", methodDescriptors));

    beanInfo = Introspector.getBeanInfo(StaticClazzWithProperty.class);
    propertyDescriptors = beanInfo.getPropertyDescriptors();
    assertEquals(1, propertyDescriptors.length);
    methodDescriptors = beanInfo.getMethodDescriptors();
    assertTrue(contains("getStaticName", methodDescriptors));
    assertTrue(contains("setStaticName", methodDescriptors));
}
 
Example #4
Source File: EventSetDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod_ListenerMDNull()
        throws IntrospectionException, NoSuchMethodException {
    String eventSetName = "MockPropertyChange";
    Class<?> listenerType = MockPropertyChangeListener.class;

    Class<MockSourceClass> sourceClass = MockSourceClass.class;
    Method addMethod = sourceClass.getMethod(
            "addMockPropertyChangeListener", listenerType);
    Method removeMethod = sourceClass.getMethod(
            "removeMockPropertyChangeListener", listenerType);

    EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
            listenerType, (MethodDescriptor[]) null, addMethod,
            removeMethod);

    assertNull(esd.getListenerMethodDescriptors());
    assertNull(esd.getListenerMethods());
}
 
Example #5
Source File: EventSetDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetInDefaultEventSet_false() throws SecurityException,
        NoSuchMethodException, IntrospectionException {
    String eventSetName = "MockPropertyChange";
    Class<?> listenerType = MockPropertyChangeListener.class;
    Method[] listenerMethods = {
            listenerType.getMethod("mockPropertyChange",
                    new Class[] { MockPropertyChangeEvent.class }),
            listenerType.getMethod("mockPropertyChange2",
                    new Class[] { MockPropertyChangeEvent.class }), };
    MethodDescriptor[] listenerMethodDescriptors = {
            new MethodDescriptor(listenerMethods[0]),
            new MethodDescriptor(listenerMethods[1]), };
    Class<MockSourceClass> sourceClass = MockSourceClass.class;
    Method addMethod = sourceClass.getMethod(
            "addMockPropertyChangeListener", new Class[] { listenerType });
    Method removeMethod = sourceClass.getMethod(
            "removeMockPropertyChangeListener",
            new Class[] { listenerType });

    EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
            listenerType, listenerMethodDescriptors, addMethod,
            removeMethod);
    assertTrue(esd.isInDefaultEventSet());
    esd.setInDefaultEventSet(false);
    assertFalse(esd.isInDefaultEventSet());
}
 
Example #6
Source File: QuartzSchedulerMBeanImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static Method findMethod(Class<?> targetType, String methodName,
        Class<?>[] argTypes) throws IntrospectionException {
    BeanInfo beanInfo = Introspector.getBeanInfo(targetType);
    if (beanInfo != null) {
        for(MethodDescriptor methodDesc: beanInfo.getMethodDescriptors()) {
            Method method = methodDesc.getMethod();
            Class<?>[] parameterTypes = method.getParameterTypes();
            if (methodName.equals(method.getName()) && argTypes.length == parameterTypes.length) {
                boolean matchedArgTypes = true;
                for (int i = 0; i < argTypes.length; i++) { 
                    if (getWrapperIfPrimitive(argTypes[i]) != parameterTypes[i]) {
                        matchedArgTypes = false;
                        break;
                    }
                }
                if (matchedArgTypes) {
                    return method;
                }
            }
        }
    }
    return null;
}
 
Example #7
Source File: EventSetDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetUnicast_false() throws SecurityException,
        NoSuchMethodException, IntrospectionException {
    String eventSetName = "MockPropertyChange";
    Class<?> listenerType = MockPropertyChangeListener.class;
    Method[] listenerMethods = {
            listenerType.getMethod("mockPropertyChange",
                    MockPropertyChangeEvent.class),
            listenerType.getMethod("mockPropertyChange2",
                    MockPropertyChangeEvent.class) };
    MethodDescriptor[] listenerMethodDescriptors = {
            new MethodDescriptor(listenerMethods[0]),
            new MethodDescriptor(listenerMethods[1]), };
    Class<MockSourceClass> sourceClass = MockSourceClass.class;
    Method addMethod = sourceClass.getMethod(
            "addMockPropertyChangeListener",listenerType);
    Method removeMethod = sourceClass.getMethod(
            "removeMockPropertyChangeListener", listenerType);

    EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
            listenerType, listenerMethodDescriptors, addMethod,
            removeMethod);
    assertFalse(esd.isUnicast());
    esd.setInDefaultEventSet(false);
    assertFalse(esd.isInDefaultEventSet());
}
 
Example #8
Source File: MethodDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testMethodDescriptorMethod() throws SecurityException,
        NoSuchMethodException {
    String beanName = "MethodDescriptorTest.bean";
    MockJavaBean bean = new MockJavaBean(beanName);
    Method method = bean.getClass()
            .getMethod("getBeanName", (Class[]) null);
    MethodDescriptor md = new MethodDescriptor(method);

    assertSame(method, md.getMethod());
    assertNull(md.getParameterDescriptors());

    assertEquals(method.getName(), md.getDisplayName());
    assertEquals(method.getName(), md.getName());
    assertEquals(method.getName(), md.getShortDescription());

    assertNotNull(md.attributeNames());

    assertFalse(md.isExpert());
    assertFalse(md.isHidden());
    assertFalse(md.isPreferred());
}
 
Example #9
Source File: ExtendedBeanInfo.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
	List<Method> matches = new ArrayList<Method>();
	for (MethodDescriptor methodDescriptor : methodDescriptors) {
		Method method = methodDescriptor.getMethod();
		if (isCandidateWriteMethod(method)) {
			matches.add(method);
		}
	}
	// Sort non-void returning write methods to guard against the ill effects of
	// non-deterministic sorting of methods returned from Class#getDeclaredMethods
	// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
	Collections.sort(matches, new Comparator<Method>() {
		@Override
		public int compare(Method m1, Method m2) {
			return m2.toString().compareTo(m1.toString());
		}
	});
	return matches;
}
 
Example #10
Source File: IntrospectorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testGetBeanInfoClassint_IGNORE_ALL_Method()
        throws IntrospectionException {
    BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
            Introspector.IGNORE_ALL_BEANINFO);
    MethodDescriptor[] mds = info.getMethodDescriptors();
    int getMethod = 0;
    int setMethod = 0;
    for (MethodDescriptor element : mds) {
        String name = element.getName();
        if (name.startsWith("getText")) {
            getMethod++;
            assertEquals("getText", name);
        }
        if (name.startsWith("setText")) {
            setMethod++;
            assertEquals("setText", name);
        }
    }

    assertEquals(1, getMethod);
    assertEquals(1, setMethod);
}
 
Example #11
Source File: SolrPluginUtils.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private static Method findSetter(Class<?> clazz, String setterName, String key, Class<?> paramClazz, boolean lenient) {
  BeanInfo beanInfo;
  try {
    beanInfo = Introspector.getBeanInfo(clazz);
  } catch (IntrospectionException ie) {
    if (lenient) {
      return null;
    }
    throw new RuntimeException("Error getting bean info for class : " + clazz.getName(), ie);
  }
  for (final boolean matchParamClazz: new boolean[]{true, false}) {
    for (final MethodDescriptor desc : beanInfo.getMethodDescriptors()) {
      final Method m = desc.getMethod();
      final Class<?> p[] = m.getParameterTypes();
      if (m.getName().equals(setterName) && p.length == 1 &&
          (!matchParamClazz || paramClazz.equals(p[0]))) {
        return m;
      }
    }
  }
  if (lenient) {
    return null;
  }
  throw new RuntimeException("No setter corrresponding to '" + key + "' in " + clazz.getName());
}
 
Example #12
Source File: ExtendedBeanInfo.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
	List<Method> matches = new ArrayList<Method>();
	for (MethodDescriptor methodDescriptor : methodDescriptors) {
		Method method = methodDescriptor.getMethod();
		if (isCandidateWriteMethod(method)) {
			matches.add(method);
		}
	}
	// Sort non-void returning write methods to guard against the ill effects of
	// non-deterministic sorting of methods returned from Class#getDeclaredMethods
	// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
	Collections.sort(matches, new Comparator<Method>() {
		@Override
		public int compare(Method m1, Method m2) {
			return m2.toString().compareTo(m1.toString());
		}
	});
	return matches;
}
 
Example #13
Source File: ExtendedBeanInfo.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
	List<Method> matches = new ArrayList<>();
	for (MethodDescriptor methodDescriptor : methodDescriptors) {
		Method method = methodDescriptor.getMethod();
		if (isCandidateWriteMethod(method)) {
			matches.add(method);
		}
	}
	// Sort non-void returning write methods to guard against the ill effects of
	// non-deterministic sorting of methods returned from Class#getDeclaredMethods
	// under JDK 7. See https://bugs.java.com/view_bug.do?bug_id=7023180
	matches.sort((m1, m2) -> m2.toString().compareTo(m1.toString()));
	return matches;
}
 
Example #14
Source File: Test8005065.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testEventSetDescriptor() {
    try {
        MethodDescriptor[] array = { new MethodDescriptor(MyDPD.class.getMethod("getArray")) };
        EventSetDescriptor descriptor = new EventSetDescriptor(null, null, array, null, null);
        test(descriptor.getListenerMethodDescriptors());
        array[0] = null;
        test(descriptor.getListenerMethodDescriptors());
        descriptor.getListenerMethodDescriptors()[0] = null;
        test(descriptor.getListenerMethodDescriptors());
    }
    catch (Exception exception) {
        throw new Error("unexpected error", exception);
    }
}
 
Example #15
Source File: Test6277246.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
Example #16
Source File: Test8005065.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testEventSetDescriptor() {
    try {
        MethodDescriptor[] array = { new MethodDescriptor(MyDPD.class.getMethod("getArray")) };
        EventSetDescriptor descriptor = new EventSetDescriptor(null, null, array, null, null);
        test(descriptor.getListenerMethodDescriptors());
        array[0] = null;
        test(descriptor.getListenerMethodDescriptors());
        descriptor.getListenerMethodDescriptors()[0] = null;
        test(descriptor.getListenerMethodDescriptors());
    }
    catch (Exception exception) {
        throw new Error("unexpected error", exception);
    }
}
 
Example #17
Source File: OverrideUserDefPropertyInfoTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public MethodDescriptor[] getMethodDescriptors() {
    MethodDescriptor[] m = new MethodDescriptor[1];
    try {
        m[0] = new MethodDescriptor(Base.class.getMethod("setX", new Class[] {int.class}));
        m[0].setDisplayName("");
    }
    catch( NoSuchMethodException | SecurityException e) {}
    return m;
}
 
Example #18
Source File: Test8005065.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void testMethodDescriptor() {
    try {
        ParameterDescriptor[] array = { new ParameterDescriptor() };
        MethodDescriptor descriptor = new MethodDescriptor(MyDPD.class.getMethod("getArray"), array);
        test(descriptor.getParameterDescriptors());
        array[0] = null;
        test(descriptor.getParameterDescriptors());
        descriptor.getParameterDescriptors()[0] = null;
        test(descriptor.getParameterDescriptors());
    }
    catch (Exception exception) {
        throw new Error("unexpected error", exception);
    }
}
 
Example #19
Source File: Test8005065.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void testEventSetDescriptor() {
    try {
        MethodDescriptor[] array = { new MethodDescriptor(MyDPD.class.getMethod("getArray")) };
        EventSetDescriptor descriptor = new EventSetDescriptor(null, null, array, null, null);
        test(descriptor.getListenerMethodDescriptors());
        array[0] = null;
        test(descriptor.getListenerMethodDescriptors());
        descriptor.getListenerMethodDescriptors()[0] = null;
        test(descriptor.getListenerMethodDescriptors());
    }
    catch (Exception exception) {
        throw new Error("unexpected error", exception);
    }
}
 
Example #20
Source File: UnloadClassBeanInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws Exception {
    Class cl = getStub();
    System.out.println("cl.getClassLoader() = " + cl.getClassLoader());
    final BeanInfo beanInfo = Introspector.getBeanInfo(cl, Object.class);
    MethodDescriptor[] mds = beanInfo.getMethodDescriptors();
    System.out.println("mds = " + Arrays.toString(mds));
    loader.close();
    loader=null;
    cl=null;
    Util.generateOOME();
    mds = beanInfo.getMethodDescriptors();
    System.out.println("mds = " + Arrays.toString(mds));
}
 
Example #21
Source File: Test6277246.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}
 
Example #22
Source File: MethodDescriptorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * @tests java.beans.MethodDescriptor#MethodDescriptor(
 *        java.lang.reflect.Method)
 */
public void test_Ctor1_NullPointerException() {
    try {
        // Regression for HARMONY-226
        new MethodDescriptor(null);
        fail("No expected NullPointerException");
    } catch (NullPointerException e) {
    }
}
 
Example #23
Source File: Test8005065.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void testEventSetDescriptor() {
    try {
        MethodDescriptor[] array = { new MethodDescriptor(MyDPD.class.getMethod("getArray")) };
        EventSetDescriptor descriptor = new EventSetDescriptor(null, null, array, null, null);
        test(descriptor.getListenerMethodDescriptors());
        array[0] = null;
        test(descriptor.getListenerMethodDescriptors());
        descriptor.getListenerMethodDescriptors()[0] = null;
        test(descriptor.getListenerMethodDescriptors());
    }
    catch (Exception exception) {
        throw new Error("unexpected error", exception);
    }
}
 
Example #24
Source File: Test8005065.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void testMethodDescriptor() {
    try {
        ParameterDescriptor[] array = { new ParameterDescriptor() };
        MethodDescriptor descriptor = new MethodDescriptor(MyDPD.class.getMethod("getArray"), array);
        test(descriptor.getParameterDescriptors());
        array[0] = null;
        test(descriptor.getParameterDescriptors());
        descriptor.getParameterDescriptors()[0] = null;
        test(descriptor.getParameterDescriptors());
    }
    catch (Exception exception) {
        throw new Error("unexpected error", exception);
    }
}
 
Example #25
Source File: ExtendedBeanInfo.java    From blog_demos with Apache License 2.0 5 votes vote down vote up
/**
 * Wrap the given {@link BeanInfo} instance; copy all its existing property descriptors
 * locally, wrapping each in a custom {@link SimpleIndexedPropertyDescriptor indexed}
 * or {@link SimplePropertyDescriptor non-indexed} {@code PropertyDescriptor}
 * variant that bypasses default JDK weak/soft reference management; then search
 * through its method descriptors to find any non-void returning write methods and
 * update or create the corresponding {@link PropertyDescriptor} for each one found.
 * @param delegate the wrapped {@code BeanInfo}, which is never modified
 * @throws IntrospectionException if any problems occur creating and adding new
 * property descriptors
 * @see #getPropertyDescriptors()
 */
public ExtendedBeanInfo(BeanInfo delegate) throws IntrospectionException {
	this.delegate = delegate;
	for (PropertyDescriptor pd : delegate.getPropertyDescriptors()) {
		this.propertyDescriptors.add(pd instanceof IndexedPropertyDescriptor ?
				new SimpleIndexedPropertyDescriptor((IndexedPropertyDescriptor) pd) :
				new SimplePropertyDescriptor(pd));
	}
	MethodDescriptor[] methodDescriptors = delegate.getMethodDescriptors();
	if (methodDescriptors != null) {
		for (Method method : findCandidateWriteMethods(methodDescriptors)) {
			handleCandidateWriteMethod(method);
		}
	}
}
 
Example #26
Source File: UnloadClassBeanInfo.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws Exception {
    Class cl = getStub();
    System.out.println("cl.getClassLoader() = " + cl.getClassLoader());
    final BeanInfo beanInfo = Introspector.getBeanInfo(cl, Object.class);
    MethodDescriptor[] mds = beanInfo.getMethodDescriptors();
    System.out.println("mds = " + Arrays.toString(mds));
    loader.close();
    loader=null;
    cl=null;
    Util.generateOOME();
    mds = beanInfo.getMethodDescriptors();
    System.out.println("mds = " + Arrays.toString(mds));
}
 
Example #27
Source File: Test8005065.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void testMethodDescriptor() {
    try {
        ParameterDescriptor[] array = { new ParameterDescriptor() };
        MethodDescriptor descriptor = new MethodDescriptor(MyDPD.class.getMethod("getArray"), array);
        test(descriptor.getParameterDescriptors());
        array[0] = null;
        test(descriptor.getParameterDescriptors());
        descriptor.getParameterDescriptors()[0] = null;
        test(descriptor.getParameterDescriptors());
    }
    catch (Exception exception) {
        throw new Error("unexpected error", exception);
    }
}
 
Example #28
Source File: JOutlookBarBeanInfo.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the methodDescriptors attribute ...
 *
 * @return   The methodDescriptors value
 */
public MethodDescriptor[] getMethodDescriptors() {
   Vector descriptors = new Vector();
   MethodDescriptor descriptor = null;
   Method[] m;
   Method method;

   try {
      m = Class.forName("com.l2fprod.common.swing.JOutlookBar").getMethods();
   } catch (ClassNotFoundException e) {
      return new MethodDescriptor[0];
   }

   return (MethodDescriptor[]) descriptors.toArray(new MethodDescriptor[descriptors.size()]);
}
 
Example #29
Source File: Test8040656.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void test(Class<?> type, Class<?> bean) throws Exception {
    for (MethodDescriptor md : Introspector.getBeanInfo(bean).getMethodDescriptors()) {
        if (md.getName().equals("getFoo")) {
            if (type != md.getMethod().getReturnType()) {
                throw new Error("unexpected type");
            }
        }
    }
}
 
Example #30
Source File: Test6277246.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IntrospectionException {
    Class type = BASE64Encoder.class;
    System.setSecurityManager(new SecurityManager());
    BeanInfo info = Introspector.getBeanInfo(type);
    for (MethodDescriptor md : info.getMethodDescriptors()) {
        Method method = md.getMethod();
        System.out.println(method);

        String name = method.getDeclaringClass().getName();
        if (name.startsWith("sun.misc.")) {
            throw new Error("found inaccessible method");
        }
    }
}