微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java.lang.annotation.AnnotationTypeMismatchException的实例源码

项目:sqlitemagic    文件ViewCollectionStep.java   
@Override
public boolean process(Set<? extends TypeElement> annotations,RoundEnvironment roundEnv) {
  boolean isSuccessfulProcess = true;
  for (Element element : roundEnv.getElementsAnnotatedWith(View.class)) {
    try {
      final ViewElement viewElement = new ViewElement(environment,element);
      if (!validator.isViewElementValid(viewElement)) {
        isSuccessfulProcess = false;
      } else {
        environment.addViewElement(viewElement);
      }
    } catch (AnnotationTypeMismatchException ex) {
      environment.error(element,String.format("@%s and @%s annotation attribute values must be self defined constant expressions",View.class.getSimpleName(),ViewColumn.class.getSimpleName()));
      return false;
    } catch (Exception e) {
      environment.error(element,"View collection error = " + e.getMessage());
      e.printstacktrace();
      return false;
    }
  }

  return isSuccessfulProcess;
}
项目:In-the-Box-Fork    文件AnnotationMember.java   
/**
 * Validates contained value against its member deFinition
 * and if ok returns the value.
 * Otherwise,if the value type mismatches deFinition
 * or the value itself describes an error,* throws appropriate exception.
 * <br> Note,this method may return null if this element was constructed
 * with such value.
 *
 * @see #rethrowError()
 * @see #copyValue()
 * @return actual valid value or null if no value
 */
public Object validateValue() throws Throwable {
    if (tag == ERROR) {
        rethrowError();
    }
    if (value == NO_VALUE) {
        return null;
    }
    if (elementType == value.getClass()
            || elementType.isinstance(value)) { // nested annotation value
        return copyValue();
    } else {
        throw new AnnotationTypeMismatchException(definingMethod,value.getClass().getName());
    }

}
项目:cn1    文件AnnotationMember.java   
/**
 * Validates contained value against its member deFinition
 * and if ok returns the value.
 * Otherwise,if the value type mismatches deFinition 
 * or the value itself describes an error,this method may return null if this element was constructed 
 * with such value.  
 * 
 * @see #rethrowError()
 * @see #copyValue()
 * @return actual valid value or null if no value
 */
public Object validateValue() throws Throwable {
    if (tag == ERROR) {
        rethrowError();
    } 
    if (value == NO_VALUE) {
        return null;
    }
    if (elementType == value.getClass() 
            || elementType.isinstance(value)) { // nested annotation value
        return copyValue();
    } else {
        throw new AnnotationTypeMismatchException(definingMethod,value.getClass().getName());
    }

}
项目:freeVM    文件AnnotationMember.java   
/**
 * Validates contained value against its member deFinition
 * and if ok returns the value.
 * Otherwise,value.getClass().getName());
    }

}
项目:j2objc    文件AnnotationTypeMismatchExceptionTest.java   
public void testSerialization() throws Exception {
    Method m = String.class.getmethod("length");
    AnnotationTypeMismatchException original = new AnnotationTypeMismatchException(m,"poop");

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        // AnnotationTypeMismatchException is broken: it's Serializable but has a non-transient
        // non-serializable field of type Method.
        new ObjectOutputStream(out).writeObject(original);
        fail();
    } catch (NotSerializableException expected) {
    }
}
项目:In-the-Box-Fork    文件AnnotationTypeMismatchExceptionTest.java   
/**
 * @throws ClassNotFoundException
 * @throws SecurityException
 * @tests java.lang.annotation.AnnotationTypeMismatchException#AnnotationTypeMismatchException(Method,*        String)
 */
@SuppressWarnings("nls")
public void test_constructorLjava_lang_reflect_MethodLjava_lang_String() throws SecurityException,ClassNotFoundException {
    Method[] methods = Class.forName("java.lang.String").getmethods();
    Method m = methods[0];
    AnnotationTypeMismatchException e = new AnnotationTypeMismatchException(
            m,"some type");
    assertNotNull("can not instantiate AnnotationTypeMismatchException",e);
    assertSame("wrong method name",m,e.element());
    assertEquals("wrong found type","some type",e.foundType());
}
项目:deep-spark    文件EntityDeepJobConfig.java   
@Override
public void validate() {

    if (entityClass == null) {
        throw new IllegalArgumentException("testentity class cannot be null");
    }

    if (!entityClass.isAnnotationPresent(DeepEntity.class)) {
        throw new AnnotationTypeMismatchException(null,entityClass.getCanonicalName());
    }

    super.validate();

    /* let's validate fieldNames in @DeepField annotations */
    Field[] deepFields = AnnotationUtils.filterDeepFields(entityClass);

    Map<String,Cell> colDefs = super.columnDeFinitions();

    /* colDefs is null if table does not exist. I.E. this configuration will be used as an output configuration
     object,and the output table is dynamically created */
    if (colDefs == null) {
        return;
    }

    for (Field field : deepFields) {
        String annotationFieldName = AnnotationUtils.deepFieldName(field);

        if (!colDefs.containsKey(annotationFieldName)) {
            throw new DeepNoSuchFieldException("UnkNown column name \'" + annotationFieldName + "\' specified for" +
                    " field " + entityClass.getCanonicalName() + "#" + field.getName() + ". Please," +
                    "make sure the field name you specify in @DeepField annotation matches _exactly_ the column " +
                    "name " +
                    "in the database");
        }
    }
}
项目:cn1    文件AnnotationTypeMismatchExceptionTest.java   
/**
 * @throws ClassNotFoundException 
 * @throws SecurityException 
 * @tests java.lang.annotation.AnnotationTypeMismatchException#AnnotationTypeMismatchException(Method,e.foundType());
}
项目:freeVM    文件AnnotationTypeMismatchExceptionTest.java   
/**
 * @throws ClassNotFoundException 
 * @throws SecurityException 
 * @tests java.lang.annotation.AnnotationTypeMismatchException#AnnotationTypeMismatchException(Method,"some type");
    assertNotNull("can not instanciate AnnotationTypeMismatchException",e.foundType());
}
项目:byte-buddy    文件AnnotationDescriptionAnnotationInvocationHandlerTest.java   
@Test(expected = AnnotationTypeMismatchException.class)
@SuppressWarnings("unchecked")
public void testAnnotationTypeMismatchException() throws Throwable {
    when(loadedAnnotationValue.resolve()).thenReturn(new Object());
    Proxy.getInvocationHandler(AnnotationDescription.AnnotationInvocationHandler.of(getClass().getClassLoader(),Foo.class,Collections.<String,AnnotationValue<?,?>>singletonMap(FOO,annotationValue)))
            .invoke(new Object(),Foo.class.getDeclaredMethod("foo"),new Object[0]);
}
项目:javify    文件AnnotationInvocationHandler.java   
public Object invoke(Object proxy,Method method,Object[] args)
   throws Throwable
 {
   String methodName = method.getName().intern();

   if (args == null || args.length == 0)
     {
if (methodName == "toString")
  {
    return toString();
  }
else if (methodName == "hashCode")
  {
    return Integer.valueOf(hashCode());
  }
else if (methodName == "annotationType")
  {
    return type;
  }
else
  {
    Object val = memberValues.get(methodName);
    if (val == null)
      {
    throw new IncompleteAnnotationException(type,methodName);
      }
    try
      {
    if (val.getClass().isArray())
      val = coerce((Object[])val,method.getReturnType());
      }
    catch (ArrayStoreException _)
      {
    throw new AnnotationTypeMismatchException
      (method,val.getClass().getName());
      }
    if (! getBoxedReturnType(method).isinstance(val))
      throw (new AnnotationTypeMismatchException
         (method,val.getClass().getName()));
    return val;
  }
     }
   else if (args.length == 1)
     {
if (methodName == "equals")
  {
    return Boolean.valueOf(equals(proxy,args[0]));
  }
     }
   throw new InternalError("Invalid annotation proxy");
 }
项目:javify    文件AnnotationInvocationHandler.java   
public Object invoke(Object proxy,Object[] args)
  throws Throwable
{
    String methodName = method.getName().intern();
    if (args == null || args.length == 0)
    {
        if (methodName == "toString")
        {
            return toString(type,memberValues);
        }
        else if (methodName == "hashCode")
        {
            return Integer.valueOf(hashCode(type,memberValues));
        }
        else if (methodName == "annotationType")
        {
            return type;
        }
        else
        {
            Object val = memberValues.get(methodName);
            if (val == null)
            {
                throw new IncompleteAnnotationException(type,methodName);
            }
            if (! getBoxedReturnType(method).isinstance(val))
            {
                throw new AnnotationTypeMismatchException(method,val.getClass().getName());
            }
            if (val.getClass().isArray())
            {
                val = arrayClone(val);
            }
            return val;
        }
    }
    else if (args.length == 1)
    {
        if (methodName == "equals")
        {
            return Boolean.valueOf(equals(type,memberValues,args[0]));
        }
    }
    throw new InternalError("Invalid annotation proxy");
}
项目:jvm-stm    文件AnnotationInvocationHandler.java   
public Object invoke(Object proxy,Object[] args)
    throws Throwable
  {
      String methodName = method.getName().intern();
      if (args == null || args.length == 0)
      {
          if (methodName == "toString")
          {
              return toString(type,memberValues);
          }
          else if (methodName == "hashCode")
          {
              return Integer.valueOf(hashCode(type,memberValues));
          }
          else if (methodName == "annotationType")
          {
              return type;
          }
          else
          {
              Object val = memberValues.get(methodName);
              if (val == null)
              {
                  throw new IncompleteAnnotationException(type,methodName);
              }
              if (! getBoxedReturnType(method).isinstance(val))
              {
                  throw new AnnotationTypeMismatchException(method,val.getClass().getName());
              }
if (val.getClass().isArray())
{
    val = arrayClone(val);
}
              return val;
          }
      }
      else if (args.length == 1)
      {
          if (methodName == "equals")
          {
              return Boolean.valueOf(equals(type,args[0]));
          }
      }
      throw new InternalError("Invalid annotation proxy");
  }
项目:jvm-stm    文件AnnotationInvocationHandler.java   
public Object invoke(Object proxy,args[0]));
  }
     }
   throw new InternalError("Invalid annotation proxy");
 }
项目:j2objc    文件AnnotationTypeMismatchExceptionTest.java   
public void testGetters() throws Exception {
    Method m = String.class.getmethod("length");
    AnnotationTypeMismatchException ex = new AnnotationTypeMismatchException(m,"poop");
    assertSame(m,ex.element());
    assertEquals("poop",ex.foundType());
}
项目:JamVM-PH    文件AnnotationInvocationHandler.java   
public Object invoke(Object proxy,args[0]));
  }
     }
   throw new InternalError("Invalid annotation proxy");
 }
项目:JamVM-PH    文件AnnotationInvocationHandler.java   
public Object invoke(Object proxy,args[0]));
          }
      }
      throw new InternalError("Invalid annotation proxy");
  }
项目:classpath    文件AnnotationInvocationHandler.java   
public Object invoke(Object proxy,args[0]));
        }
    }
    throw new InternalError("Invalid annotation proxy");
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。