java.lang.ArrayStoreException类的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(240)

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

ArrayStoreException介绍

[英]Thrown when a program attempts to store an element of an incompatible type in an array.
[中]当程序试图在数组中存储不兼容类型的元素时引发。

代码示例

代码示例来源:origin: plutext/docx4j

throw new ArrayStoreException
  ("Destination byte[] must have room for at least 16 bytes, " +
   "but has a length of only " + dst.length + ".");

代码示例来源:origin: robovm/robovm

} else if (value instanceof ArrayStoreException) {
  ArrayStoreException ase = (ArrayStoreException)value;
  throw new ArrayStoreException(ase.getMessage());

代码示例来源:origin: weexteam/weex-hackernews

static boolean registerNativeModule(String moduleName, ModuleFactory factory) throws WXException {
 if (factory == null) {
  return false;
 }
 try {
  sModuleFactoryMap.put(moduleName, factory);
 }catch (ArrayStoreException e){
  e.printStackTrace();
  //ignore:
  //may throw this exception:
  //java.lang.String cannot be stored in an array of type java.util.HashMap$HashMapEntry[]
 }
 return true;
}

代码示例来源:origin: org.glassfish.main.common/annotation-framework

private HandlerProcessingResult processAnnotations(ProcessingContext ctx, AnnotatedElement element)
  throws AnnotationProcessorException
{

  HandlerProcessingResultImpl result= new HandlerProcessingResultImpl();
  try{
  for (Annotation annotation : element.getAnnotations()) {
    // initialize the result...
    AnnotationInfo subElement = new AnnotationInfo(ctx, element, annotation, getTopElementType());
    if (!result.processedAnnotations().containsKey(annotation.annotationType())) {
      process(ctx, subElement, result);
    } else {
      if (AnnotationUtils.shouldLog("annotation")) { 
        logger.finer("Annotation " + annotation.annotationType() + " already processed");
      }
    }       
  } 
} catch (ArrayStoreException e) {
  logger.info("Exception " + e.toString()
    + " encountered while processing annotaton for element "
    + element + ". Message is: " + e.getMessage()
    + ". Ignoring annotations and proceeding.");
}
  return result;
}

代码示例来源:origin: eclipse-ee4j/glassfish

private HandlerProcessingResult processAnnotations(ProcessingContext ctx, AnnotatedElement element)
  throws AnnotationProcessorException
{

  HandlerProcessingResultImpl result= new HandlerProcessingResultImpl();
  try{
  for (Annotation annotation : element.getAnnotations()) {
    // initialize the result...
    AnnotationInfo subElement = new AnnotationInfo(ctx, element, annotation, getTopElementType());
    if (!result.processedAnnotations().containsKey(annotation.annotationType())) {
      process(ctx, subElement, result);
    } else {
      if (AnnotationUtils.shouldLog("annotation")) { 
        logger.finer("Annotation " + annotation.annotationType() + " already processed");
      }
    }       
  } 
} catch (ArrayStoreException e) {
  logger.info("Exception " + e.toString()
    + " encountered while processing annotaton for element "
    + element + ". Message is: " + e.getMessage()
    + ". Ignoring annotations and proceeding.");
}
  return result;
}

代码示例来源:origin: org.apache.poi/poi

throw new ArrayStoreException
  ("Destination byte[] must have room for at least 16 bytes, " +
   "but has a length of only " + dst.length + ".");

代码示例来源:origin: robovm/robovm

} else if (value instanceof ArrayStoreException) {
  ArrayStoreException e = (ArrayStoreException) value;
  throw new ArrayStoreException(e.getMessage());
} else {

代码示例来源:origin: weexteam/weex-hackernews

private static boolean registerNativeComponent(String type, IFComponentHolder holder) throws WXException {
 try {
  holder.loadIfNonLazy();
  sTypeComponentMap.put(type, holder);
 }catch (ArrayStoreException e){
  e.printStackTrace();
  //ignore: ArrayStoreException: java.lang.String cannot be stored in an array of type java.util.HashMap$HashMapEntry[]
 }
 return true;
}

代码示例来源:origin: robovm/robovm

private static void arraycopy(Object[] src, int srcPos, Object[] dst, int dstPos, int length) {
  arraycopyCheckBounds(src.length, srcPos, dst.length, dstPos, length);
  if (length > 0) {
    // TODO: Use arraycopyFast() if src.class and dst.class have same dimensionality and (src instanceof dst)
    int i = 0;
    try {
      // Check if this is a forward or backwards arraycopy
      if (src != dst || srcPos > dstPos || srcPos + length <= dstPos) {
        for (i = 0; i < length; ++i) {
          dst[dstPos + i] = src[srcPos + i];
        }
      } else {
        for (i = length - 1; i >= 0; --i) {
          dst[dstPos + i] = src[srcPos + i];
        }
      }
    } catch (ArrayStoreException e) {
      // Throw a new one with a more descriptive message.
      Class<?> srcElemClass = src[i + srcPos].getClass();
      String srcElemTypeName = srcElemClass.isArray() 
                  ? srcElemClass.getCanonicalName() : srcElemClass.getName();
      throw new ArrayStoreException(String.format(
          "source[%d] of type %s cannot be stored in destination array of type %s",
          i + srcPos, srcElemTypeName, dst.getClass().getCanonicalName()));
    }
  }
}

代码示例来源:origin: ibinti/bugvm

} else if (value instanceof ArrayStoreException) {
  ArrayStoreException ase = (ArrayStoreException)value;
  throw new ArrayStoreException(ase.getMessage());

代码示例来源:origin: org.apache.directory.mavibot/mavibot

ase.printStackTrace();
throw ase;

代码示例来源:origin: real-logic/agrona

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
public <T> T[] toArray(final T[] into)
{
  final Class<?> componentType = into.getClass().getComponentType();
  if (!componentType.isAssignableFrom(Integer.class))
  {
    throw new ArrayStoreException("cannot store Integers in array of type " + componentType);
  }
  @DoNotSub final int size = size();
  final T[] arrayCopy = into.length >= size ? into : (T[])Array.newInstance(componentType, size);
  copyValues(arrayCopy);
  return arrayCopy;
}

代码示例来源:origin: MobiVM/robovm

} else if (value instanceof ArrayStoreException) {
  ArrayStoreException ase = (ArrayStoreException)value;
  throw new ArrayStoreException(ase.getMessage());

代码示例来源:origin: robovm/robovm

Class<?> type2 = dst.getClass();
if (!type1.isArray()) {
  throw new ArrayStoreException("source of type " + type1.getName() + " is not an array");
  throw new ArrayStoreException("destination of type " + type2.getName() + " is not an array");
if (!componentType1.isPrimitive()) {
  if (componentType2.isPrimitive()) {
    throw new ArrayStoreException(type1.getCanonicalName() + " and " + type2.getCanonicalName() 
        + " are incompatible array types");
} else {
  if (componentType2 != componentType1) {
    throw new ArrayStoreException(type1.getCanonicalName() + " and " + type2.getCanonicalName() 
        + " are incompatible array types");

代码示例来源:origin: com.github.vindell/spring-biz

} else if (value instanceof ArrayStoreException) {  
  ArrayStoreException ase = (ArrayStoreException)value;  
  throw new ArrayStoreException(ase.getMessage());

代码示例来源:origin: com.google.gwt/gwt-servlet

public static void checkCriticalArrayType(boolean expression) {
 if (!expression) {
  throw new ArrayStoreException();
 }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

} else if (value instanceof ArrayStoreException) {
  ArrayStoreException ase = (ArrayStoreException)value;
  throw new ArrayStoreException(ase.getMessage());

代码示例来源:origin: com.google.gwt/gwt-servlet

public static void checkCriticalArrayType(boolean expression, Object errorMessage) {
 if (!expression) {
  throw new ArrayStoreException(String.valueOf(errorMessage));
 }
}

代码示例来源:origin: com.bugvm/bugvm-rt

} else if (value instanceof ArrayStoreException) {
  ArrayStoreException ase = (ArrayStoreException)value;
  throw new ArrayStoreException(ase.getMessage());

代码示例来源:origin: vsch/flexmark-java

@Override
public <T> T[] toArray(T[] array) {
  Object[] objects = array;
  int count = cardinality();
  if (!array.getClass().getComponentType().isAssignableFrom(Integer.class)) {
    throw new ArrayStoreException("Cannot store Integer in array of " + array.getClass().getName());
  }
  if (array.length < count) {
    objects = array.getClass() == Object[].class ? new Object[count] : (Object[]) Array.newInstance(array.getClass().getComponentType(), count);
  }
  int i = 0;
  for (Integer bitIndex : this) {
    array[i++] = (T) bitIndex;
  }
  if (objects.length > ++i) {
    objects[i] = null;
  }
  return (T[]) objects;
}

相关文章