• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java reflection suddenly bugged  RSS feed

 
Jan Herfs
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
one of my tools worked without a problem for years. Old Jar files still work without a problem. But as soon as I export a new Jar file in eclipse, I encounter some weird bugs.

At first there was this Bug:
There is a class A in my project. At runtime at a certain moment, that class A gets new sourcecode, gets compiled and loaded again (the new file is placed on C:\ outside of the workspace). No problem in my old jar files. But as soon as i export my tool now, i get exceptions saying, that "org.blablala.A cannot be cast to org.blablabla.A". Cannot cast to itself suddenly?
But now i get this one:
The tool successfully compiles that new class A, and loads it without an error. But: It starts working with the old Class. My tool expects there to be a new field "a" in my new class, but wont find it, since java still working with the old fieldless class, running into an exception. The eclipse console also shows a link to that old java file in the exception.

The background why i use reflection: The tool gets a set of data from an oracle database. The user can define custom Java functions to validate that data. Stuff like "if(a > b){ show me some warning}" Those functions get compiled at runtime.

Any Ideas? Or what information is missing?
Using Eclipse SDk 4.2.1
Java SE Dev Kit 7 Update 21 (64-bit) (Installed 14.05.2013)
Java 7 Update 71 (Installed 16.10.2014)
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan Herfs wrote:i get exceptions saying, that "org.blablala.A cannot be cast to org.blablabla.A".


You will get this message when the two A classes belong to different classloaders. I don't know anything about your tool, or what exporting a jar to it means, or how you're running it in Eclipse, so I can't comment on those parts of the question.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!