java.lang.NoSuchFieldException.getCause()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中java.lang.NoSuchFieldException.getCause()方法的一些代码示例,展示了NoSuchFieldException.getCause()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NoSuchFieldException.getCause()方法的具体详情如下:
包路径:java.lang.NoSuchFieldException
类名称:NoSuchFieldException
方法名:getCause

NoSuchFieldException.getCause介绍

暂无

代码示例

代码示例来源:origin: kiegroup/jbpm

private Object getValueOfField(String fieldname, Class<?> sourceClass, Object source ) {
  String sourceClassName = sourceClass.getName();

  Field field = null;
  try {
    field = sourceClass.getDeclaredField(fieldname);
    field.setAccessible(true);
  } catch (SecurityException e) {
    fail("Unable to retrieve " + fieldname + " field from " + sourceClassName + ": " + e.getCause());
  } catch (NoSuchFieldException e) {
    fail("Unable to retrieve " + fieldname + " field from " + sourceClassName + ": " + e.getCause());
  }

  assertNotNull("." + fieldname + " field is null!?!", field);
  Object fieldValue = null;
  try {
    fieldValue = field.get(source);
  } catch (IllegalArgumentException e) {
    fail("Unable to retrieve value of " + fieldname + " from " + sourceClassName + ": " + e.getCause());
  } catch (IllegalAccessException e) {
    fail("Unable to retrieve value of " + fieldname + " from " + sourceClassName + ": " + e.getCause());
  }
  return fieldValue;
}

代码示例来源:origin: kiegroup/jbpm

fail("Unable to retrieve " + fieldname + " field from " + sourceClassName + ": " + e.getCause());
} catch (NoSuchFieldException e) {
  fail("Unable to retrieve " + fieldname + " field from " + sourceClassName + ": " + e.getCause());

代码示例来源:origin: org.osgl/osgl-tool

public UnexpectedNoSuchFieldException(NoSuchFieldException cause) {
  super(cause.getCause(), cause.getMessage());
}

代码示例来源:origin: osglworks/java-tool

public UnexpectedNoSuchFieldException(NoSuchFieldException cause) {
  super(cause.getCause(), cause.getMessage());
}

代码示例来源:origin: org.jboss.weld.servlet/weld-servlet-shaded

@Override
public T create(BeanInstance beanInstance) {
  try {
    final T instance = super.create(beanInstance);
    if (beanIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), BEAN_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      beanIdField = f;
    }
    if (contextIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), CONTEXT_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      contextIdField = f;
    }
    beanIdField.set(instance, beanId);
    contextIdField.set(instance, getContextId());
    return instance;
  } catch (IllegalAccessException e) {
    throw new RuntimeException(e);
  } catch (NoSuchFieldException e) {
    throw new RuntimeException(e.getCause());
  }
}

代码示例来源:origin: org.jboss.weld.se/weld-se-shaded

@Override
public T create(BeanInstance beanInstance) {
  try {
    final T instance = super.create(beanInstance);
    if (beanIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), BEAN_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      beanIdField = f;
    }
    if (contextIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), CONTEXT_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      contextIdField = f;
    }
    beanIdField.set(instance, beanId);
    contextIdField.set(instance, getContextId());
    return instance;
  } catch (IllegalAccessException e) {
    throw new RuntimeException(e);
  } catch (NoSuchFieldException e) {
    throw new RuntimeException(e.getCause());
  }
}

代码示例来源:origin: org.jboss.weld.se/weld-se

@Override
public T create(BeanInstance beanInstance) {
  try {
    final T instance = super.create(beanInstance);
    if (beanIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), BEAN_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      beanIdField = f;
    }
    if (contextIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), CONTEXT_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      contextIdField = f;
    }
    beanIdField.set(instance, beanId);
    contextIdField.set(instance, getContextId());
    return instance;
  } catch (IllegalAccessException e) {
    throw new RuntimeException(e);
  } catch (NoSuchFieldException e) {
    throw new RuntimeException(e.getCause());
  }
}

代码示例来源:origin: weld/core

@Override
public T create(BeanInstance beanInstance) {
  try {
    final T instance = super.create(beanInstance);
    if (beanIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), BEAN_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      beanIdField = f;
    }
    if (contextIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), CONTEXT_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      contextIdField = f;
    }
    beanIdField.set(instance, beanId);
    contextIdField.set(instance, getContextId());
    return instance;
  } catch (IllegalAccessException e) {
    throw new RuntimeException(e);
  } catch (NoSuchFieldException e) {
    throw new RuntimeException(e.getCause());
  }
}

代码示例来源:origin: weld/core

@Override
public T create(BeanInstance beanInstance) {
  try {
    final T instance = super.create(beanInstance);
    if (beanIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), BEAN_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      beanIdField = f;
    }
    if (contextIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), CONTEXT_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      contextIdField = f;
    }
    beanIdField.set(instance, beanId);
    contextIdField.set(instance, getContextId());
    return instance;
  } catch (IllegalAccessException e) {
    throw new RuntimeException(e);
  } catch (NoSuchFieldException e) {
    throw new RuntimeException(e.getCause());
  }
}

代码示例来源:origin: weld/core

@Override
public T create(BeanInstance beanInstance) {
  try {
    final T instance = super.create(beanInstance);
    if (beanIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), BEAN_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      beanIdField = f;
    }
    if (contextIdField == null) {
      final Field f = SecurityActions.getDeclaredField(instance.getClass(), CONTEXT_ID_FIELD);
      SecurityActions.ensureAccessible(f);
      contextIdField = f;
    }
    beanIdField.set(instance, beanId);
    contextIdField.set(instance, getContextId());
    return instance;
  } catch (IllegalAccessException e) {
    throw new RuntimeException(e);
  } catch (NoSuchFieldException e) {
    throw new RuntimeException(e.getCause());
  }
}

代码示例来源:origin: apache/deltaspike

@Test
public void rethrowCheckedException()
{
  try
  {
    invalidOperation();
  }
  catch (NoSuchFieldException e)
  {
    Assert.assertEquals(FIELD_DOES_NOT_EXIST, e.getMessage());
    Assert.assertEquals(null, e.getCause());
    return;
  }
  Assert.fail();
}

代码示例来源:origin: org.jbpm/jbpm-bpmn2

private Object getValueOfField(String fieldname, Class<?> sourceClass, Object source ) {
  String sourceClassName = sourceClass.getName();

  Field field = null;
  try {
    field = sourceClass.getDeclaredField(fieldname);
    field.setAccessible(true);
  } catch (SecurityException e) {
    fail("Unable to retrieve " + fieldname + " field from " + sourceClassName + ": " + e.getCause());
  } catch (NoSuchFieldException e) {
    fail("Unable to retrieve " + fieldname + " field from " + sourceClassName + ": " + e.getCause());
  }

  assertNotNull("." + fieldname + " field is null!?!", field);
  Object fieldValue = null;
  try {
    fieldValue = field.get(source);
  } catch (IllegalArgumentException e) {
    fail("Unable to retrieve value of " + fieldname + " from " + sourceClassName + ": " + e.getCause());
  } catch (IllegalAccessException e) {
    fail("Unable to retrieve value of " + fieldname + " from " + sourceClassName + ": " + e.getCause());
  }
  return fieldValue;
}

代码示例来源:origin: org.kie/drools-infinispan-persistence

fail("Unable to retrieve " + fieldname + " field from " + sourceClassName + ": " + e.getCause());
} catch (NoSuchFieldException e) {
  fail("Unable to retrieve " + fieldname + " field from " + sourceClassName + ": " + e.getCause());

相关文章