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

Class Wrong Version

 
Sondra Colagrossi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am compiling ( javac-ing ) a file with ANT and I get the following message -
C:\eclipse\workspace\titan\com\titan\cabin\CabinBean.java:6: cannot access java.lang.Object
bad class file: C:\Program Files\Java\j2re1.4.0_01\lib\rt.jar(java/lang/Object.class)
class file has wrong version 48.0, should be 47.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

I suspect this is because javac is finding my 1.4 jdk but should be using my 1.3 jdk. But what I am curious about is the information about the version of java.lang.Object available through an API?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there's no standard API for pulling information out of a class file. There are plenty of 3rd-party tools to do this; see, for example, the BCEL libary.
 
Sondra Colagrossi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
So they are violating the ecapsulation of a class file and extracting a private field, is that right?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So they are violating the ecapsulation of a class file and extracting a private field, is that right?

Huh?
A .class file is kind of like an ELF or COFF object file. It's got various data in it, some of which has to do with the class the file represents, and some of which doesn't. One such piece of information that "doesn't" is the class file version, which we're talking about here. Another such piece of data is the "magic number" that identifies the file as a .class file -- the hex digits "CAFEBABE" at the beginning of the file.
This has nothing to do with "violating encapsultation." This just has to do with treating a class file as data used by the JVM and examining it as such, like a traditional linker does.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic