Bad version

User f5e6ccf034

13-09-2006 11:45:30

The 3.1.7.1 release advertises itself as 3.1.3! I am using the chemaxon.jchem.VersionInfo.JCHEM_VERSION field. So, which is it?





Thanks.

ChemAxon 9c0afc9aaf

13-09-2006 20:24:38

Hi,
Quote:
The 3.1.7.1 release advertises itself as 3.1.3! I am using the chemaxon.jchem.VersionInfo.JCHEM_VERSION field.
No, it does not.





You can easily check the jar file by issuing the following command:





$ java -jar jchem.jar





The result is:





Code:



JChem version: 3.1.7.1


Table version: 31       (for determining if regeneration is necessary)






It might be the case that some compiler cache wasn't properly updated.


It is also recommended to delete the contents of the "work" directory of Tomcat after upgrade.





Best regards,





Szilard

User f5e6ccf034

13-09-2006 21:02:14

This is weird. I have this small test class:





Code:
import chemaxon.jchem.VersionInfo;





public class Test_JChem_Version {





    public static final void main(String[] argv) throws Exception {


        System.out.println(VersionInfo.JCHEM_VERSION);


        String res = "/chemaxon/jchem/VersionInfo.class";


        System.out.println(VersionInfo.class.getResource(res));


    }


}








Now if I do


Code:
 $ java -cp ".;c:\\Program Files\\ChemAxon\\jchem-3.1.7.1\\lib\\jchem.jar" Test_JChem_Version



I get


Code:
3.1.3


jar:file:/C:/Program%20Files/ChemAxon/jchem-3.1.7.1/lib/jchem.jar!/chemaxon/jchem/VersionInfo.class





but


Code:
 java -jar "c:\\Program Files\\ChemAxon\\jchem-3.1.7.1\\lib\\jchem.jar"



gives me


Code:
JChem version: 3.1.7.1


Table version: 31



I don't understand... It's the right jar and JCHEM_VERSION looks definitely wrong.

ChemAxon aa7c50abf8

14-09-2006 01:16:31

The compiler will normally hard-wire any values referenced by public static final variables (like VersionInfo.JCHEM_VERSION) into your class files. If you compile your testprogram against JChem 3.1.3, "3.1.3" is hard-wired into the resulting class file(s) and you will get "3.1.3" no matter which JChem version is on your classpath at runtime.





Instead of directly referencing VersionInfo.JCHEM_VERSION in your code, use reflection:


Code:
Class vinfo = Class.forName("chemaxon.jchem.VersionInfo");


Field jcVersionField = vinfo.getField("JCHEM_VERSION");


Object jcVersion = jcVersionField.get(null);


System.out.println(jcVersion);

ChemAxon 9c0afc9aaf

14-09-2006 08:45:56

Hi,





We have removed the "final" modifier of the constant, so compilations of future versions won't be able to "inline" the value.





Meanwhile you can solve this problem by recompiling your class using the appropriate jchem.jar.


(clearly a different jar version was used for compilation than for running)





Thank you for reporting this.





Best regards,





Szilard

User f5e6ccf034

14-09-2006 15:26:03

You are right and I should thought about this. It happened after a "field upgrade" in which a new jchem.jar was dropped into an existing application directory. Clearly that was not a good idea.

ChemAxon 9c0afc9aaf

14-09-2006 15:34:51

Quote:
Clearly that was not a good idea.
Actually I still think that it was us (more specifically myself) who made a mistake by declaring this constant as static final.


After all one may distribute a JChem-based application in binary (class or jar) format which is expected to work with multiple versions of jchem.jar


So it's our fault, and don't argue with that ! :)





Szilard