Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class compilation confusion.....

 
Chinmay Bajikar
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a utility class(SmartData.class),which will do things such as Date,Time parsing for me.
Previously, I had "seconds" (public)member variable in this class as "float".
But after introdusing support for milli-seconds,we decided to change it to
"double".
Now comes a another class(DataUser.class) which is using SmartData inside some of its api's.
And accesses the seconds member var of this class.
The problem started when I just compiled SmartData.java and updated my jar with it.
When the code was run and the particular part accessing seconds member var
of SmartData was accessed by DataUser's api's,it gave me a illegal access
exception.
Why is this so?
On compiling DataUser.java with the latest jar in the classpath,we could
elimnate that exception.
I understand about class dependencies.
But why would a static change like changing the data type of a public member
give me an illegal access exception.
This is something which I didnt know.......
Thanks in advance,
Chinmay
 
Chinmay Bajikar
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Has anybody read this??
 
Loren Rosen
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got one part of your program that thinks this variable is a double, and another that thinks it's a long. Why should it be surprising this causes a problem? At least in Java this happens in a well-defined way-- in C or C++ your program would simply mysteriously crash, but precisely where and how would be hard to predict.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic