-->
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.  [ 5 posts ] 
Author Message
 Post subject: Bug: ClassCastException when using event listeners
PostPosted: Thu Oct 13, 2005 2:35 pm 
Newbie

Joined: Mon Sep 12, 2005 3:25 pm
Posts: 4
Hello,

I think there is a bug in org.hibernate.cfg.Configuration. The line
Code:
eventListeners.setSaveOrUpdateEventListeners( ( SaveOrUpdateEventListener[] ) listeners );

throws a CastClassException. I tried this litte program:
Code:
class MyClass {
  public static void main(String[] args) {
    Object[] listeners = new Object[1];
    listeners[0]=new MyClass();

    MyClass[] results = (MyClass[]) listeners;
    System.out.println("Finished");
  }
}

and it also throws a ClassCastException.
I wonder if this has something to do with the java version I'm using, since I don't think that I'm the first one who is using event listeners.

I hope I'm not wrongly reporting this error.
Best regards,
Björn

Hibernate version:
3.1beta1

Java version:
1.5.0
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 13, 2005 3:14 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
I suggest you revisit MyClass


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 13, 2005 3:24 pm 
Newbie

Joined: Mon Sep 12, 2005 3:25 pm
Posts: 4
Could you elaborate?
In my opinion the small example shows that it is not possible to cast an array of Objects to an array of MyClass or SaveOrUpdateEventListeners.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 3:03 am 
Newbie

Joined: Mon Sep 12, 2005 3:25 pm
Posts: 4
Hello again,

@Dennis: I still can't see where a fault should be in my test program except that it reproduces the ClassCastException, as expected.

Despite this, I now noticed that the bug I reported has apparently been fixed in revision 1.96 of the file Configuration.java. I will get a new library version and test it this evening.

Björn


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 12:27 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
MyClass might as well be a one line 'throw new Exception()' . yes, it throws a CCE, so it looks like the JVm is working. However it has nothing to do w/ Hibernat.e


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

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.