-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Bug in ClassValidator for primitives arrays
PostPosted: Fri Jul 18, 2008 2:17 am 
Newbie

Joined: Fri Sep 30, 2005 3:03 am
Posts: 1
I have the annotation :

Code:
@Retention(RetentionPolicy.RUNTIME)
@Target( { ElementType.METHOD })
@Documented
@Inherited
public @interface Size {
  int[] value() default {};
}


used on a pojo method like this (note:there is no compilation error) :

Code:
 
  @Size({50,10})
  public String getLibelle() {
    return this.libelle;
  }


ClassValidator hang up on

Code:
if ( valueMethod.getReturnType().isArray() ) {
  values = (Object[]) valueMethod.invoke( annotation );  <== ClassCastException
}


It's hang up because value is an array of primitives types (int[]) , not a (object[])


Hibernate version:
hibernate-validator-3.1.0.CR1

hibernate-annotations-3.4.0.CR1
hibernate-distribution-3.3.0.CR1-dist
hibernate-entitymanager-3.4.0.CR1.tar


Full stack trace of any exception that occurs:
Code:
java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:373)
   at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1125)
   at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226)



Code:
Caused by: java.lang.IllegalStateException: java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
   at org.hibernate.validator.ClassValidator.handleAggregateAnnotations(ClassValidator.java:256)
   at org.hibernate.validator.ClassValidator.createMemberValidator(ClassValidator.java:312)
   at org.hibernate.validator.ClassValidator.initValidator(ClassValidator.java:217)
   at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:133)
   ... 12 more


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.