This week's book giveaway is in the iOS forum.
We're giving away four copies of Classic Computer Science Problems in Swift and have David Kopec on-line!
See this thread for details.
Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using reflection for button listeners, throwing ClassNotFound exception  RSS feed

 
Greenhorn
Posts: 15
Java Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Me and my team are trying to use reflection to implement the listeners for the buttons in this simple calculator. We are doing this for an engineering class. We added a break point at line 35 "Class aListenerClass = Class.forName(splitString[0]);" because it keeps throwing a ClassNotFound exception, and it's being thrown after we split the string to identify the right listener. The "Controller" you see there, well, we are implementing the Application Controller pattern for the back-end of this calculator...

Why in the world is it throwing ClassNotFound? When we run this on debug mode in eclipse, we can check the value of the split elements, right? Well... it shows "CalculateListener" for the first element of the split string, yet when we expand the element it lists [C,a,l,c,u,l,a,t,e,L,i,s,t,e,n,e,r,_,e,q,u,a,l,s] as it's value--as if the string never got split, but it is being split! Check our code below. I'm also including the R file, so you guys can check all the ids and see how we are implementing reflection here. Please give us some light We would be eternally grateful!

In advance, thank you so much!

Sincerely,

Ben, Diego (0x783czar), Trevor, David, and Steve.



 
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure the resulted class name is qualified with its package name. For example: com.yourdomain.CalculateListener
 
Ben Alex Barreto
Greenhorn
Posts: 15
Java Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hussein Baghdadi wrote:Make sure the resulted class name is qualified with its package name. For example: com.yourdomain.CalculateListener



That was exactly right! Thank you o much! We are going past that exception now :-)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!