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 

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

@Target( { ElementType.METHOD })
public @interface Size {
  int[] value() default {};

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

  public String getLibelle() {
    return this.libelle;

ClassValidator hang up on

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:


Full stack trace of any exception that occurs:
   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)

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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.